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

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

WBOY
Release: 2016-06-06 20:15:03
Original
2817 people have browsed it

支付宝订单查询文档

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

根据文档示例,运行下面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>
Copy after login
Copy after login

返回下面结果

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

支付宝应用场景是: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>
Copy after login
Copy after login

返回下面结果

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

支付宝应用场景是: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>
Copy after login

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template