Skip to content

Commit

Permalink
Change the way number are formatted for transmission, to avoid commas
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte committed Mar 10, 2017
1 parent 5e85b53 commit 31faee6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions includes/modules/payment/firstdata_hco.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* First Data Hosted Checkout Payment Pages Module
*
* @package paymentMethod
* @copyright Copyright 2003-2016 Zen Cart Development Team
* @copyright Copyright 2003-2017 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: Author: DrByte Sat Feb 27 11:58:17 2016 -0500 New in v1.5.5 $
Expand All @@ -21,7 +21,7 @@ class firstdata_hco extends base {
/**
* $moduleVersion is the plugin version number
*/
var $moduleVersion = '1.02';
var $moduleVersion = '1.03';

/**
* $title is the displayed name for this payment method
Expand Down Expand Up @@ -195,7 +195,7 @@ function process_button() {
$submit_data_core = array(
'x_login' => html_entity_decode(MODULE_PAYMENT_FIRSTDATA_PAYMENTPAGES_PAGEID),
'x_user3' => 'EZN001', // First Data mode
'x_amount' => number_format($order->info['total'], 2),
'x_amount' => round($order->info['total'], 2),
'x_currency_code' => $_SESSION['currency'],
'x_type' => MODULE_PAYMENT_FIRSTDATA_PAYMENTPAGES_AUTHORIZATION_TYPE == 'Authorize' ? 'AUTH_ONLY': 'AUTH_CAPTURE',
'x_email_customer' => ((MODULE_PAYMENT_FIRSTDATA_PAYMENTPAGES_EMAIL_CUSTOMER == 'True') ? 'TRUE': 'FALSE'),
Expand Down Expand Up @@ -253,12 +253,12 @@ function process_button() {
if ($order->info['currency'] != $this->gateway_currency) {
global $currencies;
$exchange_factor = $currencies->get_value($this->gateway_currency);
$submit_data_core['x_amount'] = number_format($order->info['total'] * $exchange_factor, 2);
if (isset($submit_data_core['x_freight'])) $submit_data_core['x_freight'] = number_format($submit_data_core['x_freight'] * $exchange_factor, 2);
if (isset($submit_data_core['x_tax'])) $submit_data_core['x_tax'] = number_format($submit_data_core['x_tax'] * $exchange_factor, 2);
if (isset($submit_data_core['discount_amount'])) $submit_data_core['discount_amount'] = number_format($submit_data_core['discount_amount'] * $exchange_factor, 2);
$submit_data_core['x_amount'] = round($order->info['total'] * $exchange_factor, 2);
if (isset($submit_data_core['x_freight'])) $submit_data_core['x_freight'] = round($submit_data_core['x_freight'] * $exchange_factor, 2);
if (isset($submit_data_core['x_tax'])) $submit_data_core['x_tax'] = round($submit_data_core['x_tax'] * $exchange_factor, 2);
if (isset($submit_data_core['discount_amount'])) $submit_data_core['discount_amount'] = round($submit_data_core['discount_amount'] * $exchange_factor, 2);
$submit_data_core['x_currency_code'] = $this->gateway_currency;
$submit_data_core['x_description'] .= ' (Converted from: ' . number_format($order->info['total'] * $order->info['currency_value'], 2) . ' ' . $order->info['currency'] . ')';
$submit_data_core['x_description'] .= ' (Converted from: ' . round($order->info['total'] * $order->info['currency_value'], 2) . ' ' . $order->info['currency'] . ')';
}


Expand All @@ -275,12 +275,12 @@ function process_button() {
for ($i=0; $i<sizeof($order->products); $i++) {
$p = $order->products[$i];
// Item ID<|>Item Title<|>Item Description<|>Quantity<|>Unit Price<|>Taxable (Y or N)<|>Product Code<|>Commodity Code<|>Unit of Measure<|>Tax Rate<|>Tax Type<|>Tax Amount<|>Discount Indicator<|>Discount Amount<|>Line Item Total
$line = $p['model'] . $delim . $p['name'] . $delim . $p['name'] . $delim . $p['qty'] . $delim . number_format($p['final_price'] * $exchange_factor,2) . $delim;
$line = $p['model'] . $delim . $p['name'] . $delim . $p['name'] . $delim . $p['qty'] . $delim . round($p['final_price'] * $exchange_factor,2) . $delim;
$line .= (is_array($p['tax_groups']) && sizeof($p['tax_groups']) ? 'Y' : 'N') . $delim;
$line .= $product_code . $delim . $commodity_code . $delim . '' . $delim;
$line .= $p['tax'] . $delim . '' . number_format(zen_calculate_tax($p['final_price'] * $exchange_factor, $p['tax']),2) . $delim;
$line .= $p['tax'] . $delim . '' . round(zen_calculate_tax($p['final_price'] * $exchange_factor, $p['tax']),2) . $delim;
$line .= '' . $delim . '' . $delim;
$line .= number_format(zen_add_tax($p['final_price'] * $exchange_factor, $p['tax']) * $p['qty'],2);
$line .= round(zen_add_tax($p['final_price'] * $exchange_factor, $p['tax']) * $p['qty'],2);

$items .= zen_draw_hidden_field('x_line_item', $line);
$item_log[] = $line;
Expand Down Expand Up @@ -384,7 +384,7 @@ function after_process() {
$sql = "insert into " . TABLE_ORDERS_STATUS_HISTORY . " (comments, orders_id, orders_status_id, customer_notified, date_added) values (:orderComments, :orderID, :orderStatus, -1, now() )";
$currency_comment = '';
if ($order->info['currency'] != $this->gateway_currency) {
$currency_comment = ' (' . number_format($order->info['total'] * $currencies->get_value($this->gateway_currency), 2) . ' ' . $this->gateway_currency . ')';
$currency_comment = ' (' . round($order->info['total'] * $currencies->get_value($this->gateway_currency), 2) . ' ' . $this->gateway_currency . ')';
}
$sql = $db->bindVars($sql, ':orderComments', 'Credit Card payment. AUTH: ' . $this->auth_code . ' TransID: ' . $this->transaction_id . ' ' . $currency_comment, 'string');
$sql = $db->bindVars($sql, ':orderID', $insert_id, 'integer');
Expand Down

0 comments on commit 31faee6

Please sign in to comment.