Payment Development (6) Delivery address sharing interface, payment interface development
Keyword: pay the shipping address share
Author: Fang Times studio
Original: http://www.cnblogs.com/txw1958/p/weixin-editAddress.html
This article introduces the development process of the receiving address sharing interface under payment.
I. INTRODUCTION
Receiving address sharing, refers to the user in the browser to open the Web page, fill out the address, follow-up can be free to fill in support for quick selection, can also add and edit. This address is a user attribute and can be shared in each merchant's Web page. Support native control fill in address, address data will be passed to merchant.
Address sharing is based on the JavaScript API and can only be used in built-in browsers, and other browser calls are not valid. At the same time, 5.0 version is required to support, it is recommended to use the user agent to determine the current version number of users before calling the address interface. As an example of the iphone version, the following version of the sample information can be obtained via useragent: "mozilla/5.0 (iphone; CPU iphone OS 5_1_1 like Mac os X) applewebkit/534.46 (khtml,like Geocko) mobile/9b206micromessenger/5.0 "where 5.0 is the user-installed version number, The merchant can determine if the version number is greater than or equal to 5.0.
Address format
The data fields used for address sharing include:
- Name of consignee
- District, provincial level three
- Detailed Address
- Zip
- Contact phone
Among them, the region corresponds to the GB three regional code, such as "Guangdong Province-Guangzhou-Tianhe District", the corresponding ZIP code is 510630. Details Reference Link: http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201401/t20140116_501070.html
Two. OAuth2.0 Authorization
Before you get the delivery address, you need to call the login authorization interface to get the OAuth2.0 access Token once. So need to do authorization, this authorization is not pop-up confirmation box.
The essence is in the user access
http://www.fangbei.org/wxpay/js_api_call.php
When you jump to
HTTPS://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8888888888888888&redirect_uri= http://www.fangbei.org/wxpay/js_api_call.php&response_type=code&scope=snsapi_base&state=STATE# Wechat_redirect
In order to obtain the code parameter, and according to code to obtain authorization Access_token and OpenID, this access token will be used for the delivery address sharing interface.
The detailed process of its implementation can be referred to the public Platform Development (OAUTH2.0) website authorization
Second, get the random string
Here's how to generate random strings
Iii. Generating signatures
The fields that participate in the addrsign signature include: appId, url (page URL that calls the JavaScript API), timestamp, NONCESTR, Accesstoken
Use the format of the URL key-value pair (that is, key1=value1&key2=value2 ...) after all the signature parameters are sorted from small to large (dictionary order) by the ASCII code of the field name. ) stitching into string string1.
It is important to note that all parameter names in the signature process are lowercase characters, such as AppID after the sort string is AppID;
For the signature algorithm of string1, the field name and field values are used as original values, and no URL escapes. The specific signature algorithm is Addrsign = SHA1 (string1). Here is a concrete example of generating a addrsign as follows:
appid=wx17ef1eaef46752cburl=http://open.weixin.qq.com/timestamp=1384841012 noncestr=123456accesstoken= Oezxceiibsksxw0eoyliebfk1b8vbntfwalj5g6amgzhaqzwk4euesksn78qd5plsfqtumdgmhajvm5qdm24w8x3tj18kz5mhmkuci3rolm7qggh1cenchejw Qo8s5l3vvsfadawhfxuulmgh5fra
I: After a process key-value pairs are sorted, the string1 are:
accesstoken= Oezxceiibsksxw0eoyliebfk1b8vbntfwalj5g6amgzhaqzwk4euesksn78qd5plsfqtumdgmhajvm5qdm24w8x3tj18kz5mhmkuci3rolm7qggh1cenchejw qo8s5l3vvsfadawhfxuulmgh5fra&appid=wx17ef1eaef46752cb&noncestr=123456×tamp= 1384841012&url=http://open.weixin.qq.com/?code=code&state=state
II: After the B process signature can be obtained:
ADDRSIGN=SHA1 (accesstoken= Oezxceiibsksxw0eoyliebfk1b8vbntfwalj5g6amgzhaqzwk4euesksn78qd5plsfqtumdgmhajvm5qdm24w8x3tj18kz5mhmkuci3rolm7qggh1cenchejw Qo8s5l3vvsfadawhfxuulmgh5fra&appid=wx17ef1eaef46752cb&noncestr=123456×tamp= 1384841012&url=http://open.weixin.qq.com/?code=code&state=state) = CA604C740945587544A9CC25E58DD090F200E6FB
The implementation code is as follows
Iv. Obtain the address of the goods receipt
Edit and get the user receipt address Editaddress interface, which is called at the front of the Web page.
Parameter list:
Parameters |
must fill | in
Description |
AppId |
Is |
Public number AppID |
Scope |
Is |
Fill in "Jsapi_address" to get edit address permission |
Signtype |
Is |
Signature method, currently only supports SHA1 |
Addrsign |
Is |
Signature, signed by each parameter to generate the signature |
TimeStamp |
Is |
Time stamp |
Noncestr |
Is |
Random string |
The calling method is as follows
Parameter returns:
return value |
Description |
Err_msg |
Edit_address:ok get Edit Receipt Address successful |
Edit_address:fail get Edit Receipt address failed |
Username |
Name of consignee |
Telnumber |
Consignee phone |
Addresspostalcode |
Zip |
Provicefirststagename |
The first level address of the national standard goods receiving address |
Addresscitysecondstagename |
The second level address of the national standard delivery address |
Addresscountiesthirdstagename |
The third level address of the national standard shipping address |
Addressdetailinfo |
Detailed delivery address information |
Nationalcode |
Delivery address Country Code |
V. Examples
http://www.bkjia.com/PHPjc/1114989.html www.bkjia.com true http://www.bkjia.com/PHPjc/1114989.html techarticle Payment Development (6) Receiving address sharing interface, payment interface development keywords: payment receipt address sharing author: Fang Times Studio Original: http://www.cnblogs.com/txw1958/ ...