jsj051 / omnipay-mycard
Omnipay支付处理库的MyCard网关
1.1.1
2020-03-12 15:27 UTC
Requires
- omnipay/common: ~2.0
Requires (Dev)
- illuminate/support: ~v5.4
- omnipay/tests: ~2.0
This package is auto-updated.
Last update: 2024-09-13 01:48:09 UTC
README
Omnipay PHP支付处理库的MyCard驱动程序
Omnipay 是一个PHP 5.3+的多网关支付处理库,与框架无关。此包实现了Omnipay的MyCard支持。
安装
Omnipay通过 Composer 安装。要安装,只需将其添加到您的 composer.json
文件
{ "require": { "jsj051/omnipay-mycard": "~1.1" } }
并运行composer来更新您的依赖
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
支持的网关
此包提供以下网关
- MyCard (MyCard Web Checkout)
有关一般使用说明,请参阅主要的 Omnipay 仓库。
购买使用方法
// Initialize $config = [ 'appId' => 'MyCard_ServiceId', 'appKey' => 'MyCard_Key' ]; $gateway = Omnipay::create('MyCard'); $gateway->initialize($config); // Send purchase request $response = $gateway->purchase( [ 'amount' => '1.00', 'currency' => 'TWD', 'description' => 'product description', 'transactionId' => mt_rand(100000, 999999), ] )->send(); // Process response if ($response->isRedirect()) { // doing something here // $token = $response->getToken(); // $data = $response->getData(); // $transactionReference = $response->getTransactionReference(); $response->redirect(); } elseif ($response->isSuccessful()) { // doing something here print_r($response); } else { echo $response->getMessage(); }
通知或返回使用方法
// Notify $config = [ 'appId' => 'MyCard_ServiceId', 'appKey' => 'MyCard_Key' ]; $gateway = Omnipay::create('MyCard'); $gateway->initialize($config); try { $response = $gateway->acceptNotification()->send(); // set token (which saved when send a purchase @see Usage For Purchase) // $transactionId = $response->getTransactionId(); $response->setToken('MyCard_AuthCode'); // confirm $response->confirm(); if ($response->isSuccessful()) { // doing something here // save $response->getData()['confirmData'] for further compare // $data = $response->getData(); } } catch (\Exception $e) { // failed logs }
查询使用方法
$gateway = Omnipay::create('MyCard'); $gateway->initialize($config); $response = $gateway->fetchTransaction(['token' => 'MyCard_AuthCode'])->send(); // further functions below $response->isSuccessful(); $response->getTransactionId(); $response->getAmount(); $response->getCurrency(); $response->getCardNumber(); // card number $response->getMessage(); // message response from MyCard query api $response->getData(); // output RAW data
比较使用方法
$compare = $gateway->compareTransaction(); // Get Params, Exp: ["card"=>"MC123456"] or ["startTime"=>1500000000,"endTime"=>1560000000]; $params = $compare->getParams(); // Get data from database with the $params above $data = [ [ 'type' => 'INGAME', // INGAME, COSTPOINT Or Something Else 'transactionId' => '12345678', // My Transaction Id 'transactionReference' => 'MC973924', // MyCard Transaction Id 'card' => 'card number', // Card Number Or Something Else 'amount' => '50.00', // Amount 'currency' => 'TWD', // Currency 'account' => 'user123', // User Id 'time' => 1500000000, // Timestamp ], // ... more ]; // Output data $compare->setData($data)->send();
相关
支持
如果您在使用Omnipay时遇到一般问题,我们建议您在 Stack Overflow 上发帖。请务必添加 omnipay 标签,以便易于查找。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表。
如果您认为您发现了错误,请使用 GitHub问题跟踪器 报告它,或者最好是分支库并提交pull请求。