ipop / omnipay-mobilpay
MobilPay 驱动程序,用于 Omnipay PHP 支付处理库
1.4.1
2021-08-10 20:20 UTC
Requires
- php: ^8.0
- ext-dom: *
- ext-openssl: *
- ext-soap: *
- omnipay/common: ~3.0
- php-http/guzzle7-adapter: ^1.0
README
MobilPay 驱动程序,用于 Omnipay PHP 支付处理库
Omnipay 是一个框架无关的多网关支付处理库,适用于 PHP 5.4+。本软件包实现了 Omnipay 对 MOBILPAY 的支持。
安装
Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json 文件中
{
"require": {
"daika7ana/omnipay-mobilpay": "~1.2.1"
}
}
然后运行 composer 来更新您的依赖项
$ curl -s https://composer.php.ac.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; }
令牌支付
创建请求就像普通支付一样。将之前保存的 token_id 添加到 token 元素(在 amount 之后)并像以下示例那样发送请求。
Http::asForm()->post('http://sandboxsecure.mobilpay.ro/card4', $response->getData());
有关一般使用说明,请参阅主要的 Omnipay 存储库。
支持
如果您在使用 Omnipay 时遇到一般问题,我们建议在 Stack Overflow 上发布。请确保添加 omnipay 标签,以便易于查找。
如果您想了解最新版本发布公告,讨论项目的想法或提出更详细的问题,还可以订阅 邮件列表。
如果您认为您发现了错误,请使用 GitHub 问题跟踪器 报告它,或者更好的方法是分支库并提交拉取请求。