コード例 #1
0
		/**
		* check 3d secure Authentication response and take relavent action
		*
		*/
		protected function _Handle3DCallBackResponse()
		{

			require(dirname(__FILE__).'/lib/CentinelClient.php');
			$centinelClient = new CentinelClient;

			$centinelClient->Add("MsgType", "cmpi_authenticate");
			$centinelClient->Add("Version", "1.7");
			$centinelClient->Add("ProcessorId", $this->GetValue('cardinalprocessorid'));
			$centinelClient->Add("MerchantId", $this->GetValue('cardinalmerchantid'));
			$centinelClient->Add("TransactionPwd", $this->GetValue('cardinaltransactionpwd'));
			$centinelClient->Add("TransactionType", 'C');
			$centinelClient->Add("TransactionId", $_SESSION['CHECKOUT']['CardinalTransactionId']);
			$centinelClient->Add("PAResPayload", $_REQUEST['PaRes']);

			$this->_testmode = $this->GetValue("testmode") == "YES";

			if ($this->_testmode) {
				$transactionURL = $this->_cardinalTestTransactionURL;
			}
			else {
				$transactionURL = $this->_cardinalLiveTransactionURL;
			}

			$centinelClient->sendHTTP($transactionURL, "30", "30");


			if($centinelClient->getValue("ErrorNo") == '0') {
				$PAResStatus = $centinelClient->getValue("PAResStatus");
				$SignatureVerification = $centinelClient->getValue("SignatureVerification");

				//if cardholder is authticated successfully
				if(($PAResStatus == 'Y' || $PAResStatus == 'A') && $SignatureVerification =='Y') {

					$DPFields = array (
						'AUTHSTATUS3DS'	=> $centinelClient->getValue("PAResStatus"),
						'MPIVENDOR3DS'	=> $_SESSION['CHECKOUT']['CardinalEnrolled'],
						'CAVV'			=> $centinelClient->getValue("Cavv"),
						'ECI'			=> $centinelClient->getValue("EciFlag"),
						'XID'			=> $centinelClient->getValue("Xid"),
					);


					if($this->_doDirectPayment($_SESSION['CHECKOUT']['CardDetails'], $DPFields)) {
						return ORDER_STATUS_AWAITING_FULFILLMENT;
					} else {
						return ORDER_STATUS_DECLINED;
					}
				} else {
					$this->RedirectToOrderConfirmation(GetLang('UnauthorizedMessage'), true);
					exit;
				}
			} else {
				//redirect back to order confirmation page.
				$this->RedirectToOrderConfirmation($centinelClient->getValue("ErrorDesc"), true);
				exit;
			}
		}
