ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ public function pay(){ require_once "../extend/WxPay/lib/WxPay.Api.php"; require_once "../extend/WxPay/example/WxPay.JsApiPay.php"; require_once "../extend/WxPay/example/WxPay.Config.php"; require_once "../extend/WxPay/lib/WxPay.Data.php"; $openid =input('post.openid'); $fee =input('post.fee'); $attach=input('post.attach'); $tools = new \JsApiPay(); $input = new \WxPayUnifiedOrder(); $input->SetBody("壹城好店平台"); $input->SetAttach($attach); $out_trade_no = $this->order_number($openid); $input->SetOut_trade_no($out_trade_no); $input->SetTotal_fee($fee*100); $input->SetNotify_url("https://admin.nineopen.com/pay/notify_url"); $input->SetTrade_type("JSAPI"); $input->SetOpenid($openid); $config = new \WxPayConfig(); $order = new \WxPayApi(); $array= $order->unifiedOrder($config, $input); $jsApiParameters = $tools->GetJsApiParameters($array); $data=json_decode($jsApiParameters,true); return show(0,'ok',$data); } private function order_number($openid) { return md5($openid.time().rand(10,99)); } public function notify_url(){ $postStr = file_get_contents('php://input'); libxml_disable_entity_loader(true); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $data=json_decode(trim(json_encode($postObj)),true); if($data['return_code']=='SUCCESS' and $data['result_code']=='SUCCESS' ){ $data['attach']=json_decode($data['attach'],true); Cache::set('test111',$data, 7000); $xml='<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>'; echo $xml; } } public function notify(){ $data=Cache::get('test111'); return show(0,'ok',$data); } ~~~