adrianbarbos / mobilpay
Laravel 5 mobilpay包装器,基于omnipay,使用omnipay-mobilpay驱动程序
1.0.13
2022-11-29 15:56 UTC
Requires
- php: >=5.3.0
- adrianbarbos/omnipay-mobilpay: ~1.2.1
- illuminate/support: 5.* || 6.* || 7.* || 8.* || 9.*
- omnipay/common: ~3.0
README
Laravel 5 mobilpay包装器,基于omnipay,使用omnipay-mobilpay驱动程序 修改 添加主题
目录
安装
Composer
使用composer安装包
composer require adrianbarbos/mobilpay
或将包添加到您的composer.json
文件中。
{ "require": { "adrianbarbos/mobilpay": "^1.0" } }
然后运行composer update
以获取包的最新版本。
Laravel
Mobilpay自带Laravel的服务提供器。您需要将其添加到composer.json
中,如上述步骤中所述,然后注册服务提供器到您的应用程序中。
从Laravel 5.5开始,服务提供器和外观将自动注册。
打开config/app.php
并找到providers
键。将MobilpayServiceProvider
添加到数组中。
... Adrianbarbos\Mobilpay\MobilpayServiceProvider::class, ...
将所需的别名添加到同一文件中的类别名列表中。
... 'Omnipay' => Omnipay\Omnipay::class, 'Mobilpay' => Adrianbarbos\Mobilpay\Mobilpay::class, ...
发布配置。
php artisan vendor:publish --provider="Adrianbarbos\Mobilpay\MobilpayServiceProvider"
基本用法
发起支付请求
// controller function Mobilpay::setOrderId(1) ->setAmount('10.00') ->setDetails('Some details') ->purchase();
处理响应
// controller function $response = Mobilpay::response(); $data = $response->getData(); //array 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; }
选项
订单号
/** * @param $value string * @return $this */ public function setOrderId($value)
金额
/** * @param $value string * @return $this */ public function setAmount($value)
货币
/** * @param $value string * @return $this */ public function setCurrency($value)
详情
/** * @param $value string * @return $this */ public function setDetails($value)
确认URL
/** * @param $value string * @return $this */ public function setConfirmUrl($value)
返回URL
/** * @param $value string * @return $this */ public function setReturnUrl($value)
测试模式
/** * @param $value boolean * @return $this */ public function setTestMode($value)
附加参数
/** * @param $value array * @return $this */ public function setAdditionalParams($value)