@@ -117,10 +117,7 @@ function paystack_link($params)
117117 $ txnref = $ invoiceId . '_ ' .time ();
118118
119119
120- if (! (strtoupper ($ currency ) == 'NGN ' )
121- || (strtoupper ($ currency ) == 'USD ' )
122- || (strtoupper ($ currency ) == 'GHS ' )
123- ) {
120+ if (!in_array (strtoupper ($ currency ), [ 'NGN ' , 'USD ' , 'GHS ' ])) {
124121 return ("<b style='color:red;margin:2px;padding:2px;border:1px dotted;display: block;border-radius: 10px;font-size: 13px;'>Sorry, this version of the Paystack WHMCS plugin only accepts NGN, USD and GHS payments. <i> $ currency</i> not yet supported.</b> " );
125122 }
126123
@@ -162,10 +159,15 @@ function paystack_link($params)
162159 if (paymentMethod === \'paystack \') {
163160 $( \'.payment-btn-container2 \').hide();
164161 var toAppend = \'<button type="button" ' .
165- ' onclick="payWithPaystack()"> ' .addslashes ($ params ['langpaynow ' ]).'</button> \';
162+ ' onclick="payWithPaystack()" ' .
163+ ' style="padding: 10px 25px; margin: 10px;border-radius: 5px;background: #021C32; color:#fff"> ' .
164+ addslashes ($ params ['langpaynow ' ]).'</button> ' .
165+ '<img style="width: 150px; display: block; margin: 0 auto;" ' .
166+ ' src="https://paystack.com/assets/website/images/brand/badges/cards.png"/> \';
167+
166168 $( \'.payment-btn-container \').append(toAppend);
167- if($( \'.payment-btn-container \').length===0){
168- $( \'select[name="gateway"] \').after(toAppend);
169+ if($( \'.payment-btn-container \').length===0){
170+ $( \'select[name="gateway"] \').after(toAppend);
169171 }
170172 }
171173 });
@@ -174,34 +176,45 @@ function paystack_link($params)
174176 <div class="hidden" style="display:none"><iframe name="hiddenIFrame"></iframe></div>
175177 <script>
176178 var paystackIframeOpened = false;
179+ var button_created = false;
177180 var paystackHandler = PaystackPop.setup({
178- key: \'' .addslashes (trim ($ publicKey )).'\',
179- email: \'' .addslashes (trim ($ email )).'\',
180- phone: \'' .addslashes (trim ($ phone )).'\',
181- amount: ' .$ amountinkobo * 100 .',
182- currency: \'' .addslashes (trim ($ currency )).'\',
183- ref: \'' .$ txnref .'\',
184- callback: function(response){
185- window.location.href = \'' .addslashes ($ callbackUrl ).'&trxref= \' + response.trxref;
186- },
187- onClose: function(){
188- paystackIframeOpened = false;
189- }
181+ key: \'' .addslashes (trim ($ publicKey )).'\',
182+ email: \'' .addslashes (trim ($ email )).'\',
183+ phone: \'' .addslashes (trim ($ phone )).'\',
184+ amount: ' .$ amountinkobo .',
185+ currency: \'' .addslashes (trim ($ currency )).'\',
186+ ref: \'' .$ txnref .'\',
187+ callback: function(response){
188+ window.location.href = \'' .addslashes ($ callbackUrl ).'&trxref= \' + response.trxref;
189+ },
190+ onClose: function(){
191+ paystackIframeOpened = false;
192+ }
190193 });
191194 function payWithPaystack(){
192195 if (paystackHandler.fallback || paystackIframeOpened) {
193- // Handle non-support of iframes or
194- // Being able to click PayWithPaystack even though iframe already open
195- window.location.href = \'' .addslashes ($ fallbackUrl ).'\';
196+ // Handle non-support of iframes or
197+ // Being able to click PayWithPaystack even though iframe already open
198+ window.location.href = \'' .addslashes ($ fallbackUrl ).'\';
196199 } else {
197- paystackHandler.openIframe();
198- paystackIframeOpened = true;
199- $( \'img[alt="Loading"] \').hide();
200- $( \'div.alert.alert-info.text-center \').html( \'Click the button below to retry payment... \');
201- $( \'.payment-btn-container2 \').append( \'<button type="button" ' .
202- ' onclick="payWithPaystack()"> ' .addslashes ($ params ['langpaynow ' ]).'</button> \');
200+ paystackHandler.openIframe();
201+ paystackIframeOpened = true;
202+ $( \'img[alt="Loading"] \').hide();
203+ $( \'div.alert.alert-info.text-center \').html( \'Click the button below to retry payment... \');
204+ create_button();
203205 }
204206 }
207+ function create_button(){
208+ if(!button_created){
209+ button_created = true;
210+ $( \'.payment-btn-container2 \').append( \'<button type="button" ' .
211+ ' onClick="window.location.reload()" ' .
212+ ' style="padding: 10px 25px; margin: 10px;border-radius: 5px;background: #021C32; color:#fff"> ' .
213+ addslashes ($ params ['langpaynow ' ]).'</button> ' .
214+ '<img style="width: 150px; display: block; margin: 0 auto;" ' .
215+ ' src="https://paystack.com/assets/website/images/brand/badges/cards.png"/> \');
216+ }
217+ }
205218 ' . ( $ paynowload ? 'setTimeout("payWithPaystack()", 5100); ' : '' ) . '
206219 </script> ' ;
207220
0 commit comments