コード例 #2
0
 function authorise_3dsecure()
 {
     if (!session_id()) {
         session_start();
     }
     if (!class_exists('CentinelClient')) {
         include_once 'lib/CentinelClient.php';
     }
     $pares = !empty($_POST['PaRes']) ? $_POST['PaRes'] : '';
     $merchant_data = !empty($_POST['MD']) ? unserialize(urldecode($_POST['MD'])) : '';
     $order_id = $_SESSION["Centinel_orderid"];
     $order = new WC_Order($order_id);
     /******************************************************************************/
     /*                                                                            */
     /*    If the PaRes is Not Empty then process the cmpi_authenticate message    */
     /*                                                                            */
     /******************************************************************************/
     if (strcasecmp('', $pares) != 0 && $pares != null) {
         $centinelClient = new CentinelClient();
         $centinelClient->add('MsgType', 'cmpi_authenticate');
         $centinelClient->add("Version", "1.7");
         $centinelClient->add("ProcessorId", $this->centinel_pid);
         $centinelClient->add("MerchantId", $this->centinel_mid);
         $centinelClient->add("TransactionPwd", $this->centinel_pwd);
         $centinelClient->add("TransactionType", 'C');
         $centinelClient->add('OrderId', $_SESSION['Centinel_OrderId']);
         $centinelClient->add('TransactionId', $_SESSION['Centinel_TransactionId']);
         $centinelClient->add('PAResPayload', $pares);
         $centinelClient->sendHttp($this->centinel_url, "5000", "15000");
         $_SESSION["Centinel_cmpiMessageResp"] = $centinelClient->response;
         // Save authenticate response in session
         $_SESSION["Centinel_PAResStatus"] = $centinelClient->getValue("PAResStatus");
         $_SESSION["Centinel_SignatureVerification"] = $centinelClient->getValue("SignatureVerification");
         $_SESSION["Centinel_ErrorNo"] = $centinelClient->getValue("ErrorNo");
         $_SESSION["Centinel_ErrorDesc"] = $centinelClient->getValue("ErrorDesc");
         $_SESSION["Centinel_EciFlag"] = $centinelClient->getValue("EciFlag");
         $_SESSION["Centinel_Cavv"] = $centinelClient->getValue("Cavv");
         $_SESSION["Centinel_Xid"] = $centinelClient->getValue("Xid");
     } else {
         $_SESSION["Centinel_ErrorNo"] = "0";
         $_SESSION["Centinel_ErrorDesc"] = "NO PARES RETURNED";
     }
     /******************************************************************************/
     /*                                                                            */
     /*                  Determine if the transaction resulted in                  */
     /*                  an error.                                                 */
     /*                                                                            */
     /******************************************************************************/
     $redirect_url = $this->get_return_url($order);
     if ($this->liability_shift) {
         if ($_SESSION["Centinel_EciFlag"] == '07' || $_SESSION["Centinel_EciFlag"] == '01') {
             $pc_authentication_unavailable = apply_filters('angelleye_pc_3d_authentication_unavailable', __('Authentication unavailable.  Please try a different payment method or card.', 'paypal-for-woocommerce'));
             wc_add_notice($pc_authentication_unavailable, "error");
             $order->update_status('failed', __('3D Secure error: No liability shift', 'paypal-for-woocommerce'));
             wp_redirect($redirect_url);
             exit;
         }
     }
     if ($_SESSION['Centinel_ErrorNo'] == "0") {
         if (($_SESSION["Centinel_PAResStatus"] == "Y" || $_SESSION["Centinel_PAResStatus"] == "A" || $_SESSION["Centinel_PAResStatus"] == "U") && $_SESSION['Centinel_SignatureVerification'] == "Y") {
             // If we are here we can process the card
             $this->do_payment($order, $merchant_data['card'], $merchant_data['type'], $merchant_data['card_exp_month'], $merchant_data['card_exp_year'], $merchant_data['csc'], $_SESSION["Centinel_PAResStatus"], "Y", $_SESSION["Centinel_Cavv"], $_SESSION["Centinel_EciFlag"], $_SESSION["Centinel_Xid"]);
             $this->clear_centinel_session();
             wp_redirect($redirect_url);
             exit;
         } else {
             $pc_payer_authentication = apply_filters('angelleye_pc_3d_payer_authentication', __('Payer Authentication failed.  Please try a different payment method.', 'paypal-for-woocommerce'));
             wc_add_notice($pc_payer_authentication, "error");
             $order->update_status('failed', sprintf(__('3D Secure error: %s', 'paypal-for-woocommerce'), $_SESSION['Centinel_ErrorDesc']));
             wp_redirect($redirect_url);
             exit;
         }
     } else {
         $pc_3d_secure_authentication = apply_filters('angelleye_pc_3d_secure_authentication', __('Error in 3D secure authentication: ', 'paypal-for-woocommerce') . $_SESSION['Centinel_ErrorDesc'], $_SESSION['Centinel_ErrorDesc']);
         wc_add_notice($pc_3d_secure_authentication, "error");
         $order->update_status('failed', sprintf(__('3D Secure error: %s', 'paypal-for-woocommerce'), $_SESSION['Centinel_ErrorDesc']));
         wp_redirect($redirect_url);
         exit;
     }
 }
