Skip to content

Commit

Permalink
Pass in currency variable when initializing payment
Browse files Browse the repository at this point in the history
  • Loading branch information
steveamaza committed Apr 17, 2018
1 parent d1ff85b commit 44e52b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions paystack/paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function __construct()
$this->author = 'Paystack';
$this->controllers = array('payment', 'validation');
$this->is_eu_compatible = 0;
$this->module_key = '7bd648045911885fe8a9a3c6f550d76e';

$this->currencies = true;
$this->currencies_mode = 'checkbox';
Expand Down Expand Up @@ -202,13 +203,15 @@ public function hookPaymentOptions($params)
$gateway_chosen = 'paystack';
$customer = new Customer((int)($cart->id_customer));
$amount = $cart->getOrderTotal(true, Cart::BOTH);
$currency_order = new Currency($cart->id_currency);
$params = array(
"reference" => 'order_'.$params['cart']->id.'_'.time(),
"amount" => number_format($amount, 2),
"pcolor" => '',
"scolor" => '',
"total_amount"=> $amount*100,
"key" => $key,
"currency" => $currency_order->iso_code,
"email" => $customer->email,
);
$this->context->smarty->assign(
Expand Down Expand Up @@ -316,7 +319,7 @@ public function checkCurrency($cart)
public function checkCurrencyNGN($cart)
{
$currency_order = new Currency($cart->id_currency);
if ($currency_order->iso_code == 'NGN') {
if ($currency_order->iso_code == 'NGN' || $currency_order->iso_code == 'GHS') {
return true;
}
return false;
Expand Down Expand Up @@ -350,7 +353,7 @@ public function renderForm()
)
),
),
array(
array(
'type' => 'text',
'label' => $this->trans('Test Secret key', array(), 'Modules.Paystack.Admin'),
'name' => 'PAYSTACK_TEST_SECRETKEY',
Expand Down
3 changes: 2 additions & 1 deletion paystack/views/templates/front/embedded.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
</form>
<script src="https://js.paystack.co/v1/inline.js"></script>
<script type="text/javascript">
var handler = PaystackPop.setup({
var handler = PaystackPop.setup({
key: '{$key}',
email: '{$email}',
amount: '{$total_amount}',
ref: '{$reference}',
currency: '{$currency}',
callback: function(response){
$( "#paystack_form" ).submit();
},
Expand Down

0 comments on commit 44e52b2

Please sign in to comment.