@@ -5,31 +5,6 @@ class PrestaPaystackConfirmModuleFrontcontroller extends ModuleFrontController{
55 public $ ssl = true ;
66 public $ display_column_left = false ;
77
8- // public function verify_txn($code){
9- // $test_secretkey = Configuration::get('PAYSTACK_TEST_SECRETKEY');
10- // $live_secretkey = Configuration::get('PAYSTACK_LIVE_SECRETKEY');
11- // $mode = Configuration::get('PAYSTACK_MODE');
12-
13- // if ($mode == 'test') {
14- // $key = $test_secretkey;
15- // }else{
16- // $key = $live_secretkey;
17- // }
18- // $key = str_replace(' ', '', $key);
19-
20- // $contextOptions = array(
21- // 'http'=>array(
22- // 'method'=>"GET",
23- // 'header'=> array("Authorization: Bearer ".$key."\r\n")
24- // )
25- // );
26-
27- // $context = stream_context_create($contextOptions);
28- // $url = 'https://api.paystack.co/transaction/verify/'.$code;
29- // $request = Tools::file_get_contents($url, false, $context);
30- // $result = Tools::jsonDecode($request);
31- // return $result;
32- // }
338 public function verify_txn ($ code ){
349 $ test_secretkey = Configuration::get ('PAYSTACK_TEST_SECRETKEY ' );
3510 $ live_secretkey = Configuration::get ('PAYSTACK_LIVE_SECRETKEY ' );
@@ -41,41 +16,66 @@ public function verify_txn($code){
4116 $ key = $ live_secretkey ;
4217 }
4318 $ key = str_replace (' ' , '' , $ key );
19+
20+ $ contextOptions = array (
21+ 'http ' =>array (
22+ 'method ' =>"GET " ,
23+ 'header ' => array ("Authorization: Bearer " .$ key ."\r\n" )
24+ )
25+ );
26+
27+ $ context = stream_context_create ($ contextOptions );
28+ $ url = 'https://api.paystack.co/transaction/verify/ ' .$ code ;
29+ $ request = Tools::file_get_contents ($ url , false , $ context );
30+ $ result = Tools::jsonDecode ($ request );
31+ return $ result ;
32+ }
33+ // public function verify_txn($code){
34+ // $test_secretkey = Configuration::get('PAYSTACK_TEST_SECRETKEY');
35+ // $live_secretkey = Configuration::get('PAYSTACK_LIVE_SECRETKEY');
36+ // $mode = Configuration::get('PAYSTACK_MODE');
37+
38+ // if ($mode == 'test') {
39+ // $key = $test_secretkey;
40+ // }else{
41+ // $key = $live_secretkey;
42+ // }
43+ // $key = str_replace(' ', '', $key);
4444
45- $ url = 'https://api.paystack.co/transaction/verify/ ' . urlencode ($ code );
46- $ data = array ();
45+ // $url = 'https://api.paystack.co/transaction/verify/' . urlencode($code);
46+ // $data = array();
4747
4848
49- //open connection
50- $ ch = curl_init ();
51-
52- //set the url, and the header
53- curl_setopt ($ ch , CURLOPT_URL , $ url );
54- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
55-
56- // Paystack's servers require TLSv1.2
57- // Force CURL to use this
58- if (!defined ('CURL_SSLVERSION_TLSV1_2 ' )) {
59- define ('CURL_SSLVERSION_TLSV1_2 ' , 6 );
60- }
61- curl_setopt ($ ch , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSV1_2 );
62-
63- curl_setopt (
64- $ ch , CURLOPT_HTTPHEADER , [
65- 'Authorization: Bearer ' . $ key ]
66- );
67-
68- //execute post
69- $ result = curl_exec ($ ch );
70-
71- //close connection
72- curl_close ($ ch );
73-
74- if ($ result ) {
75- $ data = Tools::jsonDecode ($ result );
76- }
77- return $ data ;
78- }
49+ // //open connection
50+ // $ch = curl_init();
51+
52+ // //set the url, and the header
53+ // curl_setopt($ch, CURLOPT_URL, $url);
54+ // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
55+
56+ // // Paystack's servers require TLSv1.2
57+ // // Force CURL to use this
58+ // if (!defined('CURL_SSLVERSION_TLSV1_2')) {
59+ // define('CURL_SSLVERSION_TLSV1_2', 6);
60+ // }
61+ // curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSV1_2);
62+
63+ // curl_setopt(
64+ // $ch, CURLOPT_HTTPHEADER, [
65+ // 'Authorization: Bearer ' . $key]
66+ // );
67+
68+ // //execute post
69+ // $result = curl_exec($ch);
70+
71+ // //close connection
72+ // curl_close($ch);
73+
74+ // if ($result) {
75+ // $data = Tools::jsonDecode($result);
76+ // }
77+ // return $data;
78+ // }
7979 public function initParams (){
8080 $ params = [];
8181 $ transaction = array ();
0 commit comments