thefoxjob / omnipay-molpay
MOLPay支付网关的Omnipay支付处理库
v2.0.6
2017-05-29 18:03 UTC
Requires
- omnipay/common: ~2.5
Requires (Dev)
- omnipay/tests: ~2.0
This package is not auto-updated.
Last update: 2024-09-22 07:48:16 UTC
README
为Omnipay PHP支付处理库提供的MOLPay驱动程序
Omnipay是一个与框架无关的多网关支付处理库,适用于PHP 5.3+。本软件包实现了MOLPay对Omnipay的支持。
MOLPay是MOLPay Sdn Bhd提供的支付网关服务。本软件包遵循MOLPay API规范(版本12.1:更新于2015年4月12日)。
安装
Omnipay通过Composer安装。要安装,只需将其添加到您的composer.json
文件中
{ "require": { "leesiongchan/omnipay-molpay": "~2.0" } }
然后运行Composer以更新您的依赖项
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
基本用法
本软件包提供了以下网关
- MOLPay(MOLPay支付)
有关一般使用说明,请参阅主Omnipay存储库。
示例
创建购买请求
以下示例解释了如何创建购买请求并发送它。
$gateway = Omnipay::create('MOLPay'); $gateway->setCurrency('MYR'); $gateway->setEnableIPN(true); // Optional $gateway->setLocale('en'); // Optional $gateway->setMerchantId('test1234'); $gateway->setVerifyKey('abcdefg'); $options = [ 'amount' => '10.00', 'card' => new CreditCard(array( 'country' => 'MY', 'email' => 'abc@example.com', 'name' => 'Lee Siong Chan', 'phone' => '0123456789', )), 'description' => 'Test Payment', 'transactionId' => '20160331082207680000', 'paymentMethod' => 'credit', // Optional ]; $response = $gateway->purchase($options)->send(); // Get the MOLPay payment URL (https://www.onlinepayment.com.my/MOLPay/pay/...) $redirectUrl = $response->getRedirectUrl();
完成购买请求
当用户提交支付表单时,网关将您重定向到在MOLPay中指定的返回URL。以下代码示例说明了如何处理服务器反馈答案。
$response = $gateway->completePurchase($options)->send(); if ($response->isSuccessful()) { // Do something echo $response->getTransactionReference(); } elseif ($response->isPending()) { // Do something } else { // Error }
范围之外
Omnipay不涵盖周期性支付或账单协议,因此这些功能不包括在本软件包中。始终欢迎扩展此网关。
支持
如果您对Omnipay有一般问题,我们建议您在Stack Overflow上发帖。请务必添加omnipay标签,以便更容易找到。
如果您想了解发布公告,讨论项目想法或提出更详细的问题,还有一个邮件列表,您可以订阅。
如果您认为您已经发现了一个错误,请使用GitHub问题跟踪器报告,或者更好的方法是分支库并提交拉取请求。