adnane-ka / omnipay-tap
Omnipay支付处理库的Tap支付网关
1.2
2024-08-12 20:32 UTC
Requires
- guzzlehttp/psr7: ^2.4
- nyholm/psr7: ^1.8
- omnipay/common: ^3.3
- php-http/curl-client: ^2.1
- php-http/httplug: ^2.3
- php-http/message: ^1.0
- symfony/http-client: ^6.2
README
Omnipay支付处理库的Tap支付网关
Omnipay 是一个与框架无关、支持多个网关的PHP 5.3+支付处理库。本包实现了Omnipay对Tap的支持。
安装
composer require adnane-ka/omnipay-tap
基本用法
本包提供了以下网关
- Tap
本包与 Tap的Charges API 进行交互。
有关通用用法说明,请参阅Omnipay 的主要仓库。
示例用法
配置
use Omnipay\Omnipay; $gateway = Omnipay::create('Tap'); /** * You can use the testing API key provided by Tap. * No worries on switching test & live mode since Tap provides * Keys for both, and can distinguish between them * * @see https://developers.tap.company/reference/api-endpoint * @see https://developers.tap.company/reference/testing-keys */ $gateway->setApiToken('sk_test_XKokBfNWv6FIYuTMg5sLPjhJ');
创建一笔收费
$response = $gateway->purchase([ 'amount' => 1, // Required 'currency' => 'KWD', // Optional, Default is USD 'customerName' => 'Test', // Optional, Default is Test 'customerEmail' => 'test@test.com', // Optional, Default is Test 'sourceId' => 'src_all', // Optional, Default is src_all @see https://developers.tap.company/reference/charges#the-payment-source-object 'threeDSecure' => false, // Optional, Default is true 'returnUrl' => 'http://your_website.com/redirect_url' // Required ]) ->send(); if ($response->isRedirect()) { // Data is valid and you're ready to be redirected offsite $response->redirect(); } else { // An error occured // @see https://developers.tap.company/reference/charge-response-codes echo $response->getMessage(); }
检索一笔收费
$response = $gateway->completePurchase([ // tap_id is usually injected as a URL param when returned from gateway 'tap_id' => 'TYPE_IN_THE_TARGET_CHARGE_ID' ])->send(); if($response->isSuccessful()){ // Payment was successful and charge was captured // $response->getData() // $response->getTransactionReference() // payment reference }else{ // Charge was not captured and payment failed // $response->getData() }
支持
如果您在使用Omnipay时遇到一般问题,我们建议您在 Stack Overflow 上发帖。请确保添加 omnipay 标签,以便容易被找到。
如果您想了解最新版本发布公告,讨论项目的想法或提出更详细的问题,还可以订阅 邮件列表。
如果您认为发现了错误,请使用 GitHub问题跟踪器 报告,或者最好是分支库并提交拉取请求。