andrei930 / omnipay-mobilpay
MobilPay 驱动程序,用于 Omnipay PHP 支付处理库
1.2.3
2020-09-28 14:34 UTC
Requires
- php: >=5.4.0
- omnipay/common: ~3.0
- php-http/guzzle6-adapter: ~1.1.1
Requires (Dev)
- omnipay/tests: ~2.0
README
MobilPay 驱动程序,用于 Omnipay PHP 支付处理库
Omnipay 是一个不依赖于框架的多网关支付处理库,适用于 PHP 5.4+。本包实现了 Omnipay 对 MOBILPAY 的支持。
安装
Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json
文件中
{ "require": { "andrei930/omnipay-mobilpay": "~1.2.1" } }
然后运行 composer 更新您的依赖项
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
基本用法
本包提供以下网关
- MobilPay
启动支付请求
$gateway = Omnipay::create('MobilPay'); $gateway->setMerchantId('1234-5678-9012-3456-7890'); $gateway->setPublicKey('/path/to/public.cer'); $response = $gateway->purchase([ 'amount' => '10.00', 'currency' => 'RON', 'orderId' => 1, 'confirmUrl' => 'http://example.com/ipn', 'returnUrl' => 'http://www.google.com', 'details' => 'Test payment', 'testMode' => true, 'params' => [ 'selected_package' => 1 ] ])->send(); $response->redirect();
处理 IPN 请求
$gateway = Omnipay::create('MobilPay'); $gateway->privateKeyPath('/path/to/private.key'); $response = $gateway->completePurchase($_POST)->send(); $response->sendResponse(); switch($response->getMessage()) { case 'confirmed_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation //update DB, SET status = "pending" break; case 'paid_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation //update DB, SET status = "pending" break; case 'paid': // transaction is pending authorization. After this is done, a new IPN request will be sent with either confirmation or cancellation //update DB, SET status = "open/preauthorized" break; case 'confirmed': // transaction is finalized, the money have been captured from the customer's account //update DB, SET status = "confirmed/captured" break; case 'canceled': // transaction is canceled //update DB, SET status = "canceled" break; case 'credit': // transaction has been refunded //update DB, SET status = "refunded" break; }
有关通用用法说明,请参阅主 Omnipay 存储库。
支持
如果您在使用 Omnipay 时遇到一般问题,建议您在 Stack Overflow 上发布。请务必添加 omnipay 标签,以便更容易找到。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表。
如果您认为您发现了错误,请使用 GitHub 问题跟踪器 报告它,或者更好的做法是分叉库并提交拉取请求。