smoday/ipay

iPay Africa PHP 交易处理包

v1.1.0 2017-06-23 09:59 UTC

This package is auto-updated.

Last update: 2024-09-24 18:27:11 UTC


README

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

这是一个用于iPay Africa基于Web集成的PHP包。API允许商家启动C2B交易并从客户那里接收付款。

安装

通过Composer拉取此包。

composer require smodav/ipay

使用

要发起请求很简单。只需启动Cashier并完成交易

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');

$response变量将包含iPay的html响应。只需将其渲染到页面上,过程就完成了。

支付渠道

默认情况下,您可以通过多个渠道进行交易。包默认的渠道包括

  • MPesa
  • Airtel Money
  • Equity
  • 信用卡
  • 借记卡

要使用其他渠道,您可以调用带有渠道数组的usingChannels()方法。目前可用的渠道有

  • 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

例如

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');

免责声明

iPay API 存在一个显示未启用的渠道的bug,反之亦然。

许可

M-Pesa包是开源软件,使用MIT许可