composer require yuxiaoyang/yfbwappay
或者在你的 composer.json
的 require 部分中添加:
"yuxiaoyang/yfbwappay": "~1.0"
下载完毕之后,直接配置 config/app.php
的 providers
:
//Illuminate\Hashing\HashServiceProvider::class,
Yuxiaoyang\YfbwapPay\YfbwapPayProvider::class,
控制器中使用 YfbwapPayController.php
:
<?php
use \Yuxiaoyang\YfbwapPay\YfbwapPay;
class YfbwapPayController extends Controller
{
public $yfbwappay;
public function __construct()
{
$this->yfbwappay = new yfbwappay();
}
//易付宝WAP支付
public function yfbwappay()
{
$params["out_trade_no"] = rand(1000000000,9999999999);
$params["subject"] = "易付宝PC在线支付";
$params["body"] = "订单详细";
$params["total_fee"] = "0.01";
$params["returnUrl"] = "http://www.***.com/yiwappayReturn";
$data = $this->yfbwappay->pay($params);
return $data;
}
//易付宝WAP支付回调验签
public function yfbwappayReturn(Request $request)
{
$params['responseCode'] = Input::get('responseCode');
$params['signAlgorithm'] = Input::get('signAlgorithm');//签名方式
$params['keyIndex'] = Input::get('keyIndex');
$params['merchantOrderNos'] = Input::get('merchantOrderNos');
$params['signature'] = Input::get('signature');
$data = $this->yfbwappay->payReturn($params);
return $data;
}
}