亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php WeChat payment callback url
大家講道理
大家講道理 2017-06-26 10:49:04
0
3
1258

When should the callback url be written? The document does not explain this in detail. WeChat will only access the callback url if the customer's payment is successful. If the payment fails, it will not access it.

大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(3)
Ty80

I think you may not have read the document carefully. Attached is the relevant payment business process sequence diagram.

This sequence diagram explains clearly: after the user confirms the payment and enters the password, and the WeChat verification authorization is successful, the merchant will be notified of the payment result asynchronously (note that this includes two situations: successful payment and failed payment) , merchants update their order business logic based on the parameters returned by WeChat.

某草草

After you make the payment on your mobile phone and see that the payment is completed, this can only be regarded as the first step. The callback will not be performed until the payment is completed, which means that the payment transaction flow is pushed to the callback interface.

 public function noticeFirst() {

        Vendor('WXPAYS.lib.WxPayPubHelper');
        $notify = new \Notify_pub();

        //存儲微信的回調
        $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
        $notify->saveData($xml);
        $arr = $notify->data;


        //驗證簽名,并回應微信。
        //對后臺通知交互時,如果微信收到商戶的應答不是成功或超時,微信認為通知失敗,
        //微信會通過一定的策略(如30分鐘共8次)定期重新發(fā)起通知,
        //盡可能提高通知的成功率,但微信不保證通知最終能成功。
        $wxpay_config = array(
            'APPID' => '',
            'MCHID' => '',
            'KEY' => '',
            'APPSECRET' => ''
        );
        if ($notify->checkSign($wxpay_config) === FALSE) {
            $notify->setReturnParameter("return_code", "FAIL"); //返回狀態(tài)碼
            $notify->setReturnParameter("return_msg", "簽名失敗"); //返回信息
        } else {
            $notify->setReturnParameter("return_code", "SUCCESS"); //設置返回碼
        }
        $returnXml = $notify->returnXml();
        echo $returnXml;

        //==商戶根據(jù)實際情況設置相應的處理流程,此處僅作舉例=======
        if ($notify->checkSign($wxpay_config) === TRUE) {

            if ($arr["return_code"] == "FAIL") {
                
            } elseif ($arr["result_code"] == "FAIL") {
                
            } else {

                $info = M('order')->where(array('order_sn' => $arr['out_trade_no']))->find();

                if (!$info) {
                    exit('訂單信息有誤');
                }
                /* 修改訂單狀態(tài) */
                $data['status'] = 1;
                $time_end = substr($arr['time_end'], 0, 4) . '-' . substr($arr['time_end'], 4, 2) . '-' . substr($arr['time_end'], 6, 2) . ' ' . substr($arr['time_end'], 8, 2) . ':' . substr($arr['time_end'], 10, 2). ':' . substr($arr['time_end'], 12, 2);
                $data['pay_time'] = strtotime($time_end);
                M('order')->where(array('order_id' => $info['order_id']))->save($data);
                $total_fee=$arr['total_fee'];
                       
                /* 添加支付流水 */
                $_data['appid'] = $arr['appid'];
                $_data['bank_type'] = $arr['bank_type'];
                $_data['cash_fee'] = $arr['cash_fee'];
                $_data['fee_type'] = $arr['fee_type'];
                $_data['is_subscribe'] = $arr['is_subscribe'];
                $_data['mch_id'] = $arr['mch_id'];
                $_data['openid'] = $arr['openid'];
                $_data['out_trade_no'] = $arr['out_trade_no'];
                $_data['result_code'] = $arr['result_code'];
                $_data['return_code'] = $arr['result_code'];
                $_data['total_fee'] = $total_fee;
                $_data['trade_type'] = $arr['trade_type'];
                $_data['transaction_id'] = $arr['transaction_id'];
                $_data['nonce_str'] = $arr['nonce_str'];
                $_data['sign'] = $arr['sign'];
                $_data['time_end'] = $arr['time_end'];
                $pay_flow_id=M('payment_flow')->add($_data);
                
                /* 添加財務流水 */
                //訂單ID
                $_trans_data['order_id']=$info['order_id'];
                //會員ID
                $_trans_data['user_id']=$info['user_id'];
                //交易流水號
                $_trans_data['flow_id']=$pay_flow_id;
                //交易類型
                $_trans_data['trans_type']='1';
                //交易渠道
                $_trans_data['trans_channel']='1';
                $_trans_data['amount']=$total_fee*0.01;
                $_trans_data['add_time']=time();
                M('trans_flow')->add($_trans_data);
               
            }

            //商戶自行增加處理流程,
            //例如:更新訂單狀態(tài)
            //例如:數(shù)據(jù)庫操作
            //例如:推送支付完成信息
        }
    }

學習ing

Yes, set the callback url when paying. After the payment is successful, WeChat will actively call this url and then process the logic of updating the order

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template