<?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 $A2Tuf) { goto HfItA; f_bpx: $A2Tuf->formClass('wide'); goto GhI6i; HfItA: $A2Tuf->switch('payAlipayQrOn', '开启'); goto Ov4Rn; oMChT: $A2Tuf->display('_empty_', '')->content('<span class="ub-text-danger">如果您还没开通支付宝收款，请 <a href="https://tecmz.com/article/payapply" target="_blank">联系我们</a> 协助申请</span>'); goto f_bpx; a4BqX: $A2Tuf->textarea('payAlipayQrRSAPrivateKey', '应用私钥RSA2(SHA256)')->help('复制 -----BEGIN RSA PRIVATE KEY----- 和 -----END RSA PRIVATE KEY----- 中间的部分'); goto oMChT; dRA7j: $A2Tuf->textarea('payAlipayQrAliPublicKey', '支付宝公钥')->help('如 '); goto a4BqX; Ov4Rn: $A2Tuf->text('payAlipayQrAppId', 'AppId')->help('如 '); goto dRA7j; GhI6i: } 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($wpCAw, $xN3qr, $It5Ki = array()) { goto s1gbN; s1gbN: $XhVgh = $this->config(); goto fUFto; ZNhOo: $smBDO = array(); goto AKGG_; fUFto: $r8z56 = array('subject' => Str::limit(AlipayUtil::filterSpecialChars($wpCAw['body']), 200), 'body' => Str::limit(AlipayUtil::filterSpecialChars($wpCAw['body']), 100), 'order_no' => config('pay.payOrderOutTradeNoPrefix') . '_' . $wpCAw['id'], 'timeout_express' => time() + 3600 * 24, 'amount' => $wpCAw['feeTotal'], 'return_param' => '', 'goods_type' => '0', 'store_id' => '', 'qr_mod' => ''); goto moqiy; moqiy: try { $AzV2A = Charge::run(Config::ALI_CHANNEL_QR, $XhVgh, $r8z56); } catch (\Exception $hSVcc) { return Response::generate(-1, '创建支付错误(' . $hSVcc->getMessage() . ')'); } goto vPtaO; McvHm: $smBDO['successRedirect'] = $wpCAw['redirect']; goto jkyFX; vPtaO: PayOrderUtil::update($wpCAw['id'], array('status' => PayOrderStatus::CREATED, 'payType' => $xN3qr, 'timePayCreated' => Carbon::now())); goto ZNhOo; AKGG_: $smBDO['payCodeUrl'] = $AzV2A; goto McvHm; jkyFX: return Response::generate(0, 'ok', $smBDO); goto IphDM; IphDM: } public function onNotify($xN3qr, $Ylazq, $KJ3xr = array()) { $XhVgh = $this->config(); return Notify::run(Config::ALI_CHARGE, $XhVgh, new AlipayQrPayNotify()); } public function webRender($KJ3xr) { return View::make('module::PayCenter.View.inc.alipayQr', $KJ3xr)->render(); } }