33 ** ***************************************************************** **\
44 * *
55 * Paystack Payment Gateway *
6- * Version: 1.0.0 *
7- * Build Date: 15 May 2016 *
6+ * Version: 1.0.1 *
7+ * Build Date: 18 May 2017 *
88 * *
99 ************************************************************************
1010 * *
2424 * @return array
2525 */
2626function paystack_config ()
27- {
27+ {
28+ $ isSSL = ((!empty ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] !== 'off ' ) || $ _SERVER ['SERVER_PORT ' ] == 443 );
29+ $ callbackUrl = 'http ' . ($ isSSL ? 's ' : '' ) . ':// ' . $ _SERVER ['HTTP_HOST ' ] .
30+ substr ($ _SERVER ['SERVER_NAME ' ], 0 , strrpos ($ _SERVER ['SERVER_NAME ' ], '/ ' )) .
31+ '/modules/gateways/callback/paystack.php ' ;
32+
2833 return array (
2934 'FriendlyName ' => array (
3035 'Type ' => 'System ' ,
3136 'Value ' => 'Paystack (Debit/Credit Cards) '
3237 ),
38+ 'webhook ' => array (
39+ 'FriendlyName ' => 'Webhook URL ' ,
40+ 'Type ' => 'yesno ' ,
41+ 'Description ' => 'Copy and paste this URL on your Webhook URL settings <code> ' .$ callbackUrl .'</code> ' ,
42+ 'Default ' => "' " .$ callbackUrl ."' " ,
43+ ),
3344 'gatewayLogs ' => array (
3445 'FriendlyName ' => 'Gateway logs ' ,
3546 'Type ' => 'yesno ' ,
@@ -101,6 +112,9 @@ function paystack_link($params)
101112 $ invoiceId = $ params ['invoiceid ' ];
102113 $ amountinkobo = intval (floatval ($ params ['amount ' ])*100 );
103114 $ currency = $ params ['currency ' ];
115+ ///Transaction_reference
116+ $ txnref = $ invoiceId . '_ ' .time ();
117+
104118
105119 if (!(strtoupper ($ currency ) == 'NGN ' )) {
106120 return ("Paystack only accepts NGN payments for now. " );
@@ -114,6 +128,7 @@ function paystack_link($params)
114128 'invoiceid ' =>$ invoiceId ,
115129 'email ' =>$ email ,
116130 'phone ' =>$ phone ,
131+ 'reference ' => $ txnref ,
117132 'amountinkobo ' =>$ amountinkobo ,
118133 'go ' =>'standard '
119134 ));
@@ -156,6 +171,7 @@ function paystack_link($params)
156171 email: \'' .addslashes (trim ($ email )).'\',
157172 phone: \'' .addslashes (trim ($ phone )).'\',
158173 amount: ' .$ amountinkobo .',
174+ ref: \'' .$ txnref .'\',
159175 callback: function(response){
160176 window.location.href = \'' .addslashes ($ callbackUrl ).'&trxref= \' + response.trxref;
161177 },
0 commit comments