public function processPayment($data, $form) { // 1) Main Informations $member = $this->Member(); // 2) Mandatory Settings $inputs['CardHoldersName'] = $data['Eway_CreditCardHolderName']; $inputs['CardNumber'] = self::$test_mode ? self::$test_credit_card_number : implode('', $data['Eway_CreditCardNumber']); $inputs['CardExpiryMonth'] = substr($data['Eway_CreditCardExpiry'], 0, 2); $inputs['CardExpiryYear'] = substr($data['Eway_CreditCardExpiry'], 2, 2); if (self::$cvn_mode) { $inputs['CVN'] = $data['Eway_CreditCardCVN']; } $inputs['TotalAmount'] = self::$test_mode ? self::$test_amount : $this->Amount * 100; // 3) Payment Informations $inputs['CustomerInvoiceRef'] = $this->ID; // 4) Customer Informations $inputs['CustomerFirstName'] = $data['FirstName']; $inputs['CustomerLastName'] = $data['Surname']; $inputs['CustomerEmail'] = $data['Email']; $inputs['CustomerAddress'] = $data['Address'] . ' ' . $data['AddressLine2'] . ' ' . $data['City'] . ' ' . $data['Country']; $inputs['CustomerPostcode'] = $member->hasMethod('getPostCode') ? $member->getPostCode() : ''; // 5) Empty Informations $inputs['CustomerInvoiceDescription'] = ''; $inputs['TrxnNumber'] = ''; $inputs['Option1'] = ''; $inputs['Option2'] = ''; $inputs['Option3'] = ''; // 6) Eway Payment Creation $customerID = self::$test_mode ? EWAY_DEFAULT_CUSTOMER_ID : self::$customer_id; $paymentMethod = self::$cvn_mode ? REAL_TIME_CVN : REAL_TIME; $eway = new EwayPaymentLive(); $eway->EwayPaymentLive($customerID, $paymentMethod, !self::$test_mode); foreach ($inputs as $name => $value) { $eway->setTransactionData($name, $value); } // 7) Eway Transaction Sending $ewayResponseFields = $eway->doPayment(); // 8) Eway Response Management if ($ewayTrxnStatus = strtolower($ewayResponseFields['EWAYTRXNSTATUS'])) { $this->TxnRef = $ewayResponseFields['EWAYTRXNNUMBER']; $this->Message = $ewayResponseFields['EWAYTRXNERROR']; if ($ewayTrxnStatus == 'true') { $this->Status = 'Success'; $result = new Payment_Success(); } else { $this->Status = 'Failure'; $result = new Payment_Failure('The payment has not been completed correctly. An invalid response has been received from the Eway payment.'); } } else { $this->Status = 'Failure'; $result = new Payment_Failure('The payment has not been completed correctly. The payment request has not been sent to the Eway server correctly.'); } $this->write(); return $result; }
//for REAL_TIME_CVN $eway->setTransactionData("CVN", "123"); //for GEO_IP_ANTI_FRAUD $eway->setTransactionData("CustomerIPAddress", $eway->getVisitorIP()); //mandatory field when using Geo-IP Anti-Fraud $eway->setTransactionData("CustomerBillingCountry", "AU"); //mandatory field when using Geo-IP Anti-Fraud //special preferences for php Curl $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0); //pass a long that is set to a zero value to stop curl from verifying the peer's certificate //$eway->setCurlPreferences(CURLOPT_CAINFO, "/usr/share/ssl/certs/my.cert.crt"); //Pass a filename of a file holding one or more certificates to verify the peer with. This only makes sense when used in combination with the CURLOPT_SSL_VERIFYPEER option. //$eway->setCurlPreferences(CURLOPT_CAPATH, "/usr/share/ssl/certs/my.cert.path"); //$eway->setCurlPreferences(CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //use CURL proxy, for example godaddy.com hosting requires it //$eway->setCurlPreferences(CURLOPT_PROXY, "http://proxy.shr.secureserver.net:3128"); //use CURL proxy, for example godaddy.com hosting requires it $ewayResponseFields = $eway->doPayment(); if($ewayResponseFields["EWAYTRXNSTATUS"]=="False"){ print "Transaction Error: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n"; foreach($ewayResponseFields as $key => $value) print "\n<br>\$ewayResponseFields[\"$key\"] = $value"; //header("Location: trasnactionerrorpage.php"); //exit(); }else if($ewayResponseFields["EWAYTRXNSTATUS"]=="True"){ print "Transaction Success: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n"; foreach($ewayResponseFields as $key => $value) print "\n<br>\$ewayResponseFields[\"$key\"] = $value"; //header("Location: trasnactionsuccess.php"); //exit(); }
function _doPayment() { global $messageStack; if (MODULE_PAYMENT_EWAY_AU_SSL_VERIFIER > 0 && $request_type == 'NONSSL') { echo 'TRANSACTION ERROR: INSECURE (solutions: make it https:// or change "SSL Verifier" to FALSE from "eWay Payment" module)'; exit; } //live payment or hosted payment if (MODULE_PAYMENT_EWAYPAYMENT_PROCESSING_METHOD == REAL_TIME || MODULE_PAYMENT_EWAYPAYMENT_PROCESSING_METHOD == REAL_TIME_CVN || MODULE_PAYMENT_EWAYPAYMENT_PROCESSING_METHOD == GEO_IP_ANTI_FRAUD) { require_once 'ext/eway/eway_payment_live.php'; $eway = new EwayPaymentLive(MODULE_PAYMENT_EWAY_AU_CUSTOMER_ID, MODULE_PAYMENT_EWAYPAYMENT_PROCESSING_METHOD, MODULE_PAYMENT_EWAYPAYMENT_GATEWAY_MODE == 'Live gateway' ? true : false); // $eway->setTransactionData("TotalAmount", 1); $eway->setTransactionData("TotalAmount", $_POST['my_totalamount']); //mandatory field $eway->setTransactionData("CustomerFirstName", $_POST['my_firstname']); $eway->setTransactionData("CustomerLastName", $_POST['my_lastname']); $eway->setTransactionData("CustomerEmail", $_POST['my_email']); $eway->setTransactionData("CustomerAddress", $_POST['my_address']); $eway->setTransactionData("CustomerPostcode", $_POST['my_postcode']); $eway->setTransactionData("CustomerInvoiceDescription", $_POST['my_invoice_description']); $eway->setTransactionData("CustomerInvoiceRef", $_POST['my_invoice_ref']); $eway->setTransactionData("CardHoldersName", $_POST['my_card_name']); //mandatory field $eway->setTransactionData("CardNumber", $_POST['my_card_number']); //mandatory field $eway->setTransactionData("CardExpiryMonth", $_POST['my_card_exp_month']); //mandatory field $eway->setTransactionData("CardExpiryYear", $_POST['my_card_exp_year']); //mandatory field $eway->setTransactionData("TrxnNumber", ""); $eway->setTransactionData("Option1", $_POST['my_ewayOption1']); $eway->setTransactionData("Option2", ""); $eway->setTransactionData("Option3", ""); //for REAL_TIME_CVN $eway->setTransactionData("CVN", $_POST['my_eway_cvn']); if (MODULE_PAYMENT_EWAYPAYMENT_PROCESSING_METHOD == GEO_IP_ANTI_FRAUD) { //for GEO_IP_ANTI_FRAUD $eway->setTransactionData("CustomerIPAddress", $eway->getVisitorIP()); //mandatory field when using Geo-IP Anti-Fraud $eway->setTransactionData("CustomerBillingCountry", $_POST['my_country_code']); //mandatory field when using Geo-IP Anti-Fraud } //$eway->setCurlPreferences(CURLOPT_CAINFO, "/usr/share/ssl/certs/my.cert.crt"); //Pass a filename of a file holding one or more certificates to verify the peer with. This only makes sense when used in combination with the CURLOPT_SSL_VERIFYPEER option. //$eway->setCurlPreferences(CURLOPT_CAPATH, "/usr/share/ssl/certs/my.cert.path"); if (MODULE_PAYMENT_EWAY_AU_SSL_VERIFIER < 0) { $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0); } //pass a long that is set to a zero value to stop curl from verifying the peer's certificate if (MODULE_PAYMENT_EWAY_AU_CURL_PROXY != "") { $eway->setCurlPreferences(CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //use CURL proxy, for example godaddy.com hosting requires it $eway->setCurlPreferences(CURLOPT_PROXY, MODULE_PAYMENT_EWAY_AU_CURL_PROXY); //use CURL proxy, for example godaddy.com hosting requires it } $response = $eway->doPayment(); if ($response["EWAYTRXNSTATUS"] == "False") { $messageStack->add_session('checkout', $response[EWAYTRXNERROR], 'error'); osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'checkout&view=paymentInformationForm', 'SSL', null, null, true)); } else { if ($response["EWAYTRXNSTATUS"] == "True") { $comment = 'eWay ' . MODULE_PAYMENT_EWAYPAYMENT_PROCESSING_METHOD . ' Success[' . $response[EWAYTRXNERROR] . ']'; $this->_order_id = osC_Order::insert(); osC_Order::process($this->_order_id, $this->order_status, $comment); } } } else { //hosted payment require_once 'ext/eway/eway_payment_hosted.php'; $eway = new EwayPaymentHosted(MODULE_PAYMENT_EWAY_AU_CUSTOMER_ID, MODULE_PAYMENT_EWAYPAYMENT_PROCESSING_METHOD, MODULE_PAYMENT_EWAYPAYMENT_GATEWAY_MODE == 'Live gateway' ? true : false); $orders_id = 0; if (isset($_SESSION['prepOrderID'])) { $_prep = explode('-', $_SESSION['prepOrderID']); $orders_id = $_prep[1]; } $eway->setTransactionData("TotalAmount", $_POST['my_totalamount']); //mandatory field // $eway->setTransactionData("TotalAmount", 1); $eway->setTransactionData("CustomerFirstName", $_POST['my_firstname']); $eway->setTransactionData("CustomerLastName", $_POST['my_lastname']); $eway->setTransactionData("CustomerEmail", $_POST['my_email']); $eway->setTransactionData("CustomerAddress", $_POST['my_address']); $eway->setTransactionData("CustomerPostcode", $_POST['my_postcode']); $eway->setTransactionData("CustomerInvoiceDescription", $_POST['my_invoice_description']); $eway->setTransactionData("CustomerInvoiceRef", $_POST['my_invoice_ref']); $eway->setTransactionData("URL", osc_href_link(FILENAME_CHECKOUT, 'callback&module=' . $this->_code . '&return=yes&orders_id=' . $orders_id, 'SSL', null, null, true)); //the script that will receive the results: http://www.mywebsite.com.au/testewayhosted.php?return=yes $eway->setTransactionData("SiteTitle", STORE_NAME); $eway->setTransactionData("TrxnNumber", ""); $eway->setTransactionData("Option1", $_POST['my_ewayOption1']); $eway->setTransactionData("Option2", ""); $eway->setTransactionData("Option3", ""); $eway->doPayment(); exit; } }
function gateway_eway($seperator, $sessionid) { global $wpdb, $wpsc_cart; $purchase_log_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= '" . $sessionid . "' LIMIT 1"; $purchase_log = $wpdb->get_results($purchase_log_sql, ARRAY_A); $purchase_log = $purchase_log[0]; $cart_sql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`='" . $purchase_log['id'] . "'"; $cart = $wpdb->get_results($cart_sql, ARRAY_A); $member_subtype = get_product_meta($cart[0]['prodid'], 'is_permenant', true); $member_shiptype = get_product_meta($cart[0]['prodid'], 'membership_length', true); $member_shiptype = $member_shiptype[0]; $status = get_product_meta($cart[0]['prodid'], 'is_membership', true); $is_member = $status; $is_perm = $member_subtype; if ($_POST['collected_data'][get_option('eway_form_first_name')] != '') { $data['first_name'] = esc_attr($_POST['collected_data'][get_option('eway_form_first_name')]); } if ($_POST['collected_data'][get_option('eway_form_last_name')] != '') { $data['last_name'] = esc_attr($_POST['collected_data'][get_option('eway_form_last_name')]); } if ($_POST['collected_data'][get_option('eway_form_address')] != '') { $address_rows = explode("\n\r", $_POST['collected_data'][get_option('eway_form_address')]); $data['address1'] = esc_attr(str_replace(array("\n", "\r"), '', $address_rows[0])); unset($address_rows[0]); if ($address_rows != null) { $data['address2'] = implode(", ", $address_rows); } else { $data['address2'] = ''; } } //exit('<pre>'.print_r($wpsc_cart, true).'</pre>'); foreach ($wpsc_cart->cart_items as $item) { $itemsName .= $item->product_name . ', '; //exit('<pre>'.print_r($item,true).'</pre>'); } if ($_POST['collected_data'][get_option('eway_form_city')] != '') { $data['city'] = esc_attr($_POST['collected_data'][get_option('eway_form_city')]); } if (empty($_POST['collected_data'][get_option('eway_form_state')]) && isset($_POST['collected_data'][get_option('eway_form_country')][1]) && !empty($_POST['collected_data'][get_option('eway_form_country')][1])) { $data['state'] = $_POST['collected_data'][get_option('eway_form_country')][1]; } elseif (!empty($_POST['collected_data'][get_option('eway_form_state')])) { $data['state'] = $_POST['collected_data'][get_option('eway_form_state')]; } if ($_POST['collected_data'][get_option('eway_form_country')] != '') { $data['country'] = $_POST['collected_data'][get_option('eway_form_country')][0]; } if (is_numeric($_POST['collected_data'][get_option('eway_form_post_code')])) { $data['zip'] = esc_attr($_POST['collected_data'][get_option('eway_form_post_code')]); } if ($_POST['collected_data'][get_option('eway_form_email')]) { $data['email'] = $_POST['collected_data'][get_option('eway_form_email')]; } if ($_POST['collected_data'][get_option('email_form_field')] != null && $data['email'] == null) { $data['email'] = esc_attr($_POST['collected_data'][get_option('email_form_field')]); } // Live or Test Server? if (get_option('eway_test')) { $user = '******'; $gateway = false; } else { $user = get_option('ewayCustomerID_id'); $gateway = true; } if ($is_member[0]) { require_once WPSC_GOLD_FILE_PATH . '/ewaylib/GatewayConnector.php'; $objRebill = new RebillPayment(); $objRebill->CustomerRef($purchase_log['id']); $objRebill->CustomerTitle(''); $objRebill->CustomerFirstName($data['first_name']); $objRebill->CustomerLastName($data['last_name']); $objRebill->CustomerCompany(''); $objRebill->CustomerJobDesc(''); $objRebill->CustomerEmail($data['email']); $objRebill->CustomerAddress($data['address1']); $objRebill->CustomerSuburb(''); $objRebill->CustomerState($data['state']); $objRebill->CustomerPostCode($data['zip']); $objRebill->CustomerCountry($data['country']); $objRebill->CustomerPhone1($data['phone']); $objRebill->CustomerPhone2(''); $objRebill->CustomerFax(''); $objRebill->CustomerURL(''); $objRebill->CustomerComments(''); $objRebill->RebillInvRef(''); $objRebill->RebillInvDesc(''); $objRebill->RebillCCname($data['first_name'] . " " . $data['last_name']); $objRebill->RebillCCNumber($_POST['card_number']); $objRebill->RebillInitAmt($purchase_log['totalprice']); $objRebill->RebillInitDate(date('d/m/Y')); $objRebill->RebillRecurAmt($purchase_log['totalprice']); $objRebill->RebillStartDate(date('d/m/Y')); $objRebill->RebillEndDate(date("d/m/Y", mktime(0, 0, 0, date('m'), date('d'), (int) date('Y') + 1))); $objRebill->RebillCCExpMonth($_POST['expiry']['month']); $objRebill->RebillCCExpYear($_POST['expiry']['year']); $objRebill->RebillInterval($member_shiptype['length']); switch ($member_shiptype['unit']) { case 'd': $member_ship_unit = '1'; break; case 'w': $member_ship_unit = '2'; break; case 'm': $member_ship_unit = '3'; break; case 'y': $member_ship_unit = '4'; break; } $objRebill->RebillIntervalType($member_ship_unit); $objRebill->eWAYCustomerID($user); $objConnector = new GatewayConnector($gateway); if ($objConnector->ProcessRequest($objRebill)) { $objResponse = $objConnector->Response(); if ($objResponse != null) { $lblResult = $objResponse->Result(); if ($lblResult == 'Success') { wpsc_member_activate_subscriptions($purchase_log['id']); $_SESSION['nzshpcrt_cart'] = ''; $_SESSION['nzshpcrt_cart'] = array(); header("Location:" . get_option('product_list_url')); } $lblErrorDescription = $objResponse->ErrorDetails(); $lblErrorSeverity = $objResponse->ErrorSeverity(); // This is woefully inadequate!!! exit('An Error has occured >' . $lblResult . " " . $lblErrorDescription . " " . $lblErrorSeverity); } } else { exit("Rebill Gateway failed: " . $objConnector->Response()); } } else { require WPSC_GOLD_FILE_PATH . '/merchants/ewaylib/EwayPaymentLive.php'; //echo WPSC_GOLD_FILE_PATH.'/ewaylib/EwayPaymentLive.php'; if (get_option('eway_cvn')) { $method = 'REAL_TIME_CVN'; } else { $method = 'REAL_TIME'; } $eway = new EwayPaymentLive($user, $method, $gateway); $amount = number_format($purchase_log['totalprice'], 2, '.', '') * 100; $eway->setTransactionData("TotalAmount", $amount); //mandatory field $eway->setTransactionData("CustomerFirstName", $data['first_name']); $eway->setTransactionData("CustomerLastName", $data['last_name']); $eway->setTransactionData("CustomerEmail", $data['email']); $eway->setTransactionData("CustomerAddress", $data['address1'] . ' ' . $data['state']); $eway->setTransactionData("CustomerPostcode", $data['zip']); $eway->setTransactionData("CustomerInvoiceDescription", $itemsName); $eway->setTransactionData("CustomerInvoiceRef", $purchase_log['id']); $eway->setTransactionData("CardHoldersName", $data['first_name'] . ' ' . $data['last_name']); //mandatory field $eway->setTransactionData("CardNumber", $_POST['card_number']); //mandatory field $eway->setTransactionData("CardExpiryMonth", $_POST['expiry']['month']); //mandatory field $eway->setTransactionData("CardExpiryYear", $_POST['expiry']['year']); //mandatory field $eway->setTransactionData("TrxnNumber", $purchase_log['id']); $eway->setTransactionData("Option1", ""); $eway->setTransactionData("Option2", ""); $eway->setTransactionData("Option3", ""); //for REAL_TIME_CVN $eway->setTransactionData("CVN", $_POST['cvn']); //for GEO_IP_ANTI_FRAUD $eway->setTransactionData("CustomerIPAddress", $eway->getVisitorIP()); //mandatory field when using Geo-IP Anti-Fraud $eway->setTransactionData("CustomerBillingCountry", $data['country']); //mandatory field when using Geo-IP Anti-Fraud //special preferences for php Curl $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0); //pass a long that is set to a zero value to stop curl from verifying the peer's certificate //$eway->setCurlPreferences(CURLOPT_CAINFO, "/usr/share/ssl/certs/my.cert.crt"); //Pass a filename of a file holding one or more certificates to verify the peer with. This only makes sense when used in combination with the CURLOPT_SSL_VERIFYPEER option. //$eway->setCurlPreferences(CURLOPT_CAPATH, "/usr/share/ssl/certs/my.cert.path"); //$eway->setCurlPreferences(CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //use CURL proxy, for example godaddy.com hosting requires it //$eway->setCurlPreferences(CURLOPT_PROXY, "http://proxy.shr.secureserver.net:3128"); //use CURL proxy, for example godaddy.com hosting requires it $ewayResponseFields = $eway->doPayment(); //exit(print_r($ewayResponseFields,1)); //print_r($ewayResponseFields); if ($ewayResponseFields["EWAYTRXNSTATUS"] == "False") { $message .= "<h3>Please Check the Payment Results</h3>"; $message .= "Your transaction was not successful." . "<br><br>"; $message .= $ewayResponseFields['EWAYTRXNERROR'] . "<br><br>"; $message .= "<a href=" . get_option('shopping_cart_url') . ">Click here to go back to checkout page.</a>"; $_SESSION['eway_message'] = $message; header("Location:" . get_option('transact_url') . $seperator . "eway=0&result=" . $sessionid . "&message=1"); //exit(); } else { if ($ewayResponseFields["EWAYTRXNSTATUS"] == "True") { $wpdb->query("UPDATE `" . WPSC_TABLE_PURCHASE_LOGS . "` SET `processed`='2' WHERE `sessionid`='" . $sessionid . "' LIMIT 1"); transaction_results($sessionid, false); $message .= "Your transaction was successful." . "<br><br>"; $message .= $ewayResponseFields['EWAYTRXNERROR'] . "<br><br>"; $_SESSION['eway_message'] = $message; header("Location:" . get_option('transact_url') . $seperator . "eway=1&result=" . $sessionid . "&message=1"); //exit(); } } } //echo $_SESSION['eway_message']; exit; }
/** * Proxy for doPayment method * * Note: For TESTING: Force certain error code => Use total = 1050 (=$10.50) where cents denote error code (e.g 50), etc. * * @param Integer $total Total in cents e.g 1 dollar = 100 * @param Array $credit_card Credit card details * @param Array $customer Customer details * @param Array $options Additional details * @return Boolean True if payment successful */ public function doPayment($total, $credit_card, $customer = array(), $options = array()) { $payment = new EwayPaymentLive(sfConfig::get('app_eway_customer_id', '87654321'), $this->getPaymentMethod(sfConfig::get('app_eway_payment_method', 'REAL_TIME_CVN')), sfConfig::get('app_eway_use_live', false)); // Check if total in cents if (!is_int($total)) { sfContext::getInstance()->getLogger()->err('{rtShopPaymentEway} Total value has to be an integer (e.g. cents).'); return false; } // Check if mandatory fiels available $mandatory_fields = sfConfig::get('app_eway_cc_mandatory_fields', array("CardHoldersName", "CardNumber", "CardExpiryMonth", "CardExpiryYear")); foreach ($mandatory_fields as $key => $value) { if (!array_key_exists($value, $credit_card)) { sfContext::getInstance()->getLogger()->err('{rtShopPayment} Missing mandatory field for payment: ' . $value); return false; } } try { // Order total $payment->setTransactionData("TotalAmount", $total); //mandatory field // Cr. card details $payment->setTransactionData("CardHoldersName", $credit_card['CardHoldersName']); //mandatory field $payment->setTransactionData("CardNumber", $credit_card['CardNumber']); //mandatory field $payment->setTransactionData("CardExpiryMonth", $credit_card['CardExpiryMonth']); //mandatory field $payment->setTransactionData("CardExpiryYear", $credit_card['CardExpiryYear']); //mandatory field $payment->setTransactionData("CVN", $credit_card['CVN']); // Transaction reference $payment->setTransactionData("TrxnNumber", strtoupper(md5(mt_rand(5, 10) . date(microtime()) . time()))); // Unique transaction reference // Customer details $payment->setTransactionData("CustomerFirstName", isset($customer['CustomerFirstName']) ? $customer['CustomerFirstName'] : ''); $payment->setTransactionData("CustomerLastName", isset($customer['CustomerLastName']) ? $customer['CustomerLastName'] : ''); $payment->setTransactionData("CustomerEmail", isset($customer['CustomerEmail']) ? $customer['CustomerEmail'] : ''); $payment->setTransactionData("CustomerAddress", isset($customer['CustomerAddress']) ? $customer['CustomerAddress'] : ''); $payment->setTransactionData("CustomerPostcode", isset($customer['CustomerPostcode']) ? $customer['CustomerPostcode'] : ''); $payment->setTransactionData("CustomerInvoiceDescription", isset($customer['CustomerInvoiceDescription']) ? $customer['CustomerInvoiceDescription'] : ''); $payment->setTransactionData("CustomerInvoiceRef", isset($customer['CustomerInvoiceRef']) ? $customer['CustomerInvoiceRef'] : ''); // Options $payment->setTransactionData("Option1", isset($options['Option1']) ? $options['Option1'] : ''); $payment->setTransactionData("Option2", isset($options['Option2']) ? $options['Option2'] : ''); $payment->setTransactionData("Option3", isset($options['Option3']) ? $options['Option3'] : ''); // Special preferences for php Curl $payment->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0); $response = $payment->doPayment(); $this->setLog($response); // Extract response code from error response string (i.e 00,Transaction Approved(Test CVN Gateway)) if (isset($response['EWAYTRXNERROR'])) { $error_response = explode(',', $response['EWAYTRXNERROR']); if (count($error_response) == 2 && strlen($error_response[0]) == 2) { $this->_response_code = $error_response[0]; $this->_response_message = $error_response[1]; } else { $this->_response_message = $response['EWAYTRXNERROR']; } } // API errors if ($this->isApiError($this->getResponseCode())) { sfContext::getInstance()->getLogger()->err('{rtShopPaymentEway} $this->isApiError() flagged an error : ' . serialize($response)); return false; } // Check status. Set isApproved to true if status is true if ($response['EWAYTRXNSTATUS'] === 'True') { $this->_is_approved = true; $this->_transaction_number = $response['EWAYTRXNNUMBER']; $this->_transaction_reference = $response['EWAYTRXNREFERENCE']; } else { $this->setLog($response); return false; } return true; } catch (Exception $e) { sfContext::getInstance()->getLogger()->err('{rtShopPaymentEway} Fatal exception caught while trying to process rtShopEwayPayment::doPayment() : ' . serialize($response)); return false; } }