Home  >  Article  >  Backend Development  >  支付宝如何查询订单支付情况?

支付宝如何查询订单支付情况?

WBOY
WBOYOriginal
2016-06-06 20:15:032770browse

支付宝订单查询文档

支付宝如何查询订单支付情况?

根据文档示例,运行下面PHP 代码

<code>$aop                        = new AopClient ();
$aop->appId                 = C('alipay.app_id');
$aop->rsaPrivateKeyFilePath = C('alipay.private_key');//RSA私钥
$aop->alipayPublicKey       = C('alipay.alipay_public_key');//支付宝公钥
$request                    = new AlipayTradeQueryRequest ();
$paramArray                 = array();
$paramArray['out_trade_no'] ='16031438100034854059';
$paramArray['trade_no']     ='2016031421007864720242676619';
$request->biz_content       =json_encode($paramArray);
$result                     = $aop->execute ($request, NULL );
var_dump($result);</code>

返回下面结果

<code>{
    "code":"40001",
    "msg":"Missing Required Arguments",
    "sub_code":"isv.missing-signature-key",
    "sub_msg":"缺少签名配置"
}</code>

支付宝应用场景是:APP支付,支付流程已经没问题

回复内容:

支付宝订单查询文档

支付宝如何查询订单支付情况?

根据文档示例,运行下面PHP 代码

<code>$aop                        = new AopClient ();
$aop->appId                 = C('alipay.app_id');
$aop->rsaPrivateKeyFilePath = C('alipay.private_key');//RSA私钥
$aop->alipayPublicKey       = C('alipay.alipay_public_key');//支付宝公钥
$request                    = new AlipayTradeQueryRequest ();
$paramArray                 = array();
$paramArray['out_trade_no'] ='16031438100034854059';
$paramArray['trade_no']     ='2016031421007864720242676619';
$request->biz_content       =json_encode($paramArray);
$result                     = $aop->execute ($request, NULL );
var_dump($result);</code>

返回下面结果

<code>{
    "code":"40001",
    "msg":"Missing Required Arguments",
    "sub_code":"isv.missing-signature-key",
    "sub_msg":"缺少签名配置"
}</code>

支付宝应用场景是:APP支付,支付流程已经没问题

查询订单详情:

<code>$parameter = array(
    'service'           => 'single_trade_query',
    'partner'           => '2088101122136241',//合作者ID
    '_input_charset'    => strtolower('utf-8'),
    'out_trade_no'      => '1-1441531218',//商户订单号,唯一
);
ksort($parameter);
reset($parameter);
 
$param = '';
$sign  = '';
 
foreach ($parameter AS $key => $val)
{
    $param .= "$key=" .urlencode($val). "&";
    $sign  .= "$key=$val&";
}
     
$param = substr($param, 0, -1);
$sign  = substr($sign, 0, -1). '你的支付宝key';
$url = 'https://mapi.alipay.com/gateway.do?'.$param. '&sign='.md5($sign).'&sign_type=MD5';
echo file_get_contents($url);
</code>

key在商家服务里面查看:
支付宝如何查询订单支付情况?

支付宝没有提供类似于微信支付中查询订单的情况,只能根据支付宝异步通知客户端服务器和支付宝同步通知给app 客户单的情况进行确定,其中同步通知的校验也要放在服务端,若同步校验成功,也可认为成功,当然最好是以异步通知的结果为准,然后在支付宝开放平台上的支持中心也是可以提问的额,而且回复比较及时(一般半天左右)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn