Created
July 26, 2020 11:06
-
-
Save jeremyikwuje/b5ed8a5820be5176caf5aeb007265a2d 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 = [ | |
'customer' => "CUS_xxxxxxxxxx", | |
'plan' => "PLN_xxxxxxxxxx" | |
]; | |
$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