deh4eg/omnipay-blueorange

omnipay库的BlueOrange网关

v1.2.0 2022-10-17 11:35 UTC

This package is auto-updated.

Last update: 2024-09-17 15:36:24 UTC


README

Omnipay BlueOrange Gateway 是一个用于PHP的支付处理库。它基于 Omnipay包

Latest Stable Version Total Downloads Latest Unstable Version License

安装

Omnipay 通过 Composer 安装。要安装,只需使用Composer要求 league/omnipaydeh4eg/omnipay-blueorange

composer require league/omnipay deh4eg/omnipay-blueorange

API文档

您可以在 此处 找到BlueOrange网关的API文档

用法

有关一般用法说明,请参阅主要的 Omnipay 仓库。

目前,库实现了2个端点

  1. 创建购买
  2. 通过ID检索对象

代码示例

1. 创建购买

use Omnipay\BlueOrange\Gateway;
use Omnipay\BlueOrange\Message\Response\PurchaseResponse;
use Omnipay\Omnipay;

/** @var Gateway $gateway */
$gateway = Omnipay::create(Gateway::getGatewayClass());

$gateway->setBrandId('123456789');
$gateway->setSecretKey('abcde123456');

$options = [
    'client' => [
        'email' => 'test@test.com'
    ],
    'purchase' => [
        'currency' => 'EUR', // Currency code in the ISO 4217 standard,
        'language' => 'lv', // Language code in the ISO 639-1 format
        'total_override' => 100, // (optional) [type: int] If set, will override total sum from products[],
        'products' => [
            [
                'name' => 'Product name',
                'price' => 100, // [type: int],
                'quantity' => 1
            ]
        ]
    ],
    'reference' => '#1234', // (optional) Max length: 128
    'success_redirect' => 'https://www.example.com/success/',
    'failure_redirect' => 'https://www.example.com/failure/',
    'cancel_redirect' => 'https://www.example.com/cancel/' // (optional)
];

/** @var PurchaseResponse $response */
$response = $gateway->completePurchase($options)->send();

if ($response->isRedirect()) {
    $response->redirect();
}

2. 通过ID检索对象

use Omnipay\BlueOrange\Gateway;
use Omnipay\BlueOrange\Message\Response\FetchTransactionResponse;
use Omnipay\Omnipay;

/** @var Gateway $gateway */
$gateway = Omnipay::create(Gateway::getGatewayClass());

$gateway->setBrandId('123456789');
$gateway->setSecretKey('abcde123456');

$options = [
    'transaction_reference' => 'abc123' // Object ID (UUID) from purchase response
];

/** @var FetchTransactionResponse $response */
$response = $gateway->fetchTransaction($options)->send();

if ($response->isSuccessful()) {
    // Do code
}

变更日志

请参阅 CHANGELOG 了解最近发生了哪些变化。

许可

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