From d3c9f91a28610bf4e52fbe3a2c99fbefb115e365 Mon Sep 17 00:00:00 2001 From: Martin Francis Date: Thu, 15 Nov 2018 17:10:26 -0500 Subject: [PATCH] 5.6.0.2530: Now supports hashing of request for Bambora (formerly 'Beanstream') transactions --- ..._gateway.php => class.bambora_gateway.php} | 64 ++++++++++++------- ..._gateway.txt => class.bambora_gateway.txt} | 3 + classes/class.gateway_setting.php | 19 ++---- classes/class.gateway_setting.txt | 11 ++++ classes/class.order.php | 21 +++--- classes/class.order.txt | 2 + codebase.php | 38 +++++------ 7 files changed, 91 insertions(+), 67 deletions(-) rename classes/{class.beanstream_gateway.php => class.bambora_gateway.php} (82%) rename classes/{class.beanstream_gateway.txt => class.bambora_gateway.txt} (88%) create mode 100644 classes/class.gateway_setting.txt diff --git a/classes/class.beanstream_gateway.php b/classes/class.bambora_gateway.php similarity index 82% rename from classes/class.beanstream_gateway.php rename to classes/class.bambora_gateway.php index 2b9a7a9..45eb899 100644 --- a/classes/class.beanstream_gateway.php +++ b/classes/class.bambora_gateway.php @@ -1,15 +1,14 @@ _setup($order, false); $this->_build_request(); +// print $this->_URL."?".$this->_request;die; $this->_send_request(); if ($this->_response === false) { - do_log(3, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Cannot connect to Beanstream at ' . $this->_URL); + do_log(3, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Cannot connect to Bambora at ' . $this->_URL); $msg = "ERROR: Cannot connect to payment gateway.
\n" . "Your credit card has not been billed.
\n" @@ -35,26 +35,32 @@ public function payment($order) $this->_Obj_Order->actions_process_product_pay_failure(); return false; } + $this->_Obj_Order->set_field('gateway_result', urldecode($this->_response['messageText']), true, false); $authCode = $this->_response['authCode']; if ($this->_response['trnApproved'] == "1") { switch ($authCode) { case "TEST": $this->_Obj_Order->mark_paid('TEST: ', false); - do_log(1, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Beanstream approved - TEST'); + do_log(1, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Bambora approved - TEST'); return $authCode; break; + default: $this->_Obj_Order->mark_paid('', false); - do_log(1, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Beanstream approved'); + do_log(1, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Bambora approved'); return $authCode; break; } } + $this->_Obj_Order->actions_process_product_pay_failure(); return $authCode; } + + + protected function _build_request() { $this->_request = ''; @@ -67,6 +73,7 @@ protected function _build_request() $this->_build_request_add_taxes(); $this->_build_request_add_method_surcharge(); $this->_build_request_add_totals(); + $this->_build_request_hash_request(); } protected function _build_request_header() @@ -87,9 +94,9 @@ protected function _build_request_add_address_billing() . "&ordAddress1=" . urlencode($this->_order_record['BAddress1']) . "&ordAddress2=" . urlencode($this->_order_record['BAddress2']) . "&ordCity=" . urlencode($this->_order_record['BCity']) - . "&ordProvince=" . urlencode($this->_get_beanstream_state($this->_order_record['BCountryID'], $this->_order_record['BSpID'])) + . "&ordProvince=" . urlencode($this->_get_bambora_state($this->_order_record['BCountryID'], $this->_order_record['BSpID'])) . "&ordPostalCode=" . urlencode($this->_order_record['BPostal']) - . "&ordCountry=" . urlencode($this->_get_beanstream_country($this->_order_record['BCountryID'])); + . "&ordCountry=" . urlencode($this->_get_bambora_country($this->_order_record['BCountryID'])); } protected function _build_request_add_address_shipping() @@ -100,9 +107,9 @@ protected function _build_request_add_address_shipping() . "&shipAddress1=" . urlencode($this->_order_record['SAddress1']) . "&shipAddress2=" . urlencode($this->_order_record['SAddress2']) . "&shipCity=" . urlencode($this->_order_record['SCity']) - . "&shipProvince=" . urlencode($this->_get_beanstream_state($this->_order_record['SCountryID'], $this->_order_record['SSpID'])) + . "&shipProvince=" . urlencode($this->_get_bambora_state($this->_order_record['SCountryID'], $this->_order_record['SSpID'])) . "&shipPostalCode=" . urlencode($this->_order_record['SPostal']) - . "&shipCountry=" . urlencode($this->_get_beanstream_country($this->_order_record['SCountryID'])); + . "&shipCountry=" . urlencode($this->_get_bambora_country($this->_order_record['SCountryID'])); } } @@ -207,12 +214,19 @@ protected function _build_request_add_totals() . (isset($tax[1]) ? "&ordTax2Price=" . $tax[1] : ""); } - protected function _get_beanstream_country($country) + protected function _build_request_hash_request(){ + if (!$this->_gateway_record['settings']['xml:hash']) { + return; + } + $this->_request.= "&hashValue=". sha1($this->_request . $this->_gateway_record['settings']['xml:hash']); + } + + protected function _get_bambora_country($country) { return Country::get_iso3166($country); } - protected function _get_beanstream_state($country, $state) + protected function _get_bambora_state($country, $state) { switch ($country) { case 'CAN': @@ -227,7 +241,7 @@ protected function _get_beanstream_state($country, $state) protected function _send_request() { - do_log(1, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Connect to Beanstream at ' . $this->_URL . ' - sending request.'); + do_log(1, __CLASS__ . '::' . __FUNCTION__ . '()', '(none)', 'Connect to Bambora at ' . $this->_URL . ' - sending request.'); $Obj_CURL = new Curl( $this->_URL, $this->_request @@ -237,14 +251,16 @@ protected function _send_request() protected function _setup($order) { - $this->_Obj_Order = $order; - $this->_gateway_record = $order->_gateway_record; - $this->_order_record = $order->get_record(); - $this->_order_items = $order->get_order_items(); - $this->_URL = $this->_gateway_record['type']['URL']; - $this->_card_number = get_var('TCardNumber'); - $this->_card_cvd = get_var('TCardCvv'); - $this->_num = 1; + $this->_Obj_Order = $order; + $Obj_System = new System(SYS_ID); + $Obj_System->xmlfields_decode($order->_gateway_record['settings']); + $this->_gateway_record = $order->_gateway_record; + $this->_order_record = $order->get_record(); + $this->_order_items = $order->get_order_items(); + $this->_URL = $this->_gateway_record['type']['URL']; + $this->_card_number = get_var('TCardNumber'); + $this->_card_cvd = get_var('TCardCvv'); + $this->_num = 1; $this->_setup_get_customer_name(); } diff --git a/classes/class.beanstream_gateway.txt b/classes/class.bambora_gateway.txt similarity index 88% rename from classes/class.beanstream_gateway.txt rename to classes/class.bambora_gateway.txt index 1699074..fc7240b 100644 --- a/classes/class.beanstream_gateway.txt +++ b/classes/class.bambora_gateway.txt @@ -1,3 +1,6 @@ + 1.0.6 (2018-06-27) + 1) Changes to support cvv number: + Beanstream_Gateway::_build_request_add_card_details() now includes cvv data 1.0.5 (2015-03-23) 1) Method get_version() renamed to getVersion() and made static 1.0.4 (2014-01-06) diff --git a/classes/class.gateway_setting.php b/classes/class.gateway_setting.php index 44f27d2..7f0834e 100644 --- a/classes/class.gateway_setting.php +++ b/classes/class.gateway_setting.php @@ -1,18 +1,9 @@ Delivery Status | " ."Effective Period Units | " ."Gateway Types
\n" - ."Gateway Settings - Beanstream | " + ."Gateway Settings - Bambora | " ."Gateway Settings - Chase Paymentech | " ."Gateway Settings - Paypal
" ."Payment Methods | " @@ -1020,9 +1019,9 @@ public static function manage_ecommerce_options() ."

" ."Gateway Types Top

" .draw_auto_report('gateway_type', 1) - ."

" - ."Gateway Settings - BeanstreamTop

" - .draw_auto_report('gateway_settings_beanstream', 1) + ."

" + ."Gateway Settings - Bambora (formerly Beanstream)Top

" + .draw_auto_report('gateway_settings_bambora', 1) ."

" ."Gateway Settings - Chase PaymentechTop

" .draw_auto_report('gateway_settings_chasepaymentech', 1) @@ -1165,9 +1164,9 @@ public function payment($payment_card_number, $gateway = false, $originating_pag return true; } switch($this->_gateway_record['type']['name']) { - case "Bean Stream": - $Obj_Beanstream_Gateway = new Beanstream_Gateway; - $Obj_Beanstream_Gateway->payment($this); + case "Bambora": + $Obj_Bambora_Gateway = new Bambora_Gateway; + $Obj_Bambora_Gateway->payment($this); break; case "Chase Paymentech (Live)": case "Chase Paymentech (Test)": diff --git a/classes/class.order.txt b/classes/class.order.txt index f65a3b6..eb61b0e 100644 --- a/classes/class.order.txt +++ b/classes/class.order.txt @@ -1,3 +1,5 @@ + 1.0.72 (2018-06-13) + 1) Order::draw_order_summary() now includes Product Grouping Description 1.0.71 (2016-01-19) 1) Made the following methods static: Order::manage() diff --git a/codebase.php b/codebase.php index 967d0d7..87617da 100644 --- a/codebase.php +++ b/codebase.php @@ -1,5 +1,5 @@ '); /* -------------------------------------------------------------------------------- -5.5.6.2529 (2018-09-29) -Summary: - 1) New field for system - google_geocode_key - since this is now required for geocode lookups - 2) Google Maps no longer requires the 'sensor' parameter in calls - removed this to block the warning +5.6.0.2530 (2018-11-15) + 1) Now supports hashing of request for Bambora (formerly 'Beanstream') transactions Final Checksums: - Classes CS:15343fd7 + Classes CS:7b4a82a5 Database CS:422e4761 - Libraries CS:af9366db - Reports CS:d202a396 + Libraries CS:b946b753 + Reports CS:b6232c7 Code Changes: - codebase.php 5.5.6 (2018-09-29) + codebase.php 5.6.0 (2018-11-15) 1) Updated version information - classes/class.system_edit.php 1.0.41 (2018-09-29) - 1) Added support for setting of google_geocode_key now needed for location lookups - classes/map/googlemap.php 1.0.5 (2018-09-29) - 1) Now has key for Geocode lookup, also removed sensor parameter for Javascript Maps + classes/class.gateway_setting.php 1.0.5 (2018-11-15) + 1) Changed reference to Beanstream to Bambora + classes/class.order.php 1.0.73 (2018-11-15) + 1) Changed references to Beanstream to Bambora 2529.sql - 1) Set version information + 1) Update URL for Beanstream gateway + 2) Renamed report gateway_settings_beanstream to gateway_settings_bambora + 3) Set version information +Delete: + class.beanstream_gateway.php 1.0.6 Promote: - codebase.php 5.5.6 + codebase.php 5.6.0 classes/ (2 files changed) - class.system_edit.php 1.0.41 CS:560bfbaa - map/googlemap.php 1.0.5 CS:6a989957 - + class.gateway_setting.php 1.0.5 CS:c02bd6b0 + class.order.php 1.0.73 CS:905d92c9 + class.bambora_gateway.php 1.0.7 Bug: where two postings (e.g. gallery album and article) have same name and date