isurindu / webxpay-laravel
Webxpay Laravel 扩展包
v1.4
2018-07-02 09:56 UTC
This package is not auto-updated.
Last update: 2024-10-01 01:14:50 UTC
README
安装
您可以通过 Composer 安装此包
composer require isurindu/webxpay-laravel
在 Laravel 5.5 中,服务提供者将自动注册。在框架的旧版本中,只需在 config/app.php
文件中添加服务提供者即可
'providers' => [ // ... Isurindu\WebxpayLaravel\WebxpayServiceProvider::class, ];
您可以发布配置和视图
php artisan vendor:publish --provider="Isurindu\WebxpayLaravel\WebxpayServiceProvider"
使用方法
在路由中
Route::get('payment/{ORDER_ID}', 'PaymentController@index'); Route::post('payment/verify', 'PaymentController@verify');
在 App/Http/Middleware/VerifyCsrfToken.php 中
<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ 'payment/verify' ]; }
在控制器中
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Isurindu\WebxpayLaravel\Facades\Webxpay; class PaymentController extends Controller { public function store(Request $request) { return Webxpay::redirect([ 'order_id'=>'102', 'price'=>'100', 'first_name'=>'isurindu', 'last_name'=>'prabashwara', 'email'=>'hello@isurindu.com', 'contact_number'=>'', 'address_line_one'=>'', 'cms'=>'laravel', 'process_currency'=>'LKR', 'custom_fields'=>'', 'city'=>'', 'state'=>'', 'postal_code'=>'', 'country'=>'', ]); } public function verify(Request $request) { return dd(Webxpay::verify()); } }