Last active
December 17, 2020 13:54
-
-
Save ibrahimlawal/011693d6edf79552b4796ce557dbbfd6 to your computer and use it in GitHub Desktop.
Initializing a Paystack Transaction for 20 naira // And verifying it. // Uses Paystack Class : https://github.com/yabacon/paystack-class
This file contains hidden or 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 | |
// Get this from https://github.com/yabacon/paystack-class | |
require 'Paystack.php'; | |
$paystack = new Paystack('sk_test_xxx'); | |
// the code below throws an exception if there was a problem completing the request, | |
// else returns an object created from the json response | |
$trx = $paystack->transaction->initialize( | |
[ | |
'amount'=>'2000', /* 20 naira */ | |
'reference'=>'0832uhdo8sd0', /* Must be unique per transaction, not required */ | |
'email'=>'[email protected]', | |
'callback_url'=>'http://example.com/verify.php' | |
/* sample verify code in the other file, | |
paystack will redirect to this file after the | |
transaction */ | |
] | |
); | |
// status should be true if there was a successful call | |
if(!$trx->status){ | |
exit($trx->message); | |
} | |
// full sample initialize response is here: https://developers.paystack.co/docs/initialize-a-transaction | |
// Get the user to click link to start payment or simply redirect to the url generated | |
echo $trx->data->authorization_url; |
This file contains hidden or 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 | |
require 'Paystack.php'; | |
$paystack = new Paystack('sk_test_xxx'); | |
$reference = filter_input(INPUT_GET, 'reference'); | |
$trx = $paystack->transaction->verify( | |
[ | |
'reference'=>$reference | |
] | |
); | |
// status should be true if there was a successful call | |
if(!$trx->status){ | |
exit($trx->message); | |
} | |
// full sample verify response is here: https://developers.paystack.co/docs/verifying-transactions | |
echo $trx->data->status; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please how do I get customers display name and customer ID