X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPayment%2FPayflowPro.php;h=2020b2a8cd81d9ae53c3d33c68b8b37fe2eaefc8;hb=f14a8cc5397fca2a4ed9ea754337730c3285aff8;hp=a250deb845d0be2aa3d3f46ee7d2a3ac70e89bbd;hpb=36e8224efef0a494578975f58bf5cb1982591c87;p=civicrm-core.git diff --git a/CRM/Core/Payment/PayflowPro.php b/CRM/Core/Payment/PayflowPro.php index a250deb845..2020b2a8cd 100644 --- a/CRM/Core/Payment/PayflowPro.php +++ b/CRM/Core/Payment/PayflowPro.php @@ -1,7 +1,7 @@ $params['cvv2'], 'EXPDATE' => urlencode(sprintf('%02d', (int) $params['month']) . substr($params['year'], 2, 2)), 'ACCTTYPE' => urlencode($params['credit_card_type']), - 'AMT' => urlencode($params['amount']), + 'AMT' => urlencode($this->getAmount($params)), 'CURRENCY' => urlencode($params['currency']), 'FIRSTNAME' => $params['billing_first_name'], //credit card name @@ -131,7 +131,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { $payflow_query_array['TRXTYPE'] = 'R'; $payflow_query_array['OPTIONALTRX'] = 'S'; - $payflow_query_array['OPTIONALTRXAMT'] = $params['amount']; + $payflow_query_array['OPTIONALTRXAMT'] = $this->getAmount($params); //Amount of the initial Transaction. Required $payflow_query_array['ACTION'] = 'A'; //A for add recurring (M-modify,C-cancel,R-reactivate,I-inquiry,P-payment @@ -268,6 +268,10 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { * Payment successfully sent to gateway - process the response now */ $result = strstr($responseData, "RESULT"); + if (empty($result)) { + return self::errorExit(9016, "No RESULT code from PayPal."); + } + $nvpArray = array(); while (strlen($result)) { // name @@ -299,7 +303,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { /******************************************************* * Success ! - * This is a successful transaction. PayFlow Pro does return further information + * This is a successful transaction. Payflow Pro does return further information * about transactions to help you identify fraud including whether they pass * the cvv check, the avs check. This is stored in * CiviCRM as part of the transact @@ -340,10 +344,9 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { return self::errorExit(9014, "Check the code - all transactions should have been headed off before they got here. Something slipped through the net"); } - /* - * Produces error message and returns from class - */ /** + * Produces error message and returns from class + * * @param null $errorCode * @param null $errorMessage * @@ -361,10 +364,9 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { } - /* - * NOTE: 'doTransferCheckout' not implemented - */ /** + * NOTE: 'doTransferCheckout' not implemented + * * @param array $params * @param $component * @@ -374,28 +376,14 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { CRM_Core_Error::fatal(ts('This function is not implemented')); } - /* + /** * This public function checks to see if we have the right processor config values set * * NOTE: Called by Events and Contribute to check config params are set prior to trying * register any credit card details * - * @param string $mode - * The mode we are operating in (live or test) - not used. - * - * returns string $errorMsg if any errors found - null if OK - */ - - // function checkConfig( $mode ) // CiviCRM V1.9 Declaration - - /** - * CiviCRM V2.0 Declaration - * This function checks to see if we have the right config values - * - * @internal param string $mode the mode we are operating in (live or test) - * - * @return string - * the error message if any + * @return string|null + * the error message if any, null if OK */ public function checkConfig() { $errorMsg = array(); @@ -414,12 +402,10 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { return NULL; } } - //end check config - /* - * convert to a name/value pair (nvp) string - */ /** + * convert to a name/value pair (nvp) string + * * @param $payflow_query_array * * @return array|string @@ -433,22 +419,15 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { return $payflow_query; } - /* - * Submit transaction using CuRL - * @submiturl string Url to direct HTTPS GET to - * @payflow_query value string to be posted - */ /** - * @param $submiturl - * @param $payflow_query + * Submit transaction using cURL + * + * @param string $submiturl Url to direct HTTPS GET to + * @param $payflow_query value string to be posted * * @return mixed|object */ public function submit_transaction($submiturl, $payflow_query) { - /* - * Submit transaction using CuRL - */ - // get data ready for API $user_agent = $_SERVER['HTTP_USER_AGENT']; // Here's your custom headers; adjust appropriately for your setup: @@ -463,7 +442,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { $headers[] = "X-VPS-Timeout: 45"; //random unique number - the transaction is retried using this transaction ID // in this function but if that doesn't work and it is re- submitted - // it is treated as a new attempt. PayflowPro doesn't allow + // it is treated as a new attempt. Payflow Pro doesn't allow // you to change details (e.g. card no) when you re-submit // you can only try the same details $headers[] = "X-VPS-Request-ID: " . rand(1, 1000000000); @@ -524,6 +503,9 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { break; } } + if ($responseHeaders['http_code'] != 200) { + return self::errorExit(9015, "Error connecting to the Payflow Pro API server."); + } /* * Transaction submitted - @@ -584,84 +566,5 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { curl_close($ch); return $responseData; } - //end submit_transaction - - /** - * @param int $recurringProfileID - * @param int $processorID - * - * @throws Exception - */ - public function getRecurringTransactionStatus($recurringProfileID, $processorID) { - if (!defined('CURLOPT_SSLCERT')) { - CRM_Core_Error::fatal(ts('PayFlowPro requires curl with SSL support')); - } - - /* - * define variables for connecting with the gateway - */ - - //if you have not set up a separate user account the vendor name is used as the username - if (!$this->_paymentProcessor['subject']) { - $user = $this->_paymentProcessor['user_name']; - } - else { - $user = $this->_paymentProcessor['subject']; - } - //$recurringProfileID = "RT0000000001"; - // c $trythis = $this->getRecurringTransactionStatus($recurringProfileID,17); - - /* - *Create the array of variables to be sent to the processor from the $params array - * passed into this function - * - */ - - $payflow_query_array = array( - 'USER' => $user, - 'VENDOR' => $this->_paymentProcessor['user_name'], - 'PARTNER' => $this->_paymentProcessor['signature'], - 'PWD' => $this->_paymentProcessor['password'], - // C - Direct Payment using credit card - 'TENDER' => 'C', - // A - Authorization, S - Sale - 'TRXTYPE' => 'R', - 'ACTION' => 'I', - //A for add recurring - //(M-modify,C-cancel,R-reactivate, - //I-inquiry,P-payment - 'ORIGPROFILEID' => $recurringProfileID, - 'PAYMENTHISTORY' => 'Y', - ); - - $payflow_query = $this->convert_to_nvp($payflow_query_array); - echo $payflow_query; - $submiturl = $this->_paymentProcessor['url_site']; - //ie. url at payment processor to submit to. - $responseData = self::submit_transaction($submiturl, $payflow_query); - /* - * Payment successfully sent to gateway - process the response now - */ - - $result = strstr($responseData, "RESULT"); - $nvpArray = array(); - while (strlen($result)) { - // name - $keypos = strpos($result, '='); - $keyval = substr($result, 0, $keypos); - // value - $valuepos = strpos($result, '&') ? strpos($result, '&') : strlen($result); - $valval = substr($result, $keypos + 1, $valuepos - $keypos - 1); - // decoding the respose - $nvpArray[$keyval] = $valval; - $result = substr($result, $valuepos + 1, strlen($result)); - } - // get the result code to validate. - $result_code = $nvpArray['RESULT']; - print_r($responseData); - - //RESPMSG=Invalid Profile ID: Invalid recurring profile ID - //RT0000000001 - } }