<?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 $lZifj) { goto aP23m; X7oA6: $lZifj->textarea('payAlipayQrRSAPrivateKey', '应用私钥RSA2(SHA256)')->help('复制 -----BEGIN RSA PRIVATE KEY----- 和 -----END RSA PRIVATE KEY----- 中间的部分'); goto chHxv; chHxv: $lZifj->display('_empty_', '')->content('<span class="ub-text-danger">如果您还没开通支付宝收款，请 <a href="https://tecmz.com/article/payapply" target="_blank">联系我们</a> 协助申请</span>'); goto XeOOJ; XeOOJ: $lZifj->formClass('wide'); goto nlJFN; aP23m: $lZifj->switch('payAlipayQrOn', '开启'); goto SQVlZ; drDYg: $lZifj->textarea('payAlipayQrAliPublicKey', '支付宝公钥')->help('如 '); goto X7oA6; SQVlZ: $lZifj->text('payAlipayQrAppId', 'AppId')->help('如 '); goto drDYg; nlJFN: } 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($coASI, $ri8KE, $iNhXN = array()) { goto RrB_q; tkq3s: $U8wjN['successRedirect'] = $coASI['redirect']; goto Py7zm; RrB_q: $akSp2 = $this->config(); goto YyYGx; hai5P: $U8wjN = array(); goto AGxG6; gm_vD: PayOrderUtil::update($coASI['id'], array('status' => PayOrderStatus::CREATED, 'payType' => $ri8KE, 'timePayCreated' => Carbon::now())); goto hai5P; AGxG6: $U8wjN['payCodeUrl'] = $c16GB; goto tkq3s; JA7KM: try { $c16GB = Charge::run(Config::ALI_CHANNEL_QR, $akSp2, $jldvY); } catch (\Exception $ZemkG) { return Response::generate(-1, '创建支付错误(' . $ZemkG->getMessage() . ')'); } goto gm_vD; Py7zm: return Response::generate(0, 'ok', $U8wjN); goto beDLL; YyYGx: $jldvY = array('subject' => Str::limit(AlipayUtil::filterSpecialChars($coASI['body']), 200), 'body' => Str::limit(AlipayUtil::filterSpecialChars($coASI['body']), 100), 'order_no' => config('pay.payOrderOutTradeNoPrefix') . '_' . $coASI['id'], 'timeout_express' => time() + 3600 * 24, 'amount' => $coASI['feeTotal'], 'return_param' => '', 'goods_type' => '0', 'store_id' => '', 'qr_mod' => ''); goto JA7KM; beDLL: } public function onNotify($ri8KE, $WZ8dY, $qOrzw = array()) { $akSp2 = $this->config(); return Notify::run(Config::ALI_CHARGE, $akSp2, new AlipayQrPayNotify()); } public function webRender($qOrzw) { return View::make('module::PayCenter.View.inc.alipayQr', $qOrzw)->render(); } }