Paystack driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Paystack support for Omnipay. https://paystack.com/ refer to the API docs here: http://developer.paystack.com/
Via Composer
$ composer require aramics/omnipay-paystack
use Omnipay\Omnipay;
$pay = Omnipay::create('Paystack')
->setSecretKey('YOUR_SECRET_KEY');
->purchase([
'amount' => 2000,
'transactionId' => 'transId',
'currency' => 'NGN',
'cancelUrl' => 'https://canclecallback',
'returnUrl' => 'https://yourcallback',
]);
if ($pay->isRedirect()) {
$pay->redirect(); //redirect to pay on paystack
}
- Configure & setup an endpoint to receive the ipn message from Paystack
- Listen for the message and use
getTransactionStatus
(please handle the http GET vars accordingly)
use Omnipay\Omnipay;
$status = Omnipay::create('Paystack')
->setSecretKey('YOUR_SECRET_KEY');
->completePurchase([
'transactionId' => 'transId',
])
->send();
if ($status->isSuccessful()) {
//give value to user
}
$status
will be either paystack verify transaction object . Handle these statuses in your application workflow accordingly.