|
|
@ -122,12 +122,44 @@ class RechargeController extends AbstractController
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function confirmBindCardAndPay(RequestInterface $request) {
|
|
|
|
|
|
|
|
[$app, $prePayLog] = $this->checkToken($request->input('stoken', ''));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$amount = $request->input('amount');
|
|
|
|
|
|
|
|
if ($prePayLog->amount == 0) {
|
|
|
|
|
|
|
|
$amount = $request->input('amount');
|
|
|
|
|
|
|
|
if (empty($amount)) {
|
|
|
|
|
|
|
|
throw new BusinessException('请输入金额');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_numeric($amount)) {
|
|
|
|
|
|
|
|
throw new BusinessException('请输入金额');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($amount <= 0) {
|
|
|
|
|
|
|
|
throw new BusinessException('金额需大于0');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$outMemberId = $prePayLog->out_member_id;
|
|
|
|
|
|
|
|
$outOrderNo = $prePayLog->out_order_no;
|
|
|
|
|
|
|
|
$notifyUrl = $prePayLog->notify_url;
|
|
|
|
|
|
|
|
$amount = $prePayLog->amount > 0 ? $prePayLog->amount : intval($amount * 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$smsNo = $request->input('smsNo');
|
|
|
|
|
|
|
|
$smsCode = $request->input('smsCode');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->paymentService->protocolPayPreRequest($this->buildConfirmBindAndPay($outMemberId, $outOrderNo, $smsNo, $smsCode, $amount, $notifyUrl, $app));
|
|
|
|
|
|
|
|
return $this->success([
|
|
|
|
|
|
|
|
'outMemberId' => $prePayLog->out_member_id,
|
|
|
|
|
|
|
|
'bizData' => ['outOrderNo' => $prePayLog->out_order_no]
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function confirmPay(RequestInterface $request) {
|
|
|
|
public function confirmPay(RequestInterface $request) {
|
|
|
|
[$app, $prePayLog] = $this->checkToken($request->input('stoken', ''));
|
|
|
|
[$app, $prePayLog] = $this->checkToken($request->input('stoken', ''));
|
|
|
|
$token = $request->input('token');
|
|
|
|
$token = $request->input('token');
|
|
|
|
$protocol = $request->input('protocol');
|
|
|
|
$protocol = $request->input('protocol');
|
|
|
|
$smsCode = $request->input('smsCode');
|
|
|
|
$smsCode = $request->input('smsCode');
|
|
|
|
$bizData = $this->paymentService->protocolPayConfirm($this->buildConfirmPayParams($token, $protocol, $smsCode, $app));
|
|
|
|
$this->paymentService->protocolPayConfirm($this->buildConfirmPayParams($token, $protocol, $smsCode, $app));
|
|
|
|
return $this->success([
|
|
|
|
return $this->success([
|
|
|
|
'outMemberId' => $prePayLog->out_member_id,
|
|
|
|
'outMemberId' => $prePayLog->out_member_id,
|
|
|
|
'bizData' => ['outOrderNo' => $prePayLog->out_order_no]
|
|
|
|
'bizData' => ['outOrderNo' => $prePayLog->out_order_no]
|
|
|
@ -174,6 +206,26 @@ class RechargeController extends AbstractController
|
|
|
|
return $params;
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function buildConfirmBindAndPay($outMemberId, $outOrderNo, $smsNo, $smsCode, $amount, $notifyUrl, $app)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
|
|
|
|
'app_id' => $app->app_id,
|
|
|
|
|
|
|
|
'timestamp' => time(),
|
|
|
|
|
|
|
|
'nonce_str' => StringHelper::getRandomString(32),
|
|
|
|
|
|
|
|
'data' => json_encode([
|
|
|
|
|
|
|
|
'outMemberId' => $outMemberId,
|
|
|
|
|
|
|
|
'outOrderNo' => $outOrderNo,
|
|
|
|
|
|
|
|
'payAmount' => $amount,
|
|
|
|
|
|
|
|
'notifyUrl' => $notifyUrl,
|
|
|
|
|
|
|
|
'smsNo' => $smsNo,
|
|
|
|
|
|
|
|
'smsCode' => $smsCode,
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
$sign = \App\Helper\Platform\Signer::sign($params, $app->app_key);
|
|
|
|
|
|
|
|
$params['sign'] = $sign;
|
|
|
|
|
|
|
|
return $params;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function buildConfirmPayParams($token, $protocol, $smsCode, $app)
|
|
|
|
private function buildConfirmPayParams($token, $protocol, $smsCode, $app)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$params = [
|
|
|
|
$params = [
|
|
|
|