/*
- * Copyright (C) 2009
- * Licensed to CiviCRM under the Academic Free License version 3.0.
- *
- * Written and contributed by Kirkdesigns (http://www.kirkdesigns.co.uk)
- *
- */
+ * Copyright (C) 2009
+ * Licensed to CiviCRM under the Academic Free License version 3.0.
+ *
+ * Written and contributed by Kirkdesigns (http://www.kirkdesigns.co.uk)
+ */
/**
*
/**
* Constructor
*
- * @param string $mode the mode of operation: live or test
+ * @param string $mode
+ * The mode of operation: live or test.
*
* @param $paymentProcessor
*
$this->_setParam('sequence', rand(1, 1000));
}
- /**
- * Singleton function used to manage this object
- *
- * @param string $mode the mode of operation: live or test
- *
- * @param object $paymentProcessor
- *
- * @return object
- * @static
- */
- public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) {
- $processorName = $paymentProcessor['name'];
- if (self::$_singleton[$processorName] === NULL) {
- self::$_singleton[$processorName] = new CRM_Core_Payment_Realex($mode, $paymentProcessor);
- }
- return self::$_singleton[$processorName];
- }
-
/**
* @param array $params
*
/**
* Submit a payment using Advanced Integration Method
*
- * @param array $params assoc array of input parameters for this transaction
+ * @param array $params
+ * Assoc array of input parameters for this transaction.
*
- * @return array the result in a nice formatted array (or an error object)
+ * @return array
+ * the result in a nice formatted array (or an error object)
*/
public function doDirectPayment(&$params) {
}
// Create sha1 hash for request
- $hashme = "{$this->_getParam('timestamp')}.{$this->_getParam('merchant_ref')}.{$this->_getParam('order_id')}.{$this->_getParam('amount')}.{$this->_getParam('currency')}.{$this->_getParam('card_number')}";
+ $hashme = "{$this->_getParam('timestamp')}.{$this->_getParam('merchant_ref')}.{$this->_getParam('order_id')}.{$this->_getParam('amount')}.{$this->_getParam('currency')}.{$this->_getParam('card_number')}";
$sha1hash = sha1($hashme);
- $hashme = "$sha1hash.{$this->_getParam('secret')}";
+ $hashme = "$sha1hash.{$this->_getParam('secret')}";
$sha1hash = sha1($hashme);
-
// Generate the request xml that is send to Realex Payments.
$request_xml = "<request type='auth' timestamp='{$this->_getParam('timestamp')}'>
<merchantid>{$this->_getParam('merchant_ref')}</merchantid>
}
// Check the response hash
- $hashme = "{$this->_getParam('timestamp')}.{$this->_getParam('merchant_ref')}.{$this->_getParam('order_id')}.{$response['RESULT']}.{$response['MESSAGE']}.{$response['PASREF']}.{$response['AUTHCODE']}";
+ $hashme = "{$this->_getParam('timestamp')}.{$this->_getParam('merchant_ref')}.{$this->_getParam('order_id')}.{$response['RESULT']}.{$response['MESSAGE']}.{$response['PASREF']}.{$response['AUTHCODE']}";
$sha1hash = sha1($hashme);
- $hashme = "$sha1hash.{$this->_getParam('secret')}";
+ $hashme = "$sha1hash.{$this->_getParam('secret')}";
$sha1hash = sha1($hashme);
if ($response['SHA1HASH'] != $sha1hash) {
/**
* Helper function to convert XML string to multi-dimension array.
*
- * @param $xml
+ * @param string $xml
* an XML string.
*
- * @return array An array of the result with following keys:
+ * @return array
+ * An array of the result with following keys:
*/
public function xml_parse_into_assoc($xml) {
$input = array();
array(
1 => xml_get_error_code($xmlparser),
2 => xml_get_current_line_number($xmlparser),
- 3 => xml_get_current_column_number($xmlparser)
+ 3 => xml_get_current_column_number($xmlparser),
)
);
}
return $result;
}
- // private helper for xml_parse_into_assoc, to recusively parsing the result
/**
+ * Private helper for xml_parse_into_assoc, to recusively parsing the result
* @param $input
* @param int $depth
*
* Format the params from the form ready for sending to Realex. Also perform some validation
*/
public function setRealexFields(&$params) {
- if ((int)$params['amount'] <= 0) {
+ if ((int) $params['amount'] <= 0) {
return self::error(9001, ts('Amount must be positive'));
}
$this->_setParam('currency', $config->defaultCurrency);
// Format the expiry date to MMYY
- $expmonth = (string)$params['month'];
+ $expmonth = (string) $params['month'];
$expmonth = (strlen($expmonth) === 1) ? '0' . $expmonth : $expmonth;
- $expyear = substr((string)$params['year'], 2, 2);
+ $expyear = substr((string) $params['year'], 2, 2);
$this->_setParam('exp_date', $expmonth . $expyear);
if (isset($params['credit_card_start_date']) && (strlen($params['credit_card_start_date']['M']) !== 0) &&
(strlen($params['credit_card_start_date']['Y']) !== 0)
) {
- $startmonth = (string)$params['credit_card_start_date']['M'];
+ $startmonth = (string) $params['credit_card_start_date']['M'];
$startmonth = (strlen($startmonth) === 1) ? '0' . $startmonth : $startmonth;
- $startyear = substr((string)$params['credit_card_start_date']['Y'], 2, 2);
+ $startyear = substr((string) $params['credit_card_start_date']['Y'], 2, 2);
$this->_setParam('start_date', $startmonth . $startyear);
}
/**
* Checks to see if invoice_id already exists in db
*
- * @param int $invoiceId The ID to check
+ * @param int $invoiceId
+ * The ID to check.
*
- * @return bool True if ID exists, else false
+ * @return bool
+ * True if ID exists, else false
*/
public function _checkDupe($invoiceId) {
$contribution = new CRM_Contribute_DAO_Contribution();
/**
* Get the value of a field if set
*
- * @param string $field the field
+ * @param string $field
+ * The field.
*
- * @return mixed value of the field, or empty string if the field is
- * not set
+ * @return mixed
+ * value of the field, or empty string if the field is
+ * not set
*/
public function _getParam($field) {
if (isset($this->_params[$field])) {
* @param string $field
* @param mixed $value
*
- * @return bool false if value is not a scalar, true if successful
+ * @return bool
+ * false if value is not a scalar, true if successful
*/
public function _setParam($field, $value) {
if (!is_scalar($value)) {
/**
* This function checks to see if we have the right config values
*
- * @return string the error message if any
+ * @return string
+ * the error message if any
*/
public function checkConfig() {
$error = array();