<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\PayCenter\Provider; use Carbon\Carbon; use Illuminate\Support\Facades\View; use Illuminate\Support\Str; use ModStart\Admin\Layout\AdminConfigBuilder; use ModStart\Core\Input\Response; use ModStart\Module\ModuleClassLoader; use Module\PayCenter\Type\PayOrderStatus; use Module\PayCenter\Util\AlipayUtil; use Module\PayCenter\Util\PayOrderUtil; use Payment\Client\Charge; use Payment\Client\Notify; use Payment\Config; class AlipayQrPayCenterProvider extends AbstractPayCenterProvider { const NAME = 'alipay_qr'; public function name() { return self::NAME; } public function title() { return '支付宝当面付'; } public function supports() { return array('web'); } public function enable() { return boolval(modstart_config('payAlipayQrOn', false)); } public function init() { ModuleClassLoader::addNamespaceIfMissing('Payment', __DIR__ . '/../SDK/helei112g-payment/src'); } public function adminConfig(AdminConfigBuilder $P2vse) { goto nhYCu; njQ2U: $P2vse->formClass('wide'); goto HCoFp; c2IIG: $P2vse->display('_empty_', '')->content('<span class="ub-text-danger">如果您还没开通支付宝收款，请 <a href="https://tecmz.com/article/payapply" target="_blank">联系我们</a> 协助申请</span>'); goto njQ2U; GQVyl: $P2vse->textarea('payAlipayQrRSAPrivateKey', '应用私钥RSA2(SHA256)')->help('复制 -----BEGIN RSA PRIVATE KEY----- 和 -----END RSA PRIVATE KEY----- 中间的部分'); goto c2IIG; nhYCu: $P2vse->switch('payAlipayQrOn', '开启'); goto JqDJv; JqDJv: $P2vse->text('payAlipayQrAppId', 'AppId')->help('如 '); goto NFvZz; NFvZz: $P2vse->textarea('payAlipayQrAliPublicKey', '支付宝公钥')->help('如 '); goto GQVyl; HCoFp: } private function config() { return array('use_sandbox' => false, 'app_id' => modstart_config()->getWithEnv('payAlipayQrAppId'), 'sign_type' => 'RSA2', 'ali_public_key' => modstart_config()->getWithEnv('payAlipayQrAliPublicKey'), 'rsa_private_key' => modstart_config()->getWithEnv('payAlipayQrRSAPrivateKey'), 'limit_pay' => array(), 'notify_url' => action('\\Module\\PayCenter\\Web\\Controller\\NotifyController@index', array('payType' => self::name())), 'return_url' => action('\\Module\\PayCenter\\Web\\Controller\\ReturnController@index', array('payType' => self::name())), 'return_raw' => true); } public function onSubmit($OUSS0, $gDyzf, $r2pbP = array()) { goto XwrdI; qVNmK: $avcnU['payCodeUrl'] = $uWJ9v; goto uvByy; GhxdT: return Response::generate(0, 'ok', $avcnU); goto W_qxw; wWq0v: $ONULQ = array('subject' => Str::limit(AlipayUtil::filterSpecialChars($OUSS0['body']), 200), 'body' => Str::limit(AlipayUtil::filterSpecialChars($OUSS0['body']), 100), 'order_no' => config('pay.payOrderOutTradeNoPrefix') . '_' . $OUSS0['id'], 'timeout_express' => time() + 3600 * 24, 'amount' => $OUSS0['feeTotal'], 'return_param' => '', 'goods_type' => '0', 'store_id' => '', 'qr_mod' => ''); goto IulSJ; uvByy: $avcnU['successRedirect'] = $OUSS0['redirect']; goto GhxdT; XwrdI: $MK0sx = $this->config(); goto wWq0v; rhHGW: PayOrderUtil::update($OUSS0['id'], array('status' => PayOrderStatus::CREATED, 'payType' => $gDyzf, 'timePayCreated' => Carbon::now())); goto tTlKk; IulSJ: try { $uWJ9v = Charge::run(Config::ALI_CHANNEL_QR, $MK0sx, $ONULQ); } catch (\Exception $qoTNG) { return Response::generate(-1, '创建支付错误(' . $qoTNG->getMessage() . ')'); } goto rhHGW; tTlKk: $avcnU = array(); goto qVNmK; W_qxw: } public function onNotify($gDyzf, $Km8YS, $w6bW5 = array()) { $MK0sx = $this->config(); return Notify::run(Config::ALI_CHARGE, $MK0sx, new AlipayQrPayNotify()); } public function webRender($w6bW5) { return View::make('module::PayCenter.View.inc.alipayQr', $w6bW5)->render(); } }