PHP code example of maras0830 / laravel5-pay2go
1. Go to this page and download the library: Download maras0830/laravel5-pay2go library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maras0830 / laravel5-pay2go example snippets
Maras0830\Pay2Go\Providers\Pay2GoServiceProvider::class
'Pay2Go' => Maras0830\Pay2Go\Pay2Go::class
php artisan vendor:publish
Route::get('cash', 'CashController@index');
Route::post('cash/create', 'CashController@store');
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'));
}
Route::get('admin/order', 'admin\OrderController@index');
Route::get('admin/order/requestPay/{order_id}', 'admin\OrderController@requestPay');
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'));
}
config/app.php
config/app.php
html
<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=" echo "20160825" . random_int(1000,9999)