armezit/omnipay-jibit

Jibit 支付处理库的驱动程序

v1.2.0 2022-10-21 12:42 UTC

This package is auto-updated.

Last update: 2024-09-22 01:02:24 UTC


README

Jibit PHP 支付处理库的驱动程序

Packagist Version PHP from Packagist Packagist

Omnipay 是一个与框架无关、多网关的 PHP 支付处理库。本软件包实现了 Omnipay 的 Jibit 支持。

安装

通过 Composer 安装 Omnipay。要安装,只需使用 Composer 需要 league/omnipayarmezit/omnipay-jibit

composer require league/omnipay armezit/omnipay-jibit

基本用法

本软件包提供以下网关:

  • Jibit

有关通用使用说明,请参阅主 Omnipay 存储库。

示例

购买

结果将重定向到网关或银行。

use Omnipay\Omnipay;

$gateway = Omnipay::create('Jibit');
$gateway->setApiKey('API_KEY');
$gateway->setSecretKey('SECRET_KEY');
$gateway->setReturnUrl('https://www.example.com/return');

// Send purchase request
$response = $gateway->purchase([
    'amount' => $amount,
    'currency' => $currency,
    'transactionId' => $transactionId, // referenceNumber in Jibit api doc
    'userId' => $userId, // userIdentifier in Jibit api doc
])->send();

// Process response
if ($response->isSuccessful() && $response->isRedirect()) {
    // store the order identifier to use in completePurchase()
    $orderIdentifier = $response->getTransactionReference();
    // Redirect to offsite payment gateway
    $response->redirect();
} else {
    // Payment failed: display message to customer
    echo $response->getMessage();
}

完成购买(验证)

返回时,通常的 completePurchase 将提供交易尝试的结果。

最终结果包括以下方法来检查详细信息:

// Send purchase complete request
$response = $gateway->completePurchase([
    'transactionReference' => $orderIdentifier, 
])->send();

// Process response
if ($response->isPending()) {
    // In case of pending, you must inquiry the order later
    return;
}

if (!$response->isSuccessful() || $response->isCancelled()) {
    // Payment failed: display message to customer
    echo $response->getMessage();
} else {
    // Payment was successful
    print_r($response);
}

查询订单

通过 orderIdentifier 查询订单

$response = $gateway->fetchTransaction([
    'transactionReference' => $orderIdentifier,
])->send();

if ($response->isPending()) {
    // In case of pending, you must inquiry the order later
    return;
}

if ($response->isCancelled()) {
    // Payment failed: display message to customer
    echo $response->getMessage();
} else if ($response->isSuccessful()) {
    // Payment was successful
    print_r($response);
}

测试

composer test

支持

如果您在使用 Omnipay 时遇到一般问题,我们建议在 Stack Overflow 上发表帖子。请务必添加 omnipay 标签,以便轻松找到。

如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表

如果您认为您已发现一个错误,请使用 GitHub 问题跟踪器 报告,或者更好的是,分支库并提交一个 pull request。