项目地址 https://github.com/xxtime/omnipay-mycard
MyCard是台湾的一个电子支付服务商,类似于支付宝
但是MyCard的接入很烂,这是我见过所有支付集成平台最烂的接口
为了避免其他人在MyCard碰到各种坑,我就写了omnipay-mycard项目
omnipay-mycard项目是一个支付组件,使用composer就能很容易安装
目前稳定版本是 1.1.0
composer require "xxtime/omnipay-mycard:~1.1"
Omnipay是一个支持多网关支付的组件,也是The PHP League团队的旷世之作
由来自全球社区爱好者的精英们编写各个支付网关的适配器
目前国内的 支付宝 微信支付 银联支付 的适配器都囊括其中
不过支付宝的适配器写的不太规范 但用绝对没问题,我也跟其作者沟通,他希望有更多的人参与改进
好吧还是继续说omnipay-mycard吧
omnipay-mycard
支持 MyCard点卡支付,MyCard会员支付,MyCard电信类支付
支持MyCard对账
上代码吧:
// 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(); }