Skip to content

Instantly share code, notes, and snippets.

@jeremyikwuje
Created July 26, 2020 11:06
Show Gist options
  • Save jeremyikwuje/b5ed8a5820be5176caf5aeb007265a2d to your computer and use it in GitHub Desktop.
Save jeremyikwuje/b5ed8a5820be5176caf5aeb007265a2d to your computer and use it in GitHub Desktop.
<?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