萨希尔r2050 / omnipay-payway
适用于Omnipay支付处理库的PayWay REST API网关
1.1
2024-03-19 11:44 UTC
Requires
- php: ^7.2
- ext-curl: *
- omnipay/common: ^3.3
- symfony/http-client: ^5.4
Requires (Dev)
- http-interop/http-factory-guzzle: ^1.2
- omnipay/tests: ^4.1
- phpunit/phpunit: ^9.6
README
WestPac PayWay REST API驱动程序,适用于Omnipay PHP支付处理库
Omnipay 是一个不依赖于框架、多网关的PHP 8.0+支付处理库。本包实现了Omnipay对PayWay REST API的支持。
本模块旨在实现 PayWay REST API(西太平洋银行产品)的可使用子集。API功能丰富,因此初始目标是实现以下功能
- 创建和维护客户
- 创建单次使用的令牌(信用卡、银行账户)
- 使用令牌化的信用卡详情进行支付(有助于PCI合规性)
- 安排定期支付
这些初始功能现在已经实现。
有关详细信息,请参阅 官方PayWay文档。
安装
使用Composer安装模块。
composer require sahilr2050/omnipay-payway
用法
接收支付
进行一次性信用卡支付。
<?php include 'vendor/autoload.php'; use Exception; use Omnipay\Common\CreditCard; use Omnipay\Omnipay; $gateway = Omnipay::create('PaywayRest_DirectDebit'); $gateway->setApiKeyPublic('REPLACE'); $gateway->setApiKeySecret('REPLACE'); $gateway->setMerchantId('REPLACE'); $gateway->setTestMode(true); try { $response = $gateway->createSingleUseCardToken([ 'card' => new CreditCard([ 'firstName' => 'First Name', 'lastName' => 'Last Name', 'number' => '4564710000000004', 'expiryMonth' => '02', 'expiryYear' => '2019', 'cvv' => '847', ]), ])->send(); $singleUseTokenId = $response->getData('singleUseTokenId'); if (empty($singleUseTokenId)) { // handle error } $request = $gateway->purchase([ 'singleUseTokenId' => $singleUseTokenId, 'customerNumber' => 'AB1245', 'principalAmount' => '10.00', 'currency' => 'AUD', 'orderNumber' => 12, ]); $response = $request->send(); if ($response->isSuccessful()) { // update order } } catch (Exception $e) { // handle error } // Example for creating single-use token with Bank Account $response = $gateway->createSingleUseBankToken([ 'bankAccountBsb' => '999999', 'bankAccountNumber' => '999999999', 'bankAccountName' => 'Your Name', ])->send(); $singleUseTokenId = $response->getData('singleUseTokenId');
已知问题
[curl] 60: SSL证书问题:无法获取本地发行者证书。
解决方案
下载CA证书 并将其放置在项目根目录中的某个位置。
例如。项目/certificate/cacert.pem
在网关初始化对象中这样做。
$gateway = Omnipay::create('PaywayRest_DirectDebit'); $gateway->setApiKeyPublic('REPLACE'); $gateway->setApiKeySecret('REPLACE'); $gateway->setMerchantId('REPLACE'); $gateway->setTestMode(true); $gateway->setSSLCertificatePath('path/cacert.pem');
贡献
贡献是 欢迎的,并将被完全 认可。
可以通过 Github 上的pull request进行贡献。
支持
如果您对该包有一般性问题,请随时向我们报告。
如果您认为您已发现一个错误,请使用 GitHub问题跟踪器 报告,或者更好的方法是,分支库并提交一个pull request。