<?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 ModStart\Core\Util\SerializeUtil; 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($gDyzf = '') { goto DhRx_; DhRx_: $Km8YS = InputPackage::buildFromInput(); goto ADUzD; v0Hld: switch ($gDyzf) { case PayType::ALIPAY: goto V42OW; lskIL: return 'fail'; goto wfIec; eiqla: if (!app('alipay.web')->verify()) { Log::info('PayCenter.Alipay.VerifyFailed - ' . SerializeUtil::jsonEncode(array('data' => Request::instance()->getContent()))); return 'fail'; } goto X8QRb; X8QRb: switch (Input::get('trade_status')) { case 'TRADE_SUCCESS': case 'TRADE_FINISHED': goto D5XZj; qBgP5: if ($rhLXE['code']) { return 'fail'; } goto cHD37; D5XZj: $rbm7s = $Km8YS->getTrimString('out_trade_no'); goto mTZnM; mTZnM: $B5OyZ = $Km8YS->getTrimString('trade_no'); goto AnSD5; WcPw_: $rhLXE = PayOrderUtil::handleOrderPay(PayType::ALIPAY, $rbm7s, array('payOrderId' => $B5OyZ)); goto qBgP5; cHD37: return 'success'; goto GbG7r; AnSD5: Log::info('PayCenter.Alipay.VerifySuccess - ' . SerializeUtil::jsonEncode(array('out_trade_no' => $rbm7s, 'trade_no' => $B5OyZ), JSON_UNESCAPED_UNICODE)); goto WcPw_; GbG7r: } goto lskIL; V42OW: PayOrderUtil::initAlipay(); goto eiqla; wfIec: case PayType::WECHAT: case PayType::WECHAT_MOBILE: case PayType::WECHAT_H5: try { return PayOrderUtil::getWechatPayment()->handlePaidNotify(function ($A_afV, $EjQzd) use($gDyzf) { Log::info('PayCenter.' . $gDyzf . '.VerifySuccess - ' . SerializeUtil::jsonEncode($A_afV, JSON_UNESCAPED_UNICODE)); $rhLXE = PayOrderUtil::handleOrderPay($gDyzf, $A_afV['out_trade_no'], array('payOrderId' => $A_afV['transaction_id'])); if ($rhLXE['code']) { $EjQzd($rhLXE['msg']); } return true; }); } catch (\Exception $qoTNG) { return $this->handleException($qoTNG); } case PayType::WECHAT_MINI_PROGRAM: try { return PayOrderUtil::getWechatMiniProgramPayment()->handlePaidNotify(function ($A_afV, $EjQzd) { Log::info('PayCenter.WechatMiniProgram.VerifySuccess - ' . SerializeUtil::jsonEncode($A_afV, JSON_UNESCAPED_UNICODE)); $rhLXE = PayOrderUtil::handleOrderPay(PayType::WECHAT_MINI_PROGRAM, $A_afV['out_trade_no'], array('payOrderId' => $A_afV['transaction_id'])); if ($rhLXE['code']) { $EjQzd($rhLXE['msg']); } return true; }); } catch (\Exception $qoTNG) { return $this->handleException($qoTNG); } case PayType::ALIPAY_WEB: case PayType::ALIPAY_MOBILE: goto AQBac; OVUOD: $AzbSd = Notify::run(Config::ALI_CHARGE, $MK0sx, new PayAlipayWebNotify($gDyzf)); goto se00R; se00R: Log::info('PayCenter.' . $gDyzf . '.NotifyResult - ' . SerializeUtil::jsonEncode($AzbSd, JSON_UNESCAPED_UNICODE)); goto e2hr0; Mf1DL: $MK0sx = PayOrderUtil::alipayWebConfig($gDyzf); goto OVUOD; AQBac: Log::info('PayCenter.' . $gDyzf . '.Notify - ' . SerializeUtil::jsonEncode($Km8YS->all(), JSON_UNESCAPED_UNICODE)); goto Mf1DL; e2hr0: return $AzbSd; goto enNwr; enNwr: default: goto UIcMn; PlybJ: Log::info('PayCenter.' . $gDyzf . '.Notify - ' . SerializeUtil::jsonEncode($Km8YS->all(), JSON_UNESCAPED_UNICODE)); goto QW0Y3; nIxfy: BizException::throwsIfEmpty('PayTypeProviderEmpty - ' . $gDyzf, $tDnAb); goto PlybJ; QW0Y3: return $tDnAb->onNotify($gDyzf, $Km8YS->all()); goto BDNX9; UIcMn: $tDnAb = PayCenterProvider::get($gDyzf); goto nIxfy; BDNX9: } goto WKJYa; ADUzD: Log::info('PayCenter.Notify - ' . SerializeUtil::jsonEncode($Km8YS->all(), JSON_UNESCAPED_UNICODE)); goto v0Hld; WKJYa: } private function handleException(\Exception $qoTNG) { goto gGIkI; gGIkI: $A_afV = $qoTNG->getMessage(); goto Bt_DS; Bt_DS: $Qlahg = array('Invalid request XML' => 'InvalidXML', 'simplexml_load_string' => 'InvalidXML', 'Undefined index' => 'InvalidNotify'); goto VRlgw; ISlg5: throw $qoTNG; goto nJnY4; VRlgw: foreach ($Qlahg as $KAKiA => $Iim2u) { if (Str::contains($A_afV, $KAKiA)) { Log::info('PayCenter.NotifyController - ' . $Iim2u); return Response::sendError('错误的请求'); } } goto ISlg5; nJnY4: } }