SmoDav / ipay by SmoDav

iPay Africa PHP package for transaction handling
1,889
7
2
Package Data
Maintainer Username: SmoDav
Maintainer Contact: smodavprivate@gmail.com (SmoDav)
Package Create Date: 2017-06-23
Package Last Update: 2017-06-23
Language: PHP
License: MIT
Last Refreshed: 2024-12-15 03:05:12
Package Statistics
Total Downloads: 1,889
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 7
Total Watchers: 2
Total Forks: 10
Total Open Issues: 1

iPay Africa Web Based Integration API

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

This is a PHP package for iPay Africa Web based integration. The API allows a merchant to initiate C2B transaction and receive payments from the customers.

Installation

Pull in the package through Composer.

composer require smodav/ipay

Usage

To make a request is simple. Just initiate the Cashier and finalize the transaction:

use SmoDav\iPay\Cashier;

require "vendor/autoload.php";

$cashier = new Cashier();

$response = $cashier
    ->usingVendorId('your vendor id', 'your vendor secret')
    ->withCallback('http://yourcallback.com')
    ->withCustomer('0722000000', 'demo@example.com', false)
    ->transact(10, 'your order id', 'your order secret');

The $response variable will hold the html response from iPay. Just render it to the page and the process would be complete.

Payment Channels

By default, you are able to transact with multiple channels. The package default are:

  • MPesa
  • Airtel Money
  • Equity
  • Credit Card
  • Debit Card

In order to use other channels, you can call the usingChannels() method with a channel array. The currently available channels are:

  • Cashier::CHANNEL_MPESA
  • Cashier::CHANNEL_AIRTEL
  • Cashier::CHANNEL_EQUITY
  • Cashier::CHANNEL_MOBILE_BANKING
  • Cashier::CHANNEL_DEBIT_CARD
  • Cashier::CHANNEL_CREDIT_CARD
  • Cashier::CHANNEL_MKOPO_RAHISI
  • Cashier::CHANNEL_SAIDA

For example:

use SmoDav\iPay\Cashier;

require "vendor/autoload.php";

$cashier = new Cashier();

$transactChannels = [
    Cashier::CHANNEL_MPESA,
    Cashier::CHANNEL_AIRTEL,
];

$response = $cashier
    ->usingChannels($transactChannels)
    ->usingVendorId('your vendor id', 'your vendor secret')
    ->withCallback('http://yourcallback.com')
    ->withCustomer('0722000000', 'demo@example.com', false)
    ->transact(10, 'your order id', 'your order secret');

Disclaimer

The iPay API has a bug of displaying channels that have not been enabled and vice versa.

License

The M-Pesa Package is open-sourced software licensed under the MIT license.