maras0830 / laravel5-pay2go
此包已弃用且不再维护。未建议替代包。
Laravel5 pay2go。
v2.0.2
2018-09-08 16:27 UTC
Requires
- php: >=5.4.0
- illuminate/support: ^5.1.0
This package is auto-updated.
Last update: 2024-04-12 17:24:38 UTC
README
在Laravel 5.*上使用Pay2Go-Spagateway包进行现金交易
示例
laravel5-Pay2Go-spgateway-example
功能
- 支持添加订单。
- 支持信用卡付款或关闭。
官方文档
支付官方文档可在Spgateway_gateway MPGapi_V1_0_3找到。
版本
版本 | spgateway(智付通版本) | 定期定额 |
---|---|---|
1.0.* | 1.2 | |
2.0.* | 1.4 | 支持(v) |
安装
"maras0830/laravel5-pay2go": "^1.0"
或
"composer require maras0830/laravel5-pay2go"
在config/app.php
中添加providers
Maras0830\Pay2Go\Providers\Pay2GoServiceProvider::class
在config/app.php
中添加aliases
'Pay2Go' => Maras0830\Pay2Go\Pay2Go::class
在.env
中添加,您可以在
CASH_STORE_DEBUG_MODE=false CASH_STORE_ID=xxxxxxxx CASH_STORE_HashKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CASH_STORE_HashIV=xxxxxxxxxxxxxxxx
请记住更改您的APP_URL,spgateway拒绝localhost。
默认返回URL
CASH_ReturnUrl=/order/completed CASH_NotifyURL=/order/notify CASH_Client_BackUrl=/order/cancel
发布配置。
php artisan vendor:publish
用法
MPG(Multi Payment Gateway) 单一串接多种支付
routes.php
Route::get('cash', 'CashController@index'); Route::post('cash/create', 'CashController@store');
CashController.php
public function index()
{
return view('cash.index');
}
resources/views/cash/index.blade.php
<html> <head> <title>Test Cash</title> </head> <body> <h1>智付寶 - 訂單測試</h1> <form name='Pay2go' method='post' action='{{ url('/cash/create') }}'> {!! csrf_field() !!} 商店訂單編號:<input type="text" name="MerchantOrderNo" value="<?php echo "20160825" . random_int(1000,9999) ?>"/> <br/> 訂單金額:<input type="text" name="Amt" value="<?php echo random_int(0,9999) ?>"> <br/> 商品資訊:<input type="text" name="ItemDesc" value="測試商品資訊敘述"> <br/> Email:<input type="text" name="Email" value="Maras0830@gmail.com"> <br/> <input type='submit' value='Submit'> </form> </body> </html>
CashController.php
public function store(Request $request) { $form = $request->except('_token'); // 建立商店 $pay2go = new Pay2Go(env('CASH_STORE_ID'), env('CASH_STORE_HashKey'), env('CASH_STORE_HashIV')); // 商品資訊 $order = $pay2go->setOrder($form['MerchantOrderNo'], $form['Amt'], $form['ItemDesc'], $form['Email'])->submitOrder(); // 將資訊回傳至自定義 view javascript auto submit return view('cash.submit')->with(compact('order')); }
resources/views/cash/submit.blade.php
<html> <head> <title>redirect pay2go ...</title> </head> <body> {!! $order !!} </body> </html>
付款或关闭(信用卡请款或退款)
routes.php
Route::get('admin/order', 'admin\OrderController@index'); Route::get('admin/order/requestPay/{order_id}', 'admin\OrderController@requestPay');
Admin/OrderController.php
public function index() { $orders = $this->orderRepository->all()->get(); return view('admin.cash.index')->with(compact('orders')); }
public function requestPay($order_id) { $order = $this->orderRepository->findBy('order_unique_id', $order_id); $pay2go = new Pay2Go(config('pay2go.MerchantID'), config('pay2go.HashKey'), config('pay2go.HashIV')); $result = $pay2go->requestPaymentPay($order->order_unique_id, $order->amt); return view('admin.cash.request_pay')->with(compact('result')); }
变更日志
[2017.08.25] 在.env中添加调试模式。
[2016.11.25] 将API URL更改为spgateway.com。
[2016.09.06] 支持信用卡付款或关闭。
[2016.08.29] 仅支持添加订单,将添加发票功能,并欢迎开发者加入此项目。