arifpay/phpsdk

Arifpay PHP SDK

v1.1.1 2022-10-04 14:17 UTC

This package is auto-updated.

Last update: 2024-09-04 18:52:33 UTC


README

Arifpay API 包。

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

文档

请参阅开发者 API 文档

安装

您可以通过composer安装此包

composer require arifpay/arifpay

使用方法

该包需要使用您的账户API密钥进行配置,该密钥可在Arifpay控制台中找到。使用密钥值进行要求。安装包后,您可以使用如下方法。

⚠️ 从V2开始,Arifpay->create() 已弃用,应使用 Arifpay->checkout->create()

use Arifpay\Phpsdk\Arifpay;

...

$arifpay = new Arifpay('your-api-key');

创建结账会话

导入 arifpay 包后,使用Arifpay实例的结账属性来创建或获取 结账会话

require_once 'vendor/autoload.php';


use Arifpay\Phpsdk\Arifpay;


use Arifpay\Phpsdk\Helper\ArifpaySupport;
use Arifpay\Phpsdk\Lib\ArifpayBeneficary;
use Arifpay\Phpsdk\Lib\ArifpayCheckoutItem;
use Arifpay\Phpsdk\Lib\ArifpayCheckoutRequest;
use Arifpay\Phpsdk\Lib\ArifpayOptions;

$arifpay = new Arifpay('your-api-key');

$expired = "2023-01-13T17:09:42.411";
$data = new ArifpayCheckoutRequest(
    cancel_url: 'https://api.arifpay.com',
    error_url: 'https://api.arifpay.com',
    notify_url: 'https://gateway.arifpay.net/test/callback',
    expireDate: $expired,
    nonce: floor(rand() * 10000) . "",
    beneficiaries: [
        ArifpayBeneficary::fromJson([
            "accountNumber" => '01320811436100',
            "bank" => 'AWINETAA',
            "amount" => 10.0,
        ]),
    ],
    paymentMethods: ["CARD"],
    success_url: 'https://gateway.arifpay.net',
    items: [
        ArifpayCheckoutItem::fromJson([
            "name" => 'Bannana',
            "price" => 10.0,
            "quantity" => 1,
        ]),
    ],
);
$session =  $arifpay->checkout->create($data, new ArifpayOptions(sandbox: true));
echo $session->session_id;

通过会话ID获取会话

要跟踪结账会话的进度,可以使用以下示例中的fetch方法

 $arifpay = new Arifpay('API KEY...');
// A sessionId will be returned when creating a session.
 $session = $arifpay->checkout->fetch('checkOutSessionID', new ArifpayOptions(true));

以下对象表示一个会话

{
  public int $id, 
  public ArifpayTransaction $transcation, 
  public float $totalAmount, 
  public bool $test,  
  public string $uuid, 
  public string $created_at, 
  public string $update_at
}

通过会话ID取消会话

如果商户想要取消结账会话,现在可以按照以下方式操作。

 $arifpay = new Arifpay('API KEY...');
// A sessionId will be returned when creating a session.
 $session = $arifpay->checkout->cancel('checkOutSessionID', new ArifpayOptions(true));

返回 ArifpayCheckoutSession 类。

直接支付

在此处了解有关DirectPay的更多信息

Telebirr的DirectPay

     $session = $arifpay->checkout->create($data, new ArifpayOptions(true));

    return $arifpay->directPay->telebirr->pay($session->session_id);

Awash钱包的DirectPay

     $session = $arifpay->checkout->create($data, new ArifpayOptions(true));

    return $arifpay->directPay->awash_wallet->pay($session->session_id);

Awash的DirectPay

     $session = $arifpay->checkout->create($data, new ArifpayOptions(true));

    return $arifpay->directPay->awash->pay($session->session_id);

变更日志

发布日期:v1.1.1 2022年10月3日

  • 初始发布

更多信息

致谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件