osinakayah/kurepay-gateway

Helps you make your Kurepay API calls

dev-master 2019-03-08 06:26 UTC

This package is not auto-updated.

Last update: 2024-06-23 07:46:33 UTC


README

Kurepay Payment Gateway

Requirement

PHP 5.3.0 or more recent

Install

composer require osinakayah/kurepay-gateway

Usage

After making a call to getTransactionUrl it returns a url, do a redirect to that url after successful payment the user is redirected back to the url provided on the admin dashboard

Demo

<?php
/**
 * User: osinakayah
 * Date: 08/03/2019
 * Time: 7:02 AM
 */

$kurepay = new \Kurepay\KurepayGateway(PUBLIC_KEY);
$redirectUrl = '';
try {
    $redirectUrl = $kurepay->getTransactionUrl($email, $amount, $reference, $fullname, $phoneNumber, ['item' => "Extra meta data"]);
}
catch (\Exception $exception){
    die($e->getMessage());
}
//Takes the user to payment page.
header('Location: ' . $redirectUrl);

Verify Transaction

<?php
/**
 * User: osinakayah
 * Date: 08/03/2019
 * Time: 7:02 AM
 */

$kurepay = new \Kurepay\KurepayGateway(PUBLIC_KEY);
$wasPaymentSuccessful = false;
try {
     $wasPaymentSuccessful = $kurepay->getTransactionStatus($reference);
}
catch (\Exception $exception){
    die($e->getMessage());
}

if ($wasPaymentSuccessful) {
    echo 'Payment was successful';
}
else {
    echo 'Nah, it was not successful';
}