コード例 #3
0
 /**
  * Auth 3dsecure
  */
 public function authorise_3dsecure()
 {
     if (!class_exists('CentinelClient')) {
         include_once 'lib/CentinelClient.php';
     }
     $pares = !empty($_POST['PaRes']) ? $_POST['PaRes'] : '';
     $merchant_data = !empty($_POST['MD']) ? (array) json_decode(urldecode($_POST['MD'])) : '';
     $order_id = absint(!empty($merchant_data['order_id']) ? $merchant_data['order_id'] : WC()->session->get("paypal_pro_orderid"));
     $order = new WC_Order($order_id);
     $this->log('authorise_3dsecure() for order ' . absint($order_id));
     $this->log('authorise_3dsecure() PARes ' . print_r($pares, true));
     /******************************************************************************/
     /*                                                                            */
     /*    If the PaRes is Not Empty then process the cmpi_authenticate message    */
     /*                                                                            */
     /******************************************************************************/
     if (strcasecmp('', $pares) != 0 && $pares != null) {
         $centinelClient = new CentinelClient();
         $centinelClient->add('MsgType', 'cmpi_authenticate');
         $centinelClient->add("Version", "1.7");
         $centinelClient->add("ProcessorId", $this->centinel_pid);
         $centinelClient->add("MerchantId", $this->centinel_mid);
         $centinelClient->add("TransactionPwd", $this->centinel_pwd);
         $centinelClient->add("TransactionType", 'C');
         $centinelClient->add('OrderId', WC()->session->get('Centinel_OrderId'));
         $centinelClient->add('TransactionId', WC()->session->get('Centinel_TransactionId'));
         $centinelClient->add('PAResPayload', $pares);
         $centinelClient->sendHttp($this->centinel_url, "5000", "15000");
         $this->log('Centinal transaction ID ' . WC()->session->get('Centinel_TransactionId'));
         $this->log('Centinal client request: ' . print_r($centinelClient->request, true));
         $this->log('Centinal client response: ' . print_r($centinelClient->response, true));
         WC()->session->set("Centinel_cmpiMessageResp", $centinelClient->response);
         // Save authenticate response in session
         WC()->session->set("Centinel_PAResStatus", $centinelClient->getValue("PAResStatus"));
         WC()->session->set("Centinel_SignatureVerification", $centinelClient->getValue("SignatureVerification"));
         WC()->session->set("Centinel_ErrorNo", $centinelClient->getValue("ErrorNo"));
         WC()->session->set("Centinel_ErrorDesc", $centinelClient->getValue("ErrorDesc"));
         WC()->session->set("Centinel_EciFlag", $centinelClient->getValue("EciFlag"));
         WC()->session->set("Centinel_Cavv", $centinelClient->getValue("Cavv"));
         WC()->session->set("Centinel_Xid", $centinelClient->getValue("Xid"));
     } else {
         WC()->session->set("Centinel_ErrorNo", "0");
         WC()->session->set("Centinel_ErrorDesc", "NO PARES RETURNED");
     }
     /******************************************************************************/
     /*                                                                            */
     /*                  Determine if the transaction resulted in                  */
     /*                  an error.                                                 */
     /*                                                                            */
     /******************************************************************************/
     $redirect_url = $this->get_return_url($order);
     try {
         $pa_res_status = WC()->session->get("Centinel_PAResStatus");
         $eci_flag = WC()->session->get("Centinel_EciFlag");
         $error_no = WC()->session->get('Centinel_ErrorNo');
         $error_desc = WC()->session->get("Centinel_ErrorDesc");
         $cavv = WC()->session->get("Centinel_Cavv");
         $xid = WC()->session->get("Centinel_Xid");
         $sig_verification = WC()->session->get("Centinel_SignatureVerification");
         $this->log('3dsecure pa_res_status: ' . $pa_res_status);
         if ($this->liability_shift) {
             if ($eci_flag == '07' || $eci_flag == '01') {
                 $order->update_status('failed', __('3D Secure error: No liability shift', 'woocommerce-gateway-paypal-pro'));
                 throw new Exception(__('Authentication unavailable.  Please try a different payment method or card.', 'woocommerce-gateway-paypal-pro'));
             }
         }
         if ($error_no == "0") {
             if (($pa_res_status == "Y" || $pa_res_status == "A" || $pa_res_status == "U") && $sig_verification == "Y") {
                 // If we are here we can process the card
                 $this->do_payment($order, $merchant_data['card'], $merchant_data['type'], $merchant_data['card_exp_month'], $merchant_data['card_exp_year'], $merchant_data['csc'], $merchant_data['card_start_month'], $merchant_data['card_start_year'], $pa_res_status, "Y", $cavv, $eci_flag, $xid);
             } else {
                 $order->update_status('failed', sprintf(__('3D Secure error: %s', 'woocommerce-gateway-paypal-pro'), $error_desc));
                 throw new Exception(__('Payer Authentication failed.  Please try a different payment method.', 'woocommerce-gateway-paypal-pro'));
             }
         } else {
             $order->update_status('failed', sprintf(__('3D Secure error: %s', 'woocommerce-gateway-paypal-pro'), $error_desc));
             throw new Exception(__('Error in 3D secure authentication: ', 'woocommerce-gateway-paypal-pro') . $error_desc);
         }
     } catch (Exception $e) {
         wc_add_notice($e->getMessage(), 'error');
     }
     wp_redirect($redirect_url);
     exit;
 }