Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
close #26 Changed: Securetrading WS amount format
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Sep 6, 2016
1 parent fdc9590 commit 8b0a798
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public function process()

$billing_node = $request_node->addChild('billing');

$amount_node = $billing_node->addChild('amount', str_replace('.', '', $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)));
//$amount_node = $billing_node->addChild('amount', str_replace('.', '', $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)));
$amount_node = $billing_node->addChild('amount', str_replace('.', '', $this->model_extension_payment_securetrading_ws->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'])));
$amount_node->addAttribute('currencycode', $order_info['currency_code']);

$billing_node->addChild('premise', $order_info['payment_address_1']);
Expand Down Expand Up @@ -212,7 +213,8 @@ public function process()
$name_node->addChild('first', $order_info['payment_firstname']);
$name_node->addChild('last', $order_info['payment_lastname']);

$amount_node = $billing_node->addChild('amount', str_replace('.', '', $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)));
//$amount_node = $billing_node->addChild('amount', str_replace('.', '', $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false)));
$amount_node = $billing_node->addChild('amount', str_replace('.', '', $this->model_extension_payment_securetrading_ws->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'])));
$amount_node->addAttribute('currencycode', $order_info['currency_code']);

$payment_node = $billing_node->addChild('payment');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ public function call($data)
return $response;
}

public function format($number, $currency, $value = '', $format = false)
{
$decimal_place = $this->currency->getDecimalPlace($currency);

if (!$value) {
$value = $this->currency->getValue($currency);
}

$amount = $value ? (float)$number * $value : (float)$number;

$amount = number_format($amount, (int)$decimal_place);

if (!$format) {
return $amount;
}
}

public function getOrder($order_id)
{
$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "securetrading_ws_order` WHERE `order_id` = '" . (int) $order_id . "' LIMIT 1");
Expand Down

0 comments on commit 8b0a798

Please sign in to comment.