X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPayment%2FeWAY.php;h=71457de839318fb0df9410358449dafe609165bd;hb=a922142c067998cb0ffb4cbc95a71aa370ffdc88;hp=8605b3ac852bd65d19fc3c68f5af7807131f0b99;hpb=11df99209d13885aaf45a5c94612bdc65eb490ff;p=civicrm-core.git diff --git a/CRM/Core/Payment/eWAY.php b/CRM/Core/Payment/eWAY.php index 8605b3ac85..71457de839 100644 --- a/CRM/Core/Payment/eWAY.php +++ b/CRM/Core/Payment/eWAY.php @@ -57,42 +57,42 @@ */ /** - ----------------------------------------------------------------------------------------------- - From the eWAY supplied 'Web.config' dated 25-Sep-2006 - check date and update links if required - ----------------------------------------------------------------------------------------------- - - LIVE gateway with CVN - https://www.eway.com.au/gateway_cvn/xmlpayment.asp - - LIVE gateway without CVN - https://www.eway.com.au/gateway/xmlpayment.asp - - - Test gateway with CVN - https://www.eway.com.au/gateway_cvn/xmltest/TestPage.asp - - Test gateway without CVN - https://www.eway.com.au/gateway/xmltest/TestPage.asp - - - LIVE gateway for Stored Transactions - https://www.eway.com.au/gateway/xmlstored.asp - - - ----------------------------------------------------------------------------------------------- - From the eWAY web-site - http://www.eway.com.au/Support/Developer/PaymentsRealTime.aspx - ----------------------------------------------------------------------------------------------- - The test Customer ID is 87654321 - this is the only ID that will work on the test gateway. - The test Credit Card number is 4444333322221111 - - this is the only credit card number that will work on the test gateway. - The test Total Amount should end in 00 or 08 to get a successful response (e.g. $10.00 or $10.08) - ie - all other amounts will return a failed response. - - ----------------------------------------------------------------------------------------------- + * ----------------------------------------------------------------------------------------------- + * From the eWAY supplied 'Web.config' dated 25-Sep-2006 - check date and update links if required + * ----------------------------------------------------------------------------------------------- + * + * LIVE gateway with CVN + * https://www.eway.com.au/gateway_cvn/xmlpayment.asp + * + * LIVE gateway without CVN + * https://www.eway.com.au/gateway/xmlpayment.asp + * + * + * Test gateway with CVN + * https://www.eway.com.au/gateway_cvn/xmltest/TestPage.asp + * + * Test gateway without CVN + * https://www.eway.com.au/gateway/xmltest/TestPage.asp + * + * + * LIVE gateway for Stored Transactions + * https://www.eway.com.au/gateway/xmlstored.asp + * + * + * ----------------------------------------------------------------------------------------------- + * From the eWAY web-site - http://www.eway.com.au/Support/Developer/PaymentsRealTime.aspx + * ----------------------------------------------------------------------------------------------- + * The test Customer ID is 87654321 - this is the only ID that will work on the test gateway. + * The test Credit Card number is 4444333322221111 + * - this is the only credit card number that will work on the test gateway. + * The test Total Amount should end in 00 or 08 to get a successful response (e.g. $10.00 or $10.08) + * ie - all other amounts will return a failed response. + * + * ----------------------------------------------------------------------------------------------- **/ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { # (not used, implicit in the API, might need to convert?) - CONST CHARSET = 'UTF-8'; + const CHARSET = 'UTF-8'; /** * We only need one instance of this object. So we use the singleton @@ -106,14 +106,15 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { /********************************************************** * Constructor * - * @param string $mode the mode of operation: live or test + * @param string $mode + * The mode of operation: live or test. * * @param $paymentProcessor * * @return \CRM_Core_Payment_eWAY ******************************************************* */ - function __construct($mode, &$paymentProcessor) { - // require Standaard eWAY API libraries + public function __construct($mode, &$paymentProcessor) { + // require Standard eWAY API libraries require_once 'eWAY/eWAY_GatewayRequest.php'; require_once 'eWAY/eWAY_GatewayResponse.php'; @@ -123,31 +124,11 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { $this->_processorName = ts('eWay'); } - /** - * Singleton function used to manage this object - * - * @param string $mode the mode of operation: live or test - * - * @param object $paymentProcessor - * @param null $paymentForm - * @param bool $force - * - * @return object - * @static - */ - static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) { - $processorName = $paymentProcessor['name']; - if (self::$_singleton[$processorName] === NULL) { - self::$_singleton[$processorName] = new CRM_Core_Payment_eWAY($mode, $paymentProcessor); - } - return self::$_singleton[$processorName]; - } - /********************************************************** * This function sends request and receives response from * eWAY payment process **********************************************************/ - function doDirectPayment(&$params) { + public function doDirectPayment(&$params) { if (CRM_Utils_Array::value('is_recur', $params) == TRUE) { CRM_Core_Error::fatal(ts('eWAY - recurring payments not implemented')); } @@ -185,12 +166,11 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { $country = $params['country']; */ - //------------------------------------------------------------- // Prepare some composite data from _paymentProcessor fields //------------------------------------------------------------- $fullAddress = $params['street_address'] . ", " . $params['city'] . ", " . $params['state_province'] . "."; - $expireYear = substr($params['year'], 2, 2); + $expireYear = substr($params['year'], 2, 2); $expireMonth = sprintf('%02d', (int) $params['month']); // CiviCRM V1.9 - Picks up reasonable description //$description = $params['amount_level']; @@ -316,12 +296,14 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { $errorDesc = curl_error($submit); // Paranoia - in the unlikley event that 'curl' errno fails - if ($errorNum == 0) - $errorNum = 9005; + if ($errorNum == 0) { + $errorNum = 9005; + } // Paranoia - in the unlikley event that 'curl' error fails - if (strlen($errorDesc) == 0) - $errorDesc = "Connection to eWAY payment gateway failed"; + if (strlen($errorDesc) == 0) { + $errorDesc = "Connection to eWAY payment gateway failed"; + } return self::errorExit($errorNum, $errorDesc); } @@ -403,12 +385,12 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { $trxn_id = str_replace( 'test', '', $trxn_id ); $trxn_id = intval($trxn_id) + 1; $params['trxn_id'] = sprintf('test%08d', $trxn_id); - } else { + } + else { $params['trxn_id'] = $eWAYResponse->TransactionNumber(); } */ - //============= // Success ! //============= @@ -427,11 +409,13 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { /** * 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 */ - function _checkDupe($invoiceId) { + public function _checkDupe($invoiceId) { $contribution = new CRM_Contribute_DAO_Contribution(); $contribution->invoice_id = $invoiceId; return $contribution->find(); @@ -440,7 +424,7 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { /************************************************************************************************* * This function checks the eWAY response status - returning a boolean false if status != 'true' *************************************************************************************************/ - function isError(&$response) { + public function isError(&$response) { $status = $response->Status(); if ((stripos($status, "true")) === FALSE) { @@ -452,7 +436,7 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { /************************************************** * Produces error message and returns from class **************************************************/ - function &errorExit($errorCode = NULL, $errorMessage = NULL) { + public function &errorExit($errorCode = NULL, $errorMessage = NULL) { $e = CRM_Core_Error::singleton(); if ($errorCode) { @@ -467,7 +451,7 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { /************************************************** * NOTE: 'doTransferCheckout' not implemented **************************************************/ - function doTransferCheckout(&$params, $component) { + public function doTransferCheckout(&$params, $component) { CRM_Core_Error::fatal(ts('This function is not implemented')); } @@ -488,7 +472,7 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { */ //function checkConfig( $mode ) // CiviCRM V1.9 Declaration // CiviCRM V2.0 Declaration - function checkConfig() { + public function checkConfig() { $errorMsg = array(); if (empty($this->_paymentProcessor['user_name'])) { @@ -514,11 +498,10 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { * @param $p_request * @param $p_response */ - function send_alert_email($p_eWAY_tran_num, $p_trxn_out, $p_trxn_back, $p_request, $p_response) { + public function send_alert_email($p_eWAY_tran_num, $p_trxn_out, $p_trxn_back, $p_request, $p_response) { // Initialization call is required to use CiviCRM APIs. civicrm_initialize(TRUE); - list($fromName, $fromEmail) = CRM_Core_BAO_Domain::getNameAndEmail(); $from = "$fromName <$fromEmail>"; @@ -556,15 +539,14 @@ The CiviCRM eWAY Payment Processor Module $params = array(); $params['groupName'] = 'eWay Email Sender'; - $params['from'] = $from; - $params['toName'] = $toName; - $params['toEmail'] = $toEmail; - $params['subject'] = $subject; - $params['cc'] = $cc; - $params['text'] = $message; + $params['from'] = $from; + $params['toName'] = $toName; + $params['toEmail'] = $toEmail; + $params['subject'] = $subject; + $params['cc'] = $cc; + $params['text'] = $message; CRM_Utils_Mail::send($params); } } // end class CRM_Core_Payment_eWAY -