/** * WxPayNotifyAbstract constructor. */ public function __construct() { parent::__construct(); $this->wxPayApi = WxPayFactory::WxPayApi(); }
function check_wechatpay_response() { //generate QR Code if (isset($_GET['QRData'])) { $url = $_GET['QRData']; Log::DEBUG('Generate WeChat QR Code:' . print_r($url, true)); QRcode::png($url); exit; } else { //handle ipn callback $xml = $GLOBALS['HTTP_RAW_POST_DATA']; Log::DEBUG(' message callback.' . print_r($xml, true)); Log::DEBUG('weChat Async IPN message callback.'); if ($this->isWeChatIPNValid($xml)) { Log::DEBUG('weChat IPN is valid message.'); Log::DEBUG('weChat Async IPN message:' . print_r($xml, true)); $order_id = $this->ipn['attach']; $order = new WC_Order($order_id); $order->payment_complete(); $trade_no = $this->ipn['transaction_id']; update_post_meta($order_id, 'WeChatPay Trade No.', wc_clean($trade_no)); $reply = new WxPayNotifyReply(); $reply->SetReturn_code("SUCCESS"); $reply->SetReturn_msg("OK"); WxpayApi::replyNotify($reply->ToXml()); } else { $reply = new WxPayNotifyReply(); $reply->SetReturn_code("FAIL"); $reply->SetReturn_msg("OK"); WxpayApi::replyNotify($reply->ToXml()); } } }