Skip to content

Commit

Permalink
Switched back to file_get contents
Browse files Browse the repository at this point in the history
  • Loading branch information
Kendysond committed Jan 11, 2017
1 parent acfe307 commit da2c4b9
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions controllers/front/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,6 @@ class PrestaPaystackConfirmModuleFrontcontroller extends ModuleFrontController{
public $ssl = true;
public $display_column_left = false;

// public function verify_txn($code){
// $test_secretkey = Configuration::get('PAYSTACK_TEST_SECRETKEY');
// $live_secretkey = Configuration::get('PAYSTACK_LIVE_SECRETKEY');
// $mode = Configuration::get('PAYSTACK_MODE');

// if ($mode == 'test') {
// $key = $test_secretkey;
// }else{
// $key = $live_secretkey;
// }
// $key = str_replace(' ', '', $key);

// $contextOptions = array(
// 'http'=>array(
// 'method'=>"GET",
// 'header'=> array("Authorization: Bearer ".$key."\r\n")
// )
// );

// $context = stream_context_create($contextOptions);
// $url = 'https://api.paystack.co/transaction/verify/'.$code;
// $request = Tools::file_get_contents($url, false, $context);
// $result = Tools::jsonDecode($request);
// return $result;
// }
public function verify_txn($code){
$test_secretkey = Configuration::get('PAYSTACK_TEST_SECRETKEY');
$live_secretkey = Configuration::get('PAYSTACK_LIVE_SECRETKEY');
Expand All @@ -41,41 +16,66 @@ public function verify_txn($code){
$key = $live_secretkey;
}
$key = str_replace(' ', '', $key);

$contextOptions = array(
'http'=>array(
'method'=>"GET",
'header'=> array("Authorization: Bearer ".$key."\r\n")
)
);

$context = stream_context_create($contextOptions);
$url = 'https://api.paystack.co/transaction/verify/'.$code;
$request = Tools::file_get_contents($url, false, $context);
$result = Tools::jsonDecode($request);
return $result;
}
// public function verify_txn($code){
// $test_secretkey = Configuration::get('PAYSTACK_TEST_SECRETKEY');
// $live_secretkey = Configuration::get('PAYSTACK_LIVE_SECRETKEY');
// $mode = Configuration::get('PAYSTACK_MODE');

// if ($mode == 'test') {
// $key = $test_secretkey;
// }else{
// $key = $live_secretkey;
// }
// $key = str_replace(' ', '', $key);

$url = 'https://api.paystack.co/transaction/verify/' . urlencode($code);
$data = array();
// $url = 'https://api.paystack.co/transaction/verify/' . urlencode($code);
// $data = array();


//open connection
$ch = curl_init();

//set the url, and the header
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Paystack's servers require TLSv1.2
// Force CURL to use this
if (!defined('CURL_SSLVERSION_TLSV1_2')) {
define('CURL_SSLVERSION_TLSV1_2', 6);
}
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSV1_2);

curl_setopt(
$ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $key]
);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

if ($result) {
$data = Tools::jsonDecode($result);
}
return $data;
}
// //open connection
// $ch = curl_init();

// //set the url, and the header
// curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// // Paystack's servers require TLSv1.2
// // Force CURL to use this
// if (!defined('CURL_SSLVERSION_TLSV1_2')) {
// define('CURL_SSLVERSION_TLSV1_2', 6);
// }
// curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSV1_2);

// curl_setopt(
// $ch, CURLOPT_HTTPHEADER, [
// 'Authorization: Bearer ' . $key]
// );

// //execute post
// $result = curl_exec($ch);

// //close connection
// curl_close($ch);

// if ($result) {
// $data = Tools::jsonDecode($result);
// }
// return $data;
// }
public function initParams(){
$params = [];
$transaction = array();
Expand Down

0 comments on commit da2c4b9

Please sign in to comment.