/** * 获取配置文件(json) */ public function getConfig(array $api, $debug = false) { $this->config['jsApiList'] = $api; if ($debug) { $this->config['debug'] = true; } return Json::encode($this->config); }
<?php require './config.php'; use Thenbsp\Wechat\Util\Util; use Thenbsp\Wechat\Util\Json; use Thenbsp\Wechat\Util\Cache; try { $cache = new Cache('../Storage'); } catch (\Exception $e) { exit($e->getMessage()); } if ($request = @file_get_contents('php://input')) { $content = Util::XML2Array($request); $cache->set('payment_notify', Json::encode($content)); } // 微信服务器会在支付成功后该求该 URL,以 XML 的方式提交此次支付信息,具体信息类似: // { // "appid":"wx345f3830c28971f4", // "bank_type":"CFT", // "cash_fee":"1", // "fee_type":"CNY", // "is_subscribe":"Y", // "mch_id":"1241642202", // "nonce_str":"fTbkMTXgMmnvTaO1", // "openid":"oWY-5jjLjo7pYUK86JPpwvcnF2Js", // "out_trade_no":"124164220220150803161536", // "result_code":"SUCCESS", // "return_code":"SUCCESS", // "sign":"4B8948BD3E831394C956B5DFA8AAEB1E", // "time_end":"20150803161547", // "total_fee":"1",
/** * 获取配置文件(用于 Jssdk chooseWXPay 方式) */ public function getConfigJssdk($asJson = true) { $config = $this->_generateConfig(); $params = array('timestamp' => $config['timeStamp'], 'nonceStr' => $config['nonceStr'], 'package' => $config['package'], 'signType' => $config['signType'], 'paySign' => $config['paySign']); return $asJson ? Json::encode($params) : $params; }