支付宝订单查询接口(alipay.trade.query):统一收单交易查询-明生-尊龙凯时平台在线地址

alipay.trade.query接口提供所有支付宝支付订单的查询,可以查询单个或多个订单状态。
通过该接口主动查询订单状态,完成下一步的业务逻辑。

需要调用查询接口的情况:
(1)当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
(2)调用支付接口后,返回系统错误或未知交易状态情况; 调用alipay.trade.pay,返回inprocess的状态;
(3)调用alipay.trade.cancel之前,需确认支付状态
一、交易订单查询
require_once '../aop/aopclient.php';
require_once '../aop/aopcertclient.php';
require_once '../aop/aopcertification.php';
require_once '../aop/alipayconfig.php';
require_once '../aop/request/alipaytradequeryrequest.php';
$privatekey = "xxxx";
$alipaypublickey = "yyyy";
$alipayconfig = new alipayconfig();
$alipayconfig->setserver;
$alipayconfig->setappid("zzzz");
$alipayconfig->setprivatekey($privatekey);
$alipayconfig->setformat("json");
$alipayconfig->setalipaypublickey($alipaypublickey);
$alipayconfig->setcharset("utf8");
$alipayconfig->setsigntype("rsa2");
$alipayclient = new aopclient($alipayconfig);
$request = new alipaytradequeryrequest();
$request->setbizcontent("{".
"\"out_trade_no\":\"".$out_trade_no."\",".
"\"total_amount\":\"".$amount."\",".
"}");
$responseresult = $alipayclient->execute($request);
$responseapiname = str_replace(".","_",$request->getapimethodname())."_response";
$response = $responseresult->$responseapiname;
if(!empty($response->code)&&$response->code==10000){
echo("调用成功");
}
else{
echo("调用失败");
}

二、返回json数组:
{
"alipay_trade_query_response": {
"code": "40004",
"msg": "business failed",
"sub_code": "acq.trade_not_exist",
"sub_msg": "交易不存在",
"buyer_pay_amount": "0.00",
"invoice_amount": "0.00",
"out_trade_no": "90040406",
"point_amount": "0.00",
"receipt_amount": "0.00"
},
"sign": "x xxxrtdgdgdsdrertergdfhdhd"
}
发表评论
网站地图