Пример #1
0
 function httpSend($url, $method, $data)
 {
     $client = new TenpayHttpClient();
     $client->setReqContent($url);
     $client->setMethod($method);
     $client->setReqBody($data);
     $res = '';
     if ($client->call()) {
         $res = $client->getResContent();
     }
     //设置debug信息
     $this->_setDebugInfo('Req Url:' . $url);
     $this->_setDebugInfo('Req data:' . $data);
     $this->_setDebugInfo('Res Content:' . $res);
     return $res;
 }
Пример #2
0
 public function mobile_refund()
 {
     import("@.ORG.pay.Tenpay.RequestHandler");
     import("@.ORG.pay.Tenpay.client.ClientResponseHandler");
     import("@.ORG.pay.Tenpay.client.TenpayHttpClient");
     $reqHandler = new RequestHandler();
     $httpClient = new TenpayHttpClient();
     $resHandler = new ClientResponseHandler();
     $reqHandler = new RequestHandler();
     $reqHandler->init();
     $reqHandler->setKey($this->pay_config["pay_tenpay_partnerkey"]);
     $reqHandler->setGateUrl("https://gw.tenpay.com/gateway/normalrefundquery.xml");
     $httpClient = new TenpayHttpClient();
     $resHandler = new ClientResponseHandler();
     $reqHandler->setParameter("partner", $this->pay_config["pay_tenpay_partnerid"]);
     $reqHandler->setParameter("out_trade_no", $this->order_info["order_type"] . "_" . $this->order_info["order_id"]);
     $reqHandler->setParameter("input_charset", "utf-8");
     $httpClient->setTimeOut(30);
     $httpClient->setMethod("POST");
     $httpClient->setReqContent($reqHandler->getRequestURL());
     if ($httpClient->call()) {
         $resHandler->setContent($httpClient->getResContent());
         $resHandler->setKey($this->pay_config["pay_tenpay_partnerkey"]);
         if ($resHandler->isTenpaySign() && $resHandler->getParameter("retcode") == 0) {
             $refund_param["refund_id"] = $resHandler->getParameter("out_refund_no_0");
             $refund_param["refund_time"] = $refundResult["timestamp"];
             return array("error" => 0, "type" => "ok", "msg" => "退款申请成功!5到10个工作日款项会自动流入您支付时使用的银行卡内。", "refund_param" => $refund_param);
         } else {
             $refund_param["err_msg"] = "验证签名失败 或 业务错误信息:retcode= " . $resHandler->getParameter("retcode") . ",retmsg= " . $resHandler->getParameter("retmsg");
             $refund_param["refund_time"] = time();
             return array("error" => 1, "type" => "fail", "msg" => "退款申请失败!如果重试多次还是失败请联系系统管理员。", "refund_param" => $refund_param);
         }
     } else {
         $refund_param["err_msg"] = "call err:" . $httpClient->getResponseCode() . "," . $httpClient->getErrInfo();
         $refund_param["refund_time"] = time();
         return array("error" => 1, "type" => "fail", "msg" => "退款申请失败!如果重试多次还是失败请联系系统管理员。", "refund_param" => $refund_param);
     }
 }