<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\PayCenter\Web\Controller; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use Module\PayCenter\Provider\PayCenterProvider; use Module\PayCenter\Type\PayType; use Module\PayCenter\Util\PayOrderUtil; use Module\PayCenter\Web\Support\PayAlipayWebNotify; use Payment\Client\Notify; use Payment\Config; class NotifyController extends Controller { public function index($xN3qr = '') { goto WBZuu; WBZuu: $Ylazq = InputPackage::buildFromInput(); goto JwLlP; u3gty: switch ($xN3qr) { case PayType::ALIPAY: goto dijW9; qaOfv: return 'fail'; goto ivvR3; ieNzS: switch (Input::get('trade_status')) { case 'TRADE_SUCCESS': case 'TRADE_FINISHED': goto JGM3I; IwRuM: $gsJZj = $Ylazq->getTrimString('trade_no'); goto iWv1K; KOhyd: if ($Gs3Xd['code']) { return 'fail'; } goto c7QnS; JGM3I: $JhXYY = $Ylazq->getTrimString('out_trade_no'); goto IwRuM; iWv1K: Log::info('PayCenter.Alipay.VerifySuccess - ' . json_encode(array('out_trade_no' => $JhXYY, 'trade_no' => $gsJZj), JSON_UNESCAPED_UNICODE)); goto cjlRX; cjlRX: $Gs3Xd = PayOrderUtil::handleOrderPay(PayType::ALIPAY, $JhXYY, array('payOrderId' => $gsJZj)); goto KOhyd; c7QnS: return 'success'; goto aUdxJ; aUdxJ: } goto qaOfv; fXXrJ: if (!app('alipay.web')->verify()) { Log::info('PayCenter.Alipay.VerifyFailed - ' . json_encode(array('data' => Request::instance()->getContent()))); return 'fail'; } goto ieNzS; dijW9: PayOrderUtil::initAlipay(); goto fXXrJ; ivvR3: case PayType::WECHAT: case PayType::WECHAT_MOBILE: case PayType::WECHAT_H5: try { return PayOrderUtil::getWechatPayment()->handlePaidNotify(function ($HMHj9, $cMc22) use($xN3qr) { Log::info('PayCenter.' . $xN3qr . '.VerifySuccess - ' . json_encode($HMHj9, JSON_UNESCAPED_UNICODE)); $Gs3Xd = PayOrderUtil::handleOrderPay($xN3qr, $HMHj9['out_trade_no'], array('payOrderId' => $HMHj9['transaction_id'])); if ($Gs3Xd['code']) { $cMc22($Gs3Xd['msg']); } return true; }); } catch (\Exception $hSVcc) { return $this->handleException($hSVcc); } case PayType::WECHAT_MINI_PROGRAM: try { return PayOrderUtil::getWechatMiniProgramPayment()->handlePaidNotify(function ($HMHj9, $cMc22) { Log::info('PayCenter.WechatMiniProgram.VerifySuccess - ' . json_encode($HMHj9, JSON_UNESCAPED_UNICODE)); $Gs3Xd = PayOrderUtil::handleOrderPay(PayType::WECHAT_MINI_PROGRAM, $HMHj9['out_trade_no'], array('payOrderId' => $HMHj9['transaction_id'])); if ($Gs3Xd['code']) { $cMc22($Gs3Xd['msg']); } return true; }); } catch (\Exception $hSVcc) { return $this->handleException($hSVcc); } case PayType::ALIPAY_WEB: case PayType::ALIPAY_MOBILE: goto k6xyr; bA8UC: $j3paW = Notify::run(Config::ALI_CHARGE, $XhVgh, new PayAlipayWebNotify($xN3qr)); goto QxnQ9; QxnQ9: Log::info('PayCenter.' . $xN3qr . '.NotifyResult - ' . json_encode($j3paW, JSON_UNESCAPED_UNICODE)); goto G2NZ6; PPqe1: $XhVgh = PayOrderUtil::alipayWebConfig($xN3qr); goto bA8UC; k6xyr: Log::info('PayCenter.' . $xN3qr . '.Notify - ' . json_encode($Ylazq->all(), JSON_UNESCAPED_UNICODE)); goto PPqe1; G2NZ6: return $j3paW; goto Gm7Kc; Gm7Kc: default: goto b86tX; wqe81: BizException::throwsIfEmpty('PayTypeProviderEmpty - ' . $xN3qr, $sefXk); goto tUCyp; b86tX: $sefXk = PayCenterProvider::get($xN3qr); goto wqe81; L6BEW: return $sefXk->onNotify($xN3qr, $Ylazq->all()); goto NnHpA; tUCyp: Log::info('PayCenter.' . $xN3qr . '.Notify - ' . json_encode($Ylazq->all(), JSON_UNESCAPED_UNICODE)); goto L6BEW; NnHpA: } goto Ior7K; JwLlP: Log::info('PayCenter.Notify - ' . json_encode($Ylazq->all(), JSON_UNESCAPED_UNICODE)); goto u3gty; Ior7K: } private function handleException(\Exception $hSVcc) { goto W97hB; W97hB: $HMHj9 = $hSVcc->getMessage(); goto gCjmo; gCjmo: $iTD7A = array('Invalid request XML' => 'InvalidXML', 'simplexml_load_string' => 'InvalidXML', 'Undefined index' => 'InvalidNotify'); goto Ga9Sq; Ce5y3: throw $hSVcc; goto rHV7B; Ga9Sq: foreach ($iTD7A as $JdFJR => $PSYn9) { if (Str::contains($HMHj9, $JdFJR)) { Log::info('PayCenter.NotifyController - ' . $PSYn9); return Response::sendError('错误的请求'); } } goto Ce5y3; rHV7B: } }