weddingjuma/omnipay-mpesa

Mpesa driver for omnipay payment processing library

v1.0 2018-11-06 13:36 UTC

This package is auto-updated.

Last update: 2024-04-09 07:49:03 UTC


README

Mpesa driver for the Omnipay PHP payment processing library

Build Status Latest Stable Version Total Downloads

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Mpesa support for Omnipay.

Installation

Omnipay is installed via Composer. To install, simply require league/omnipay and omnipay/mpesa with Composer:

composer require league/omnipay omnipay/mpesa

Basic Usage

The following gateways are provided by this package:

  • Mpesa

For general usage instructions, please see the main Omnipay repository.

Basic purchase example

$gateway = \Omnipay\Omnipay::create('Mpesa');  
$gateway->setApiKey('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM');

$response = $gateway->purchase(
    [
        "amount" => "10.00",
        "currency" => "EUR",
        "description" => "My first Payment",
        "returnUrl" => "https://webshop.example.org/mpesa-return.php"
    ]
)->send();

// Process response
if ($response->isSuccessful()) {

    // Payment was successful
    print_r($response);

} elseif ($response->isRedirect()) {

    // Redirect to offsite payment gateway
    $response->redirect();

} else {

    // Payment failed
    echo $response->getMessage();
}

Support

If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.