Skip to content

Commit

Permalink
5.6.0.2530: Now supports hashing of request for Bambora (formerly 'Be…
Browse files Browse the repository at this point in the history
…anstream') transactions
  • Loading branch information
classaxe committed Nov 15, 2018
1 parent 1065660 commit d3c9f91
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php
/*
Version History:
1.0.6 (2018-06-27)
1) Changes to support cvv number:
Beanstream_Gateway::_build_request_add_card_details() now includes
1.0.7 (2018-11-15)
1) Renamed from Beanstream_Gateway to Bambora_Gateway
2) Now adds hashing capability to requests posted to payment provider
*/

class Beanstream_Gateway extends Base
class Bambora_Gateway extends Base
{
const VERSION = '1.0.6';
const VERSION = '1.0.7';

private $_num;
private $_card_number;
Expand All @@ -24,9 +23,10 @@ public function payment($order)
{
$this->_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 =
"<b>ERROR: Cannot connect to payment gateway</b>.<br />\n"
. "Your credit card has not been billed.<br />\n"
Expand All @@ -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 = '';
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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']));
}
}

Expand Down Expand Up @@ -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':
Expand All @@ -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
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
19 changes: 5 additions & 14 deletions classes/class.gateway_setting.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<?php
define('VERSION_GATEWAY_SETTING','1.0.4');
define('VERSION_GATEWAY_SETTING','1.0.5');
/*
Version History:
1.0.4 (2012-09-05)
1) Gateway_Setting::do_donation() wasn't recognising gateway types of
'Paypal (Live)' and 'Paypal (Test)' - it does now.
1.0.3 (2012-05-08)
1) Added handle_report_copy() method for cloning entries
1.0.2 (2011-10-04)
1) Added Gateway_Setting::get_selector_sql()
1.0.1 (2010-10-04)
1) Changes to setter and getter names for parent-based object properties
1.0.0 (2009-07-02)
Initial release
1.0.5 (2018-11-15)
1) Changed reference to Beanstream to Bambora
*/
class Gateway_Setting extends Record{

Expand All @@ -29,8 +20,8 @@ public function do_donation() {
return 'There is no gateway defined for this system.';
}
switch($gateway_record['type']['name']) {
case "Bean Stream":
return "The Donation button is not currently supported with Beanstream gateways";
case "Bambora":
return "The Donation button is not currently supported with Bambora gateways";
break;
case "Paypal (Live)":
case "Paypal (Test)":
Expand Down
11 changes: 11 additions & 0 deletions classes/class.gateway_setting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
1.0.4 (2012-09-05)
1) Gateway_Setting::do_donation() wasn't recognising gateway types of
'Paypal (Live)' and 'Paypal (Test)' - it does now.
1.0.3 (2012-05-08)
1) Added handle_report_copy() method for cloning entries
1.0.2 (2011-10-04)
1) Added Gateway_Setting::get_selector_sql()
1.0.1 (2010-10-04)
1) Changes to setter and getter names for parent-based object properties
1.0.0 (2009-07-02)
Initial release
21 changes: 10 additions & 11 deletions classes/class.order.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php
/*
Version History:
1.0.72 (2018-06-13)
1) Order::draw_order_summary() now includes Product Grouping Description
1.0.73 (2018-11-15)
1) Changed references to Beanstream to Bambora
*/
class Order extends Record
{
const VERSION = '1.0.72';
const VERSION = '1.0.73';
const FIELDS = 'ID, archive, archiveID, deleted, systemID, personID, BAddress1, BAddress2, BCity, BCountryID, BEmail, BPostal, BSpID, BTelephone, category, cost_grand_total, cost_items_pre_tax, cost_shipping, cost_sub_total, credit_memo_for_orderID, credit_memo_notes_admin, credit_memo_notes_customer, credit_memo_refund_awarded, credit_memo_status, credit_memo_transaction_code, custom_1, custom_2, custom_3, custom_4, custom_5, custom_6, custom_7, custom_8, custom_9, custom_10, deliveryMethod, deliveryStatus, gateway_result, gateway_settingsID, instructions, notes, originating_page, paymentAmount, paymentApproved, paymentMethod, paymentMethodSurcharge, paymentStatus, payment_card_expiry, payment_card_name, payment_card_partial, processed, qb_ident, SAddress1, SAddress2, SCity, SCountryID, SMethod, SPostal, SSpID, tax1_cost, tax1_name, tax1_rate, tax2_cost, tax2_name, tax2_rate, tax3_cost, tax3_name, tax3_rate, tax4_cost, tax4_name, tax4_rate, tax5_cost, tax5_name, tax5_rate, tax6_cost, tax6_name, tax6_rate, tax7_cost, tax7_name, tax7_rate, tax8_cost, tax8_name, tax8_rate, tax9_cost, tax9_name, tax9_rate, tax10_cost, tax10_name, tax10_rate, tax11_cost, tax11_name, tax11_rate, tax12_cost, tax12_name, tax12_rate, tax13_cost, tax13_name, tax13_rate, tax14_cost, tax14_name, tax14_rate, tax15_cost, tax15_name, tax15_rate, tax16_cost, tax16_name, tax16_rate, tax17_cost, tax17_name, tax17_rate, tax18_cost, tax18_name, tax18_rate, tax19_cost, tax19_name, tax19_rate, tax20_cost, tax20_name, tax20_rate, taxes_shipping, history_created_by, history_created_date, history_created_IP, history_modified_by, history_modified_date, history_modified_IP';

public function __construct($ID = "")
Expand Down Expand Up @@ -998,7 +997,7 @@ public static function manage_ecommerce_options()
."<a href='#delivery_status'><b>Delivery Status</b></a> | "
."<a href='#effective_period_units'><b>Effective Period Units</b></a> | "
."<a href='#gateway_types'><b>Gateway Types</b></a><br />\n"
."<a href='#gateway_settings_beanstream'><b>Gateway Settings - Beanstream</b></a> | "
."<a href='#gateway_settings_bambora'><b>Gateway Settings - Bambora</b></a> | "
."<a href='#gateway_settings_chasepaymentech'><b>Gateway Settings - Chase Paymentech</b></a> | "
."<a href='#gateway_settings_paypal'><b>Gateway Settings - Paypal</b></a><br />"
."<a href='#payment_methods'><b>Payment Methods</b></a> | "
Expand All @@ -1020,9 +1019,9 @@ public static function manage_ecommerce_options()
."<h3 style='margin:1em 0 0.15em 0'><a name='gateway_types'></a>"
."Gateway Types <a style='font-size:75%' href='#top'>Top</a></h3>"
.draw_auto_report('gateway_type', 1)
."<h3 style='margin:1em 0 0.15em 0'><a name='gateway_settings_beanstream'></a>"
."Gateway Settings - Beanstream<a style='font-size:75%' href='#top'>Top</a></h3>"
.draw_auto_report('gateway_settings_beanstream', 1)
."<h3 style='margin:1em 0 0.15em 0'><a name='gateway_settings_bambora'></a>"
."Gateway Settings - Bambora (formerly Beanstream)<a style='font-size:75%' href='#top'>Top</a></h3>"
.draw_auto_report('gateway_settings_bambora', 1)
."<h3 style='margin:1em 0 0.15em 0'><a name='gateway_settings_chasepaymentech'></a>"
."Gateway Settings - Chase Paymentech<a style='font-size:75%' href='#top'>Top</a></h3>"
.draw_auto_report('gateway_settings_chasepaymentech', 1)
Expand Down Expand Up @@ -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)":
Expand Down
2 changes: 2 additions & 0 deletions classes/class.order.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
38 changes: 20 additions & 18 deletions codebase.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define("CODEBASE_VERSION", "5.5.6");
define("CODEBASE_VERSION", "5.6.0");
define('ECC_PHP_7_STRICT', 1);
define("DEBUG_FORM", 0);
define("DEBUG_REPORT", 0);
Expand All @@ -19,34 +19,36 @@
//define("DOCTYPE", '<!DOCTYPE html SYSTEM "%HOST%/xhtml1-strict-with-iframe.dtd">');
/*
--------------------------------------------------------------------------------
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
Expand Down

0 comments on commit d3c9f91

Please sign in to comment.