<?php
 namespace Module\Vendor\Pay\Controller; use ModStart\Core\Input\Response; use Module\Vendor\Pay\Util\PayOrderUtil; use Module\Vendor\Pay\Type\PayType; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Session; class ReturnController extends Controller { public function index($payType = '') { switch ($payType) { case PayType::ALIPAY_WEB: PayOrderUtil::initAlipay(); if (!app('alipay.web')->verify()) { Log::notice('alipay return -> query data verification fail.', [ 'data' => Request::getQueryString() ]); return Response::send(-1, '支付失败:-1'); } switch (Input::get('trade_status')) { case 'TRADE_SUCCESS': case 'TRADE_FINISHED': Log::notice('alipay return -> data verification success.', [ 'out_trade_no' => Input::get('out_trade_no'), 'trade_no' => Input::get('trade_no') ]); $ret = PayOrderUtil::handleOrderPay(PayType::ALIPAY, Input::get('out_trade_no', '')); if ($ret['code']) { return Response::send(-1, '支付失败:' . $ret['msg']); } $redirect = empty($ret['data']['order']['param']['redirect']) ? null : $ret['data']['order']['param']['redirect']; if (null === $redirect) { return Response::send(0, '支付成功'); } else { return Response::send(0, null, null, $redirect); } } return Response::send(-1, '支付失败'); case PayType::ALIPAY: PayOrderUtil::initAlipay(); if (!app('alipay.web')->verify()) { Log::notice('alipay return -> query data verification fail.', [ 'data' => Request::getQueryString() ]); return Response::send(-1, '支付失败:-1'); } switch (Input::get('trade_status')) { case 'TRADE_SUCCESS': case 'TRADE_FINISHED': Log::notice('alipay return -> data verification success.', [ 'out_trade_no' => Input::get('out_trade_no'), 'trade_no' => Input::get('trade_no') ]); $ret = PayOrderUtil::handleOrderPay(PayType::ALIPAY, Input::get('out_trade_no', '')); if ($ret['code']) { return Response::send(-1, '支付失败:' . $ret['msg']); } $redirect = empty($ret['data']['order']['param']['redirect']) ? null : $ret['data']['order']['param']['redirect']; if (null === $redirect) { return Response::send(0, '支付成功'); } else { return Response::send(0, null, null, $redirect); } } return Response::send(-1, '支付失败'); } } } 