亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
二、實(shí)現(xiàn)細(xì)節(jié)
1. 獲得access token
3.提交查詢(xún)
三、訂單結(jié)果
Home WeChat Applet WeChat Development WeChat payment development order inquiry

WeChat payment development order inquiry

Feb 25, 2017 pm 05:30 PM

1. Order Query

Due to technical reasons on one side, the merchant may not receive the final payment notification within the expected time. At this time, the merchant can query the detailed payment status of the order through this API.

The URL of the order query API is:

https://api.weixin.qq.com/pay/orderquery?access_token=xxxxxx

The parameters in the URL only contain At present, the WeChat public platform credential access_token, and the real data of order query is placed in PostData, the format is as follows:

{
????"appid"?:?"wwwwb4f85f3a797777",
????"package"?:?"out_trade_no=11122&partner=1900090055&sign=4e8d0df3da0c3d0df38f",
????"timestamp"?:?"1369745073",
????"app_signature"?:?"53cca9d47b883bd4a5c85a9300df3da0cb48565c",
????"sign_method"?:?"sha1"}

The above content parameter description is shown in the table .

AppId of the public platform account; Query the key information data of the order, including the third-party unique order number out_trade_no, Tenpay merchant ID partner (the partnerid mentioned above), Signature sign, where sign is to sort the parameters in dictionary order and combine them with &, and finally add &key=partnerkey (unique allocation), perform md5 operation, and then convert it to all uppercase, finally getting signlinux timestamp;Generated according to the signature method mentioned in the payment signature (paySign) generation method, the participating signature fields are: appid, appkey, package, timestamp; Signature method (not counted in signature generation);

Parameter Description

appid

package

timestamp

app_signature

sign_method

?

二、實(shí)現(xiàn)細(xì)節(jié)

1. 獲得access token

這個(gè)很容易,參考微信公眾平臺(tái)開(kāi)發(fā)(26) ACCESS TOKEN

代碼如下:

$appid = "wx0000000000000000";
$appsecret = "e76050733c695748537fc4d4c21d0e2c";
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
$result = https_request($url);
$jsoninfo = json_decode($result, true);
$access_token = $jsoninfo["access_token"];

2. 參數(shù)生成

appid: 直接賦值

timestamp:程序直接獲取

$timestamp = time();

sign_method:這里為sha1

難點(diǎn)1:package 值的獲得

先要獲得sign

sign是out_trade_no,partner,key(partnerkey)三項(xiàng)信息的字典序排序,再M(fèi)D5運(yùn)算,再轉(zhuǎn)為大寫(xiě)

$sign= strtoupper(md5("out_trade_no=JfuKdiBig4zZnE4n&partner=1234567890&key=ebf5cf381de2d716d432bfda34fa9e57"));

package 是查詢(xún)訂單的關(guān)鍵信息數(shù)據(jù),包含第三方唯一訂單號(hào) out_trade_no、財(cái)付通商戶(hù)身仹標(biāo)識(shí) partner(即前文所述的 partnerid) 、簽名 sign

$package = "out_trade_no=JfuKdiBig4zZnE4n&partner=1234567890&sign=".$sign;

難點(diǎn)2:獲得app_signature

app_signature 依然是根據(jù)支付簽名(paySign)生成方法中所講的簽名方式生成的,參加簽名字段為:appid、appkey、package、timestamp;

$obj['appid']          = "wx0000000000000000";
$obj['appkey']         = "8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6k";
$obj['package']        = $package;
$obj['timestamp']      = $timestamp;
$WxPayHelper->get_biz_sign($obj);

這樣各項(xiàng)參數(shù)都獲得了

3.提交查詢(xún)

$jsonmenu = '{
    "appid" : "wx0000000000000000",
    "package" : "'.$package.'",
    "timestamp" : "'.$timestamp.'",
    "app_signature" : "'.$app_signature.'",
    "sign_method" : "sha1"
}
';

$url = "https://api.weixin.qq.com/pay/orderquery?access_token=".$access_token;
$result = https_request($url, $jsonmenu);
var_dump($result);

完整代碼如下所示:

include_once("WxPayHelper.php");

//1. 獲取access token
$appid = "wx0000000000000000";
$appsecret = "e76050733ce76050733ce76050733cdd";
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
$result = https_request($url);
$jsoninfo = json_decode($result, true);
$access_token = $jsoninfo["access_token"];


//2.準(zhǔn)備參數(shù)
$timestamp = time();
$sign= strtoupper(md5("out_trade_no=JfuKdiBig4zZnE4n&partner=1234567890&key=asdfasdfasdfasdfasdfasdfasdfasdf"));
$package = "out_trade_no=JfuKdiBig4zZnE4n&partner=1234567890&sign=".$sign;

//2.1構(gòu)造最麻煩的app_signature
$obj['appid']          = "wx0000000000000000";
$obj['appkey']         = "8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6k";
$obj['package']        = $package;
$obj['timestamp']      = $timestamp;
$WxPayHelper = new WxPayHelper();
//get_biz_sign函數(shù)受保護(hù),需要先取消一下,否則會(huì)報(bào)錯(cuò)
$app_signature  = $WxPayHelper->get_biz_sign($obj);

//3. 將構(gòu)造的json提交給微信服務(wù)器,查詢(xún)
$jsonmenu = '
{
 "appid" : "wx0000000000000000",
 "package" : "'.$package.'",
 "timestamp" : "'.$timestamp.'",
 "app_signature" : "'.$app_signature.'",
 "sign_method" : "sha1"
}
';

$url = "https://api.weixin.qq.com/pay/orderquery?access_token=".$access_token;
$result = https_request($url, $jsonmenu);
var_dump($result);

function https_request($url, $data = null){
 $curl = curl_init();
 curl_setopt($curl, CURLOPT_URL, $url);
 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
 if (!empty($data)){
     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
 }
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 $output = curl_exec($curl);
 curl_close($curl);
 return $output;
}

三、訂單結(jié)果

上述程序執(zhí)行后,獲得訂單結(jié)果如下

{
    "errcode": 0,
    "errmsg": "ok",
    "order_info": {
        "ret_code": 0,
        "ret_msg": "",
        "input_charset": "GBK",
        "trade_state": "0",
        "trade_mode": "1",
        "partner": "1234567890",
        "bank_type": "CMB_FP",
        "bank_billno": "201405273540085997",
        "total_fee": "1",
        "fee_type": "1",
        "transaction_id": "1218614901201405273313473135",
        "out_trade_no": "JfuKdiBig4zZnE4n",
        "is_split": "false",
        "is_refund": "false",
        "attach": "",
        "time_end": "20140527194139",
        "transport_fee": "0",
        "product_fee": "1",
        "discount": "0",
        "rmb_total_fee": ""
    }
}

各個(gè)字段的含義如表所示。

參數(shù)

說(shuō)明

ret_code

查詢(xún)結(jié)果狀態(tài)碼,0表明成功,其他表明錯(cuò)誤;

ret_msg

查詢(xún)結(jié)果出錯(cuò)信息;

input_charset

返回信息中的編碼方式;

trade_state

訂單狀態(tài),0為成功,其他為失?。?/p>

trade_mode

交易模式,1為即時(shí)到帳,其他保留;

partner

財(cái)付通商戶(hù)號(hào),即前文的partnerid;

bank_type

銀行類(lèi)型;

bank_billno

銀行訂單號(hào);

total_fee

總金額,單位為分;

fee_type

幣種,1為人民幣;

transaction_id

財(cái)付通訂單號(hào);

out_trade_no

第三方訂單號(hào);

is_split

是否分賬,false為無(wú)分賬,true為有分賬;

is_refund

是否退款,false為無(wú)退款,ture為退款;

attach

商戶(hù)數(shù)據(jù)包,即生成訂單package時(shí)商戶(hù)填入的attach;

time_end

支付完成時(shí)間;

transport_fee

物流費(fèi)用,單位為分;

product_fee

物品費(fèi)用,單位為分;

discount

折扣價(jià)格,單位為分;

rmb_total_fee

換算成人民幣之后的總金額,單位為分,一般看total_fee即可。

If there is an error in the program, it will be described in errcode and errmsg.

For more articles related to WeChat payment development order inquiry, please pay attention to the PHP Chinese website!

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72