Skip to content

Commit 1f5266b

Browse files
committed
V1.0.4 Fallback for servers that can't use lazy inline
1 parent da2c4b9 commit 1f5266b

File tree

6 files changed

+65
-16
lines changed

6 files changed

+65
-16
lines changed

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<module>
33
<name>prestapaystack</name>
44
<displayName><![CDATA[Paystack]]></displayName>
5-
<version><![CDATA[1.0.3]]></version>
5+
<version><![CDATA[1.0.4]]></version>
66
<description><![CDATA[Paystack for prestashop, Accept online card payments in Naira.]]></description>
77
<author><![CDATA[Douglas Kendyson]]></author>
88
<tab><![CDATA[payments_gateways]]></tab>

controllers/front/payment.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function initContent()
2525
$test_publickey = Configuration::get('PAYSTACK_TEST_PUBLICKEY');
2626
$live_publickey = Configuration::get('PAYSTACK_LIVE_PUBLICKEY');
2727
$mode = Configuration::get('PAYSTACK_MODE');
28+
$style = Configuration::get('PAYSTACK_STYLE');
2829
if ($mode == 'test') {
2930
$key = $test_publickey;
3031
}else{
@@ -33,6 +34,7 @@ public function initContent()
3334
$key = str_replace(' ', '', $key);
3435

3536
$this->context->smarty->assign('key', $key);
37+
$this->context->smarty->assign('style', $style);
3638
$cart = $this->context->cart;
3739
$cart_id = $cart->id;
3840

controllers/hook/getContent.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,31 @@ public function __construct($module, $file, $path)
1111
public function assignConfiguration(){
1212
$test_secretkey = Configuration::get('PAYSTACK_TEST_SECRETKEY');
1313
$test_publickey = Configuration::get('PAYSTACK_TEST_PUBLICKEY');
14-
$live_secretkey = Configuration::get('PAYSTACK_LIVE_SECRETKEY');
14+
$live_secretkey = Configuration::get('PAYSTACK_LIVE_SECRETKEY');
1515
$live_publickey = Configuration::get('PAYSTACK_LIVE_PUBLICKEY');
1616
$mode = Configuration::get('PAYSTACK_MODE');
17+
$style = Configuration::get('PAYSTACK_STYLE');
1718
$this->context->smarty->assign('test_secretkey', $test_secretkey);
1819
$this->context->smarty->assign('test_publickey', $test_publickey);
1920
$this->context->smarty->assign('live_secretkey', $live_secretkey);
2021
$this->context->smarty->assign('live_publickey', $live_publickey);
2122
$this->context->smarty->assign('mode', $mode);
23+
$this->context->smarty->assign('style', $style);
2224
}
2325
public function processConfiguration(){
2426
if (Tools::isSubmit('save_settings')){
2527
$test_publickey = Tools::getValue('test_publickey');
2628
$test_secretkey = Tools::getValue('test_secretkey');
2729
$public_publickey = Tools::getValue('live_publickey');
2830
$public_secretkey = Tools::getValue('live_secretkey');
31+
$style = Tools::getValue('style');
2932
$mode = Tools::getValue('mode');
3033
Configuration::updateValue('PAYSTACK_MODE', $mode);
3134
Configuration::updateValue('PAYSTACK_TEST_PUBLICKEY', $test_publickey);
3235
Configuration::updateValue('PAYSTACK_TEST_SECRETKEY', $test_secretkey);
3336
Configuration::updateValue('PAYSTACK_LIVE_PUBLICKEY', $public_publickey);
3437
Configuration::updateValue('PAYSTACK_LIVE_SECRETKEY', $public_secretkey);
38+
Configuration::updateValue('PAYSTACK_STYLE', $style);
3539
$this->context->smarty->assign('confirmation', 'ok');
3640
}
3741
}

prestapaystack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PrestaPaystack extends PaymentModule{
1515
public function __construct(){
1616
$this->name = 'prestapaystack';
1717
$this->tab = 'payments_gateways';
18-
$this->version = '1.0.3';
18+
$this->version = '1.0.4';
1919
$this->bootstrap = true;
2020
$this->author = 'Douglas Kendyson';
2121
$this->description = 'Paystack for prestashop, Accept online card payments in Naira.';

views/templates/front/payment.tpl

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{l s='Your shopping cart is empty.' mod='prestapaystack'}
1616
</p>
1717
{else}
18-
<form action="{$link->getModuleLink('prestapaystack', 'confirm', [], true)|escape:'html'}" method="post">
18+
<form action="{$link->getModuleLink('prestapaystack', 'confirm', [], true)|escape:'html'}" id="paystack_form" method="post">
1919
<div class="box cheque-box">
2020
<h3 class="page-subheading">
2121
{l s='PAYSTACK Payment' mod='prestapaystack'}
@@ -24,6 +24,7 @@
2424
<strong class="dark">
2525
{l s='You have chosen to pay with Paystack.' mod='prestapaystack'} {l s='Here is a short summary of your order:' mod='prestapaystack'}
2626
</strong>
27+
2728
</p>
2829
<p>
2930
- {l s='The total amount of your order is' mod='prestapaystack'}
@@ -72,14 +73,22 @@
7273
<i class="icon-chevron-left"></i>{l s='Other payment methods' mod='prestapaystack'}
7374
</a>
7475
</p>
75-
<script
76-
src="https://js.paystack.co/v1/inline.js"
77-
data-key="{$key}"
78-
data-email="{$email}"
79-
data-amount="{$total_amount*100}"
80-
data-ref="{$code}">
76+
{if $style == 'inline'}
77+
<script src="https://js.paystack.co/v1/inline.js"></script>
78+
79+
<input class="btn btn-default pull-right" type="button" name="save_settings" id="paystack_button" value="Pay Now" />
80+
81+
{else}
82+
<script
83+
src="https://js.paystack.co/v1/inline.js"
84+
data-key="{$key}"
85+
data-email="{$email}"
86+
data-amount="{$total_amount*100}"
87+
data-ref="{$code}">
8188
</script>
82-
<!-- <input class="btn btn-default pull-right" type="submit" name="save_settings" value="Save" /> -->
89+
{/if}
90+
91+
8392

8493

8594
</form>
@@ -88,4 +97,28 @@
8897
float:right;
8998
}
9099
</style>
100+
{if $style == 'inline'}
101+
<script>
102+
$('#paystack_button').on('click', function (e) {
103+
// e.preventDefault();
104+
$("#paystack_form").unbind("submit");
105+
var handler = PaystackPop.setup({
106+
key: '{$key}',
107+
email: '{$email}',
108+
amount: '{$total_amount*100}',
109+
ref: '{$code}',
110+
callback: function(response){
111+
$( "#paystack_form" ).submit();
112+
},
113+
onClose: function(){
114+
115+
}
116+
});
117+
handler.openIframe();
118+
119+
});
120+
</script>
121+
122+
{/if}
123+
91124
{/if}

views/templates/hook/getContent.tpl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
<input type="radio" id="enable_comments_0" name="mode" value="test" {if $mode eq 'test'}checked{/if} />
2929
<label class="t" for="enable_comments_0">Test</label>
3030
</div>
31+
</div>
32+
<div class="form-group clearfix">
33+
<label class="col-lg-3">Test Secret Key:</label>
34+
<div class="col-lg-9">
35+
<input type="text" name="test_secretkey" value="{$test_secretkey}" />
36+
37+
</div>
3138
</div>
3239
<div class="form-group clearfix">
3340
<label class="col-lg-3">Test Public Key:</label>
@@ -37,9 +44,9 @@
3744
</div>
3845
</div>
3946
<div class="form-group clearfix">
40-
<label class="col-lg-3">Test Secret Key:</label>
47+
<label class="col-lg-3">Live Secret Key:</label>
4148
<div class="col-lg-9">
42-
<input type="text" name="test_secretkey" value="{$test_secretkey}" />
49+
<input type="text" name="live_secretkey" value="{$live_secretkey}" />
4350

4451
</div>
4552
</div>
@@ -50,11 +57,14 @@
5057

5158
</div>
5259
</div>
60+
5361
<div class="form-group clearfix">
54-
<label class="col-lg-3">Live Secret Key:</label>
62+
<label class="col-lg-3">Payment style:</label>
5563
<div class="col-lg-9">
56-
<input type="text" name="live_secretkey" value="{$live_secretkey}" />
57-
64+
<input type="radio" id="enable_comments_1" name="style" value="inline" {if $style eq 'inline'}checked{/if} />
65+
<label class="t" for="enable_comments_1">Inline</label>
66+
<input type="radio" id="enable_comments_0" name="style" value="lazy" {if $style eq 'lazy'}checked{/if} />
67+
<label class="t" for="enable_comments_0">Lazy Inline</label>
5868
</div>
5969
</div>
6070

0 commit comments

Comments
 (0)