Created
July 26, 2020 10:25
-
-
Save jeremyikwuje/adf6d4dd73117affa10580f3af23b055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = "https://api.paystack.co/transaction/initialize"; | |
$fields = [ | |
'email' => "customer@email.com", | |
'amount' => "10000", | |
'plan' => "PLN_ijhi17fybuszv8f" | |
]; | |
$fields_string = http_build_query($fields); | |
//open connection | |
$ch = curl_init(); | |
//set the url, number of POST vars, POST data | |
curl_setopt($ch,CURLOPT_URL, $url); | |
curl_setopt($ch,CURLOPT_POST, true); | |
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
"Authorization: Bearer SECRET_KEY", | |
"Cache-Control: no-cache", | |
)); | |
//So that curl_exec returns the contents of the cURL; rather than echoing it | |
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); | |
//execute post | |
$result = curl_exec($ch); | |
echo $result; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment