E-commerce platform capability interface

The platform capabilities provided to e-commerce service providers and self-developed businesses currently include order capability interface, commodity capability interface, and event notification push (only for virtual businesses).


E-commerce service provider interface verification signature

Calling the e-commerce service provider interface requires the sign parameter to verify the signature. The generation method is: filter out the parameters of the calling interface that do not participate in the signature, sort them in ascending order according to the key name, then convert them into URL query strings (querystring), splice the e-commerce signature key ($key parameter in the example) at the end, and finally md5 the resulting string, Get the final sign value.


Parameters that do not participate in signature. The parameter names are sign, sign_ type、access_ The parameters of the token and the parameters whose parameter values are empty strings.


It should be noted that the appid parameter in the e-commerce capability interface refers to the identity of e-commerce service providers, which is different from the open platform APPKEY used to obtain authorization. The identity of e-commerce service providers, appid, is a one-to-one group with the e-commerce signature key ($key parameter in the example), which is allocated by microblog e-commerce. After the application is approved, Contact microblog e-commerce products to apply for access.


Example of signature method:

CODE:PHP
 //Here are the parameters when calling the interface $data_ list = ["goods_id"=>"371965", "appid"=> 100023, "sign_type"=>"md5"]; //This is the signature secret key of e-commerce, which can be obtained by contacting the microblog e-commerce platform $key = 'YOUR SIGN KEY'; //Start generating signatures and outputting signatures echo getSign($data_list, $key); //Obtain signature according to algorithm public static function getSign($data_list, $key, $filter_k_list = ["sign", "sign_type", "access_token",], $filter_v_list = ["",]) { //Filter parameters not participating in signature foreach ($data_list as $k => $v) { if (in_array($k, $filter_k_list, true) || in_ array($v, $filter_v_list, true)) { unset($data_list[$k]); } } //Sort ksort($data_list); //Convert to query string, pay attention to the space before and after filtering $parameter = []; foreach ($data_list as $k => $v) { $parameter[] = $k .  "=" .  trim($v); } $string = implode("&", $parameter); //Splicing key $stringKey = $string . $ key; //Perform MD5 to get the final signature $sign = md5($stringKey); return $sign; }


CODE:JAVA
 import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Set; class Sign { public static final String[] filterKeys = new String[]{"sign", "sign_type", "access_token"}; public static void main(String[] args) { Map<String, String> dataList = new HashMap<>(); //Here are the parameters when calling the interface dataList.put("goods_id", "371965"); dataList.put("appid", "100023"); dataList.put("sign_type", "md5"); //This is the signature secret key of e-commerce, which can be obtained by contacting the microblog e-commerce platform String secret = "YOUR SIGN KEY"; //Start generating signature String sign = getSign(dataList, secret); //Output Signature System.out.println(sign); } //Obtain signature according to algorithm public static String getSign(Map<String, String> dataList, String secret) { Set<String> keySet = dataList.keySet(); String[] keyArray = keySet.toArray(new String[0]); Arrays.sort(keyArray); StringBuilder sb = new StringBuilder(); String prefix = ""; for (int i = 0; i < keyArray.length; i++) { if (Arrays.asList(filterKeys).contains(keyArray[i])) { continue; } sb.append(prefix).append(keyArray[i]).append("=").append(dataList.get(keyArray[i])); prefix = "&"; } sb.append(secret); return md5(sb.toString()); } public static String md5(String input) { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] messageDigest = md.digest(input.getBytes()); BigInteger no = new BigInteger(1, messageDigest); String hashtext = no.toString(16); while (hashtext.length() < 32) { hashtext = "0" + hashtext; } return hashtext; } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } }


CODE: GO language
 package main import ( "crypto/md5" "encoding/hex" "fmt" "sort" ) func main() { //Here are the parameters when calling the interface dataList := map[string]string{"goods_id": "371965", "appid": "100023", "sign_type": "md5"} //This is the signature secret key of e-commerce, which can be obtained by contacting the microblog e-commerce platform secret := "YOUR SIGN KEY" //Start generating signature sign := getSign(dataList, secret) //Output Signature fmt. Println(sign) } //Obtain signature according to algorithm func getSign(dataList map[string]string, secret string) string { var keys []string prefix := "" str := "" //Filter parameters not participating in signature filterKList := [3]string{"sign", "sign_type", "access_token"} for k := range dataList { keys = append(keys, k) } //Sort sort.Strings(keys) //Convert to query string, pay attention to the space before and after filtering for _,  k := range keys { flag := false for _,  filterK := range filterKList { if k == filterK { flag = true break } } if ! flag { str += prefix + k + "=" + dataList[k] prefix = "&" } } //Splicing key str += secret //Perform MD5 to get the final signature h := md5.New() h.Write([]byte(str)) return hex. EncodeToString(h.Sum(nil)) }


Order capability interface

For the interface related to order business, see the interface list for details:

Interface explain
order/retailerGetSubList Get sub order list
order/retailerGetSub Get sub order details
order/retailerSearchSub Search for sub orders
order/retailerFinishSub Successful performance of merchant (only for virtual merchants)
order/retailerCloseSub The merchant failed to perform the contract (only for virtual merchants)
order/retailerAddExpress Submit Shipment
order/retailerSetReceiverInfo Modify consignee information
order/retailerSetRetailerRemark Modify merchant notes


Commodity capability interface

For the interface related to commodity business, see the interface list for details:

Interface explain
goods/online Goods on shelves
goods/offline Commodity off the shelf
goods/getGoodsInfo Query product information according to product ID
goods/getGoodsList Query product information according to product update time
goods/getShopInfo Get merchant information
goods/getAllCateData Get merchant category
goods/getDraftExtendField Get the extended category of goods
goods/setGoodsInfo Modify Item
goods/setGoodsInfoPin Use PIN code as identification to modify goods
goods/setGoodsStockSkuid Use SKU ID as identification to modify item inventory
goods/setGoodsStockPin Use PIN code as identification to modify commodity inventory
goods/setGoodsPriceSkuid Use SKU ID as identification to modify commodity price
goods/setGoodsPricePin Use PIN code as identification to modify product price
goods/getGoodsVerifyInfo Get the details of the second review of goods
goods/applyGoodsVerify Submit the product for secondary review
goods/revertGoodsVerify Cancel the second review of goods
goods/delGoodsVerify Delete the second approval of goods
goods/getDraftList Get the list of product drafts
goods/getDraftInfo Get product draft details
goods/addDraft Create item to draft
goods/setDraftInfo Edit Product Draft
goods/delDrafts Delete Product Draft
goods/applyDraftVerify Submit product draft for review
goods/revertDraftVerify Withdraw the approval of product draft
goods/getTplList Get the list of freight templates
goods/getTplInfo Get details of freight template
goods/addTpl Add freight template
goods/updateTpl Update freight template
goods/delTpl Delete freight template


Event notification push

Event notification refers to the notification of connected businesses by the microblog e-commerce platform. Currently, it is mainly order event notification, which is limited to virtual businesses.



appendix

Various code comparison tables required in the order capability interface.






Document update time: 2023-02-06