forked from ibrahimlawal/paystack-php-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdonate-conclude.php
25 lines (21 loc) · 1.05 KB
/
donate-conclude.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
/* handles the callback from Paystack,
* remember to set this URL here > https://dashboard.paystack.co/#/settings/developer
*/
require __DIR__ . '/vendor/autoload.php';
require './functions.php';
$paystack = new \Yabacon\Paystack(PAYSTACK_SECRET_KEY);
$code = filter_input(INPUT_GET, 'trxref');
if (file_exists('results/' . $code . '-request.json')) {
// check already has a response, never requery
if (!file_exists('results/' . $code . '-response.json')) {
// verify the transaction
$rez = $paystack->transaction->verify(['reference'=>$code]);
// verify the transaction (would throw an exception if unable to proper API response)
$response = $paystack->transaction->verify(['reference'=>$code]);
$data = $response->data; // more about data on: https://developers.paystack.co/docs/verifying-transactions
// do what you want with data
file_put_contents('results/' . $code . '-response.json', json_encode($response));
echo $data->status; // tell the status to the customer
}
}