示例#1
0
 public function NotifyProcess($data, &$msg)
 {
     //Log::DEBUG("call back:" . json_encode($data));
     U::W([__METHOD__, $data, $msg]);
     /*
             $data => Array
             (
             [appid] => wx79c2bf0249ede62a
             [is_subscribe] => Y
             [mch_id] => 1220047701
             [nonce_str] => bfegWC2eAXolkxj8
             [openid] => oSHFKs9_gq4Ve6sHdQ86mJh1U3ZQ
             [product_id] => 123456789
             [sign] => 6D81DBD2229DC244D9E94E6BD24EF5B3
             )
     */
     if (!array_key_exists("openid", $data) || !array_key_exists("product_id", $data)) {
         $msg = "回调数据异常";
         return false;
     }
     $openid = $data["openid"];
     $product_id = $data["product_id"];
     $result = $this->unifiedorder($openid, $product_id);
     if (!array_key_exists("appid", $result) || !array_key_exists("mch_id", $result) || !array_key_exists("prepay_id", $result)) {
         $msg = "统一下单失败";
         return false;
     }
     $this->SetData("appid", $result["appid"]);
     $this->SetData("mch_id", $result["mch_id"]);
     $this->SetData("nonce_str", WxPayApi::getNonceStr());
     $this->SetData("prepay_id", $result["prepay_id"]);
     $this->SetData("result_code", "SUCCESS");
     $this->SetData("err_code_des", "OK");
     return true;
 }