aramics/omnipay-paystack

Paystack gateway for Omnipay payment processing library

dev-master 2019-11-17 18:28 UTC

This package is auto-updated.

Last update: 2024-04-18 04:04:46 UTC


README

Paystack driver for the Omnipay PHP payment processing library

Maintainability Test Coverage Style CI

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/

Install

Via Composer

$ composer require aramics/omnipay-paystack

Basic Usage

Get the Paystack redirect URL

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
}

Check transaction status (from the Paystack ipn)

  1. Configure & setup an endpoint to receive the ipn message from Paystack
  2. 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
}
  1. $status will be either paystack verify transaction object . Handle these statuses in your application workflow accordingly.