sitehandy / omnipay-toyyibpay
Omnipay支付处理库的toyyibPay驱动程序
dev-master
2020-03-04 15:13 UTC
Requires
- omnipay/common: ^3
Requires (Dev)
- omnipay/tests: ^3
This package is auto-updated.
Last update: 2024-09-08 12:32:10 UTC
README
Omnipay PHP支付处理库的toyyibPay驱动程序
Omnipay 是一个PHP的、无框架、多网关支付处理库。本包实现了Omnipay的toyyibPay支持。
安装
Omnipay通过Composer安装。要安装,只需在Composer中添加league/omnipay
和sitehandy/omnipay-toyyibpay
。
composer require league/omnipay sitehandy/omnipay-toyyibpay
基本用法
有关一般使用说明,请参阅Omnipay的主要仓库。
toyyibPay类别与账单
每笔付款都是一个账单
,它属于一个类别
。要开始,您需要在toyyibPay.com开设账户,然后创建一个类别。然后,获取网关设置的类别代码
。
示例
如何创建账单
参考:https://toyyibpay.com/apireference/#cb
账单作为您的客户的发票。以下示例说明如何创建toyyibPay账单并将客户重定向到支付页面。
$gateway = Omnipay::create('ToyyibPay'); // Use sandbox mode for testing $gateway->setTestMode(1); // You need to pass the following parameters to generate bill code $options = [ 'userSecretKey' => 'YOURSECRETKEY', 'categoryCode' => 'CATEGORYCODE', 'billName' => 'Product Name', 'billDescription' => 'Product Description', 'billPriceSetting'=> 0, 'billPayorInfo'=> 1, 'billAmount'=> 1, 'billReturnUrl'=>'https://yourwebsite.com/returnurl', 'billCallbackUrl'=>'https://yourwebsite.com/callbackurl', 'billExternalReferenceNo' => 'ORDER123', 'billTo'=>'Customer Name', 'billEmail'=>'customer@sampleemail.test', 'billPhone'=>'0123456789', 'billSplitPayment'=> 0, 'billSplitPaymentArgs'=>'', 'billPaymentChannel'=> 0, 'billDisplayMerchant'=> 1, 'billContentEmail' => 'Sample email content', 'billChargeToCustomer' => 2 ]; // Send a purchase request to create a bill $response = $gateway->purchase($options)->send(); // Available response method // $response->isSuccessful(); // is the response successful? // $response->isRedirect(); // is the response a redirect? // $response->getTransactionReference(); // a reference generated by the payment gateway // $response->getTransactionId(); // the reference set by the originating website if available. // $response->getMessage(); // a message generated by the payment gateway // Now redirect the customer to the toyyibPay bill payment page if ($response->isRedirect()) { // Do whatever you want here for example saving the data to the database etc // and then redirect the customer to the offsite payment gateway $response->redirect(); } else { // Display error message exit($response->getMessage()); }
如何获取账单交易
参考:https://toyyibpay.com/apireference/#gbt
您可以通过提交账单代码和账单支付状态(可选)来检查账单支付状态。
以下代码示例展示了如何从支付网关服务器检索账单交易。
$gateway = Omnipay::create('ToyyibPay'); // Parameters required $options = [ 'billCode' => 'samplebillcode' ]; // Send a complete purchase request to get the bill transactions $response = $gateway->completePurchase($options)->send(); // Available response method // $response->isSuccessful(); // is the response successful? // $response->isRedirect(); // is the response a redirect? // $response->getTransactionReference(); // a reference generated by the payment gateway // $response->getTransactionId(); // the reference set by the originating website if available. // $response->getMessage(); // a message generated by the payment gateway if ($response->isSuccessful()) { // Do whatever you want here for example saving the data to the database etc echo $responsive->getTransactionReference(); } elseif ($response->isRedirect()) { // If the payment is not successful, redirect the customer to the payment page for completion $response->redirect(); } else { // Display error message exit($response->getMessage()); }
支持
如果您在使用Omnipay时遇到一般问题,建议您在Stack Overflow上发布。请确保添加omnipay标签,以便更容易找到。
如果您想了解发布公告,讨论项目想法或提出更详细的问题,还有一个您可以订阅的邮件列表。
如果您认为您已经发现了一个错误,请使用GitHub问题跟踪器报告它,或者更好的是,分支库并提交一个pull request。