Ejemplo n.º 1
0
 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     // debug
     Yii::error("\n====================start payorder===================");
     Yii::error($result);
     Yii::error("\n====================end payorder===================");
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         $this->order = $result;
         return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  *
  * 获取jsapi支付的参数
  * @param array $UnifiedOrderResult 统一支付接口返回的数据
  * @throws WxPayException
  *
  * @return json数据,可直接填入js函数作为参数
  */
 public function GetJsApiParameters($UnifiedOrderResult)
 {
     if (!array_key_exists("appid", $UnifiedOrderResult) || !array_key_exists("prepay_id", $UnifiedOrderResult) || $UnifiedOrderResult['prepay_id'] == "") {
         throw new WxPayException("参数错误");
     }
     $jsapi = new WxPayJsApiPay();
     $jsapi->SetAppid($UnifiedOrderResult["appid"]);
     $timeStamp = time();
     $jsapi->SetTimeStamp("{$timeStamp}");
     $jsapi->SetNonceStr(WxPayApi::getNonceStr());
     $jsapi->SetPackage("prepay_id=" . $UnifiedOrderResult['prepay_id']);
     $jsapi->SetSignType("MD5");
     $jsapi->SetPaySign($jsapi->MakeSign());
     $parameters = json_encode($jsapi->GetValues());
     return $parameters;
 }