nekofar/omnipay-zarinpal

Omnipay PHP支付处理库的ZarinPal驱动程序


README

Omnipay PHP支付处理库的ZarinPal驱动程序

Packagist Version PHP from Packagist Packagist Downloads Tests Status Coverage Status License Twitter: nekofar

Omnipay 是一个不依赖于框架的、多网关的PHP支付处理库。本包实现了Omnipay的ZarinPal支持。

安装

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

composer require league/omnipay nekofar/omnipay-zarinpal

基本用法

本包提供以下网关

  • ZarinPal

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

示例

购买

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

use Omnipay\Omnipay;

$gateway = Omnipay::create('ZarinPal');
$gateway->setMerchantId('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
$gateway->setReturnUrl('https://www.example.com/return');

// Send purchase request
$response = $gateway->purchase([
    'amount' => 100,
    'description' => 'Some description'
])->send();

// Process response
if ($response->isRedirect()) {
    // 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([
    'amount' => 100,
    'authority' => $_REQUEST['Authority'], 
)->send();

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

测试

composer test

支持

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

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

如果您认为您发现了错误,请使用 GitHub问题跟踪器 报告它,或者更好的是,分支库并提交拉取请求。