更新代码
This commit is contained in:
@@ -10,6 +10,7 @@ class UnionPayController extends Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$str = 'msg_type=00&msg_txn_code=002100&msg_crrltn_id=12345678901234567890123456789000&msg_flg=0&msg_sender=01&msg_time=20130318162412&msg_sys_sn=12345678900987654321&msg_ver=0.1&mchnt_no=8981231234567890&term_no=12345678&shop_no=086123456123456789&req_serial_no=12345678900987654321&orig_req_serial_no=12345678900987654321&enc_card_no=123123123123123123123sdfadqerqr&acq_term_sn=123456&refer_no=123456789012&sett_date=20130318&txn_date=20130318&txn_time=162850&orig_amt=10000&discount_amt=2000&pay_amt=8000&pay_mode=1';
|
||||
parse_str($str, $arr_str);
|
||||
|
||||
@@ -32,25 +33,12 @@ class UnionPayController extends Controller
|
||||
public function query(Request $request)
|
||||
{
|
||||
$inputs = $request->all();
|
||||
$sign = $inputs['sign'];
|
||||
unset($inputs['sign']);
|
||||
|
||||
if (!isset($inputs['msg_txn_code'])) {
|
||||
|
||||
}
|
||||
|
||||
$validator = \Validator::make($inputs, [
|
||||
'activityId' => 'required',
|
||||
'outletId' => 'required',
|
||||
'mobile' => 'required',
|
||||
], [
|
||||
'activityId.required' => '缺少活动编码',
|
||||
'outletId.required' => '缺少网点id',
|
||||
'mobile.required' => '缺少手机号',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return $this->error($validator->errors()->first());
|
||||
}
|
||||
|
||||
$action = new UnionPay($inputs, $sign);
|
||||
$res = $action->start();
|
||||
dd($res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
//分配的渠道号
|
||||
'msg_sender' => 01,
|
||||
//打印在小票上,由活动标题、优惠金额、原始金额组合而成
|
||||
'pos_receipt' => '',
|
||||
//广告,用于打印在小票上
|
||||
'pos_ad' => '',
|
||||
//营销联盟广告,用于打印在小票上
|
||||
'pos_mkt_ad' => '',
|
||||
|
||||
'check' => [
|
||||
'self' => [
|
||||
'private' => storage_path('cert/unionpay/self/private_rsa.pem'),
|
||||
|
||||
@@ -2,14 +2,19 @@
|
||||
|
||||
namespace XuanChen\UnionPay\Action;
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Init
|
||||
{
|
||||
|
||||
public $params;
|
||||
|
||||
public $sign;
|
||||
|
||||
public $msg_txn_code;
|
||||
|
||||
public $msg_sender;
|
||||
|
||||
/**
|
||||
* RSA验签
|
||||
* @param $params 待签名数据
|
||||
@@ -41,7 +46,7 @@ class Init
|
||||
/**
|
||||
* Notes: 签名
|
||||
* @Author: 玄尘
|
||||
* @Date: 2020/9/29 9:56
|
||||
* @Date : 2020/9/29 9:56
|
||||
* @return string
|
||||
*/
|
||||
public function getSign()
|
||||
@@ -70,6 +75,7 @@ class Init
|
||||
$params = array_filter($this->params);
|
||||
ksort($params);
|
||||
$signStr = http_build_query($params);
|
||||
|
||||
return $signStr;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,57 @@ class UnionPay extends Init
|
||||
|
||||
public function __construct($params, $sign = '')
|
||||
{
|
||||
$this->params = $params;
|
||||
$this->params = collect($params);
|
||||
$this->sign = $sign;
|
||||
$this->msg_txn_code = $params['msg_txn_code'];
|
||||
$this->msg_sender = config('unionpay.msg_sender');
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
$out = $this->out();
|
||||
|
||||
}
|
||||
|
||||
public function out_data()
|
||||
{
|
||||
$basics = [
|
||||
"msg_type" => "00",
|
||||
"msg_txn_code" => $this->msg_txn_code,
|
||||
"msg_crrltn_id" => $this->params->msg_crrltn_id,
|
||||
"msg_flg" => 1,
|
||||
"msg_sender" => $this->msg_sender,
|
||||
"msg_time" => now()->format('YmdHis'),
|
||||
"msg_sys_sn" => $this->params->msg_sys_sn,
|
||||
"msg_rsp_code" => "0000",
|
||||
"msg_rsp_desc" => "成功",
|
||||
];
|
||||
|
||||
switch ($this->msg_txn_code) {
|
||||
case '002025':
|
||||
$basics = array_merge($basics, [
|
||||
"discount" => 0,
|
||||
"actual_amt" => 0,
|
||||
"pos_display" => "POS显示",
|
||||
// "pos_receipt" => config('unionpay.pos_receipt'),
|
||||
// "pos_ad" => config('unionpay.pos_ad'),
|
||||
"pos_mkt_ad" => config('unionpay.pos_receipt'),
|
||||
]);
|
||||
break;
|
||||
case '002100':
|
||||
$data = array_merge($basics, [
|
||||
'msg_ver' => 0.1,
|
||||
]);
|
||||
break;
|
||||
case '002101':
|
||||
break;
|
||||
case '002102':
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return $basics;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user