接收回調通知后的業務處理都在NotifyProcess做,$data包含了微信返回給你的數據。
Service:
<?php /** * Created by PhpStorm. * User: skh * Date: 13/03/2017 * Time: 14:46 */ namespace App\Http\Services; class WxNotifyService extends \WxPayNotify { //重寫回調處理函數 public function NotifyProcess($data, &$msg) { // $notfiyOutput = array(); if(!array_key_exists("transaction_id", $data)){ $msg = "輸入參數不正確"; return false; } //查詢訂單,判斷訂單真實性 if(!$this->queryOrder($data["transaction_id"])){ $msg = "訂單查詢失敗"; return false; } return true; } //查詢訂單 public function queryOrder($transaction_id) { $input = new \WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = \WxPayApi::orderQuery($input); if(array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; } return false; } }
技術交流群:576269252
------------------------------------------
聲明: 原創文章,未經允許,禁止轉載!
------------------------------------------