


WeChat public platform develops WeChat payment customs declaration interface
Mar 08, 2017 pm 04:49 PMThis article introduces the development process of the customs declaration interface under WeChat payment. WeChat Customs Declaration is used by merchants to submit order information required by customs.
1. Customs declaration interface API
Interface address
https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclareorder
Do you need a certificate?
No.
Request method: post Data format: xml Signature method: MD5
Note: The amount of the merchant's order number is subject to what is recorded in the payment system. There is no need to upload. If there is a sub-order number, the amount payable, logistics fee, and product price of the sub-order must be uploaded (amount payable = logistics fee + product price).
Variable name | Required | Type | Example value | Description | |
---|---|---|---|---|---|
sign | is | String(32) | C380BEC2BFD727A4B6845133519F3AD6 | Signature, see signature generation algorithm | |
appid | is | String(32) | wxd678efh567hg6787 | The public account ID assigned by WeChat | |
mch_id | is | String(32) | 1230000109 | The merchant number assigned by WeChat payment | |
out_trade_no | is | String(32) | 20150806125346 | The internal order number of the merchant system | |
transaction_id | is | String(28) | 1000320306201511078440737890 | The order number | |
customs | returned by WeChat Pay is | String(32) | SHANGHAI | NO No need to report to customsGUANGZHOU GuangzhouHANGZHOU HangzhouNINGBO NingboZHENGZHOU_BS Zhengzhou (Bonded Logistics Center) CHONGQING ChongqingXIAN Xi'anSHANGHAI ShanghaiZHENGZHOU_ZH Zhengzhou (Comprehensive Bonded Area)SHENZHEN Shenzhen | |
mch_customs_no | No | String(32) | 123456 | The registration number of the merchant registered at the customs, customs is not NO, this parameter is required | |
duty | No | Int | 888 | Tariff, in cents |
Variable name | Required | Type | Example value | Description | |
---|---|---|---|---|---|
sub_order_no | No | String (32) | 20150806125346 | Merchant sub-order number, if there is a split order, | |
fee_type | No | String(3) | CNY | The currency used when paying WeChat payment orders. Currently, only RMB CNY is supported. If there is an order split, Must pass. | |
order_fee | No | Int | 888 | Sub-order The amount, in cents, cannot exceed the original order amount, order_fee=transport_fee+product_fee (amount payable = logistics fee + product price), if there is a split order, it must be sent. | |
transport_fee | No | Int | 888 | Logistics fee , divided into units. If there is any split order, it must be transmitted. | |
product_fee | No | Int | 888 | Product fee , divided into units. If there is any split order, it must be transmitted. |
Variable name | Required | Type | Example value | Description | |
---|---|---|---|---|---|
cert_type | No | String(32) | IDCARD | Currently only supports ID cards. This parameter refers to user information. If the merchant has user information, it can be submitted. The system will be based on the data uploaded by the merchant. , perform customs clearance reporting; | |
cert_id | No | String(64) | 330821198809085211 | ID number, this parameter refers to user information. If the merchant has user information, it can be uploaded. The system will take the data uploaded by the merchant as the basis for customs clearance reporting; | |
name | No | String(64) | 張三 | User name, the Parameters refer to user information. If the merchant has user information, it can be submitted. The system will use the data uploaded by the merchant as the basis for customs clearance reporting; |
字段名 | 變量名 | 必填 | 類(lèi)型 | 示例值 | 說(shuō)明 |
---|---|---|---|---|---|
返回狀態(tài)碼 | return_code | 是 | String(16) | SUCCESS | SUCCESS/FAIL 此字段是通信標(biāo)識(shí),非交易標(biāo)識(shí),交易是否成功需要查看result_code來(lái)判斷 |
返回信息 | return_msg | 否 | String(128) | 簽名失敗 | 返回信息,如非空,為錯(cuò)誤原因 簽名失敗 參數(shù)格式校驗(yàn)錯(cuò)誤 |
以下字段在return_code為SUCCESS的時(shí)候有返回
字段名 | 變量名 | 必填 | 類(lèi)型 | 示例值 | 描述 |
---|---|---|---|---|---|
簽名類(lèi)型 | sign_type | 是 | String(32) | MD5 | 暫只支持MD5 |
簽名 | sign | 是 | String(32) | C380BEC2BFD727A4B6845133519F3AD6 | 簽名,詳見(jiàn)簽名生成算法 |
公眾賬號(hào)ID | appid | 是 | String(32) | wxd678efh567hg6787 | 微信分配的公眾賬號(hào)ID |
商戶號(hào) | mch_id | 是 | String(32) | 1230000109 | 微信支付分配的商戶號(hào) |
業(yè)務(wù)結(jié)果 | result_code | 是 | String(16) | SUCCESS | SUCCESS/FAIL |
錯(cuò)誤代碼 | err_code | 否 | String(32) | SYSTEMERROR | 詳細(xì)參見(jiàn)錯(cuò)誤列表 |
錯(cuò)誤代碼描述 | err_code_des | 否 | String(128) | 系統(tǒng)錯(cuò)誤 | 錯(cuò)誤返回的信息描述 |
以下字段在return_code 和result_code都為SUCCESS的時(shí)候有返回
字段名 | 變量名 | 必填 | 類(lèi)型 | 示例值 | 描述 |
---|---|---|---|---|---|
狀態(tài)碼 | state | 是 | String(2) | UNDECLARED | 狀態(tài)碼 UNDECLARED -- 未申報(bào) SUBMITTED -- 申報(bào)已提交(訂單已經(jīng)送海關(guān),商戶重新申報(bào),并且海關(guān)還有修改接口,那么記錄的狀態(tài)會(huì)是這個(gè)) PROCESSING -- 申報(bào)中 SUCCESS -- 申報(bào)成功 FAIL-- 申報(bào)失敗 EXCEPT --海關(guān)接口異常 |
微信支付訂單號(hào) | transaction_id | 是 | String(28) | 1000320306201511078440737890 | 微信支付返回的訂單號(hào) |
商戶訂單號(hào) | out_trade_no | 是 | String(32) | 20150806125346 | 商戶系統(tǒng)內(nèi)部的訂單號(hào) |
商戶子訂單號(hào) | sub_order_no | 否 | String(32) | 20150806125346 | 商戶子訂單號(hào),如有拆單則必傳 |
微信子訂單號(hào) | sub_order_id | 否 | String(32) | 20150806125346 | 微信子訂單號(hào) |
最后更新時(shí)間 | modify_time | 是 | String(14) | 20091227091010 | 最后更新時(shí)間,格式為yyyyMMddhhmmss,如2009年12月27日9點(diǎn)10分10秒表示為20091227091010。時(shí)區(qū)為GMT+8 beijing。該時(shí)間取自微信服務(wù)器 |
錯(cuò)誤碼
名稱(chēng) | 描述 | 原因 | 解決方案 |
---|---|---|---|
132011004 | 參數(shù)錯(cuò)誤 | 報(bào)關(guān)時(shí)僅傳入訂單號(hào),不傳入子訂單號(hào)(sub_order_no)時(shí),不能填費(fèi)用信息,須以支付系統(tǒng)中的值為準(zhǔn) | 請(qǐng)檢查參數(shù)是否都正確 |
132021028 | 交易幣種與商戶結(jié)算幣種不一致】 | 報(bào)關(guān)時(shí)傳入子訂單號(hào)(sub_order_no)時(shí),幣種參數(shù)(fee_type)必填 | 請(qǐng)檢查所傳幣種參數(shù)(fee_type)是否為空 |
MCHID_NOT_SET | 商戶號(hào)未設(shè)置 | 商戶號(hào)為必傳參數(shù),請(qǐng)求時(shí)必傳 | 請(qǐng)檢查商戶號(hào)是否為空 |
MCHID_INVALID_LENGTH | 無(wú)效的商戶號(hào)長(zhǎng)度 | 報(bào)關(guān)接口只支持12開(kāi)頭10位數(shù)字的商戶號(hào) | 請(qǐng)檢查商戶號(hào)長(zhǎng)度是否為10位 |
CUSTOMSCONFIG_NOT_SET | 海關(guān)配置未設(shè)置 | 報(bào)關(guān)接口需要商戶已配置過(guò)海關(guān)信息才可以訪問(wèn) | 請(qǐng)參照上文中的海關(guān)備案指引,進(jìn)行海關(guān)信息報(bào)備 |
FEETYPE_NOT_SET | 幣種類(lèi)型未設(shè)置 | 拆單情況下,幣種為必填參數(shù) | 請(qǐng)檢查fee_type是否為空 |
OUTTRADENO_NOT_SET | 商戶訂單號(hào)(out_trade_no)未設(shè)置 | 商戶訂單號(hào)為必傳參數(shù) | 請(qǐng)檢查商戶訂單號(hào)(out_trade_no)是否為空 |
TRANSACTION_ID_NOT_SET | 微信訂單號(hào)(transaction_id)未設(shè)置 | 微信訂單號(hào)(transaction_id)為必傳參數(shù) | 請(qǐng)檢查微信訂單號(hào)(transaction_id)是否為空 |
INVALID_TRANSACTION_ID | 無(wú)效的微信訂單號(hào)長(zhǎng)度 | 微信訂單號(hào)為28位數(shù)字,請(qǐng)確保長(zhǎng)度一致 | 請(qǐng)檢查微信訂單號(hào)(transaction_id)是否正確 |
CUSTOMS_NOT_SET | 海關(guān)信息未設(shè)置 | 海關(guān)信息為必傳字段 | 請(qǐng)檢查海關(guān)信息是否為空 |
CHCUSTOMSNO_NOT_SET | 海關(guān)備案號(hào)未設(shè)置 | 海關(guān)備案號(hào)為必傳字段 | 請(qǐng)檢查備案號(hào)是否為空 |
INVALID_MCHCUSTOMSNO | 無(wú)效的海關(guān)備案號(hào)長(zhǎng)度 | 海關(guān)備案號(hào)一般為6位字符串 | 請(qǐng)檢查海關(guān)備案號(hào)是否正確 |
PAYFEE_NOT_MATCH | 金額不匹配 | 報(bào)關(guān)的訂單金額必須和支付的金額一致 | 請(qǐng)檢查報(bào)關(guān)訂單的金額是否正確 |
INVALID_SUBORDER_NO | 無(wú)效的子訂單號(hào)長(zhǎng)度(sub_order_no) | 子訂單號(hào)要求是32位以內(nèi)的字符串 | 請(qǐng)檢查子訂單號(hào)長(zhǎng)度是否正確 |
APPID_NOT_EXIST | AppId未設(shè)置(sub_order_no) | appid為必傳字段 | 請(qǐng)檢查appid是否正確 |
MCHID_NOT_EXIST | 商戶號(hào)(mch_id)未設(shè)置 | MCH_ID為必傳字段 | 請(qǐng)檢查mch_id是否正確 |
AUTHORITY_NOT_FOUND | 未開(kāi)通自助清關(guān)功能 | 須先開(kāi)通自助清關(guān)功能才可成功調(diào)用接口 | 請(qǐng)檢查是否已開(kāi)通自助清關(guān)功能,開(kāi)通路徑:微信支付商戶平臺(tái)-產(chǎn)品中心-自助清關(guān)中申請(qǐng)開(kāi)通。 |
NO_AUTH | 無(wú)權(quán)限 | 未獲得此接口的調(diào)用權(quán)限 | 請(qǐng)檢查當(dāng)前商戶號(hào)是否已獲得此接口的調(diào)用權(quán)限 |
二、SDK實(shí)現(xiàn)
sdk定義
三、調(diào)用方式
三、返回結(jié)果
發(fā)送數(shù)據(jù)如下
array(6) { ["appid"]=> string(18) "wxa8092dd025e45123" ["mch_id"]=> string(10) "1238298123" ["out_trade_no"]=> string(22) "SH20160824095750086988" ["transaction_id"]=> string(28) "4006742001201608242098415582" ["customs"]=> string(6) "NINGBO" ["mch_customs_no"]=> string(10) "3302461123" }
接收到的數(shù)據(jù)如下
array(12) { ["return_code"]=> string(7) "SUCCESS" ["return_msg"]=> string(6) "成功" ["sign"]=> string(32) "91EFCEEAAD4322F331F3F63C4D8F1279" ["appid"]=> string(18) "wxa8092dd025e45123" ["mch_id"]=> string(10) "1238298123" ["result_code"]=> string(7) "SUCCESS" ["err_code"]=> string(1) "0" ["err_code_des"]=> string(2) "OK" ["state"]=> string(9) "SUBMITTED" ["transaction_id"]=> string(28) "4006742001201608242098415582" ["out_trade_no"]=> string(22) "SH20160824095750086988" ["modify_time"]=> string(14) "20160825111049" }
?
The above is the detailed content of WeChat public platform develops WeChat payment customs declaration interface. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP is an open source scripting language that is widely used in web development and server-side programming, especially in WeChat development. Today, more and more companies and developers are starting to use PHP for WeChat development because it has become a truly easy-to-learn and easy-to-use development language. In WeChat development, message encryption and decryption are a very important issue because they involve data security. For messages without encryption and decryption methods, hackers can easily obtain the data, posing a threat to users.

In the development of WeChat public accounts, the voting function is often used. The voting function is a great way for users to quickly participate in interactions, and it is also an important tool for holding events and surveying opinions. This article will introduce you how to use PHP to implement WeChat voting function. Obtain the authorization of the WeChat official account. First, you need to obtain the authorization of the WeChat official account. On the WeChat public platform, you need to configure the API address of the WeChat public account, the official account, and the token corresponding to the public account. In the process of our development using PHP language, we need to use the PH officially provided by WeChat

With the popularity of WeChat, more and more companies are beginning to use it as a marketing tool. The WeChat group messaging function is one of the important means for enterprises to conduct WeChat marketing. However, if you only rely on manual sending, it is an extremely time-consuming and laborious task for marketers. Therefore, it is particularly important to develop a WeChat mass messaging tool. This article will introduce how to use PHP to develop WeChat mass messaging tools. 1. Preparation work To develop WeChat mass messaging tools, we need to master the following technical points: Basic knowledge of PHP WeChat public platform development Development tools: Sub

WeChat is currently one of the social platforms with the largest user base in the world. With the popularity of mobile Internet, more and more companies are beginning to realize the importance of WeChat marketing. When conducting WeChat marketing, customer service is a crucial part. In order to better manage the customer service chat window, we can use PHP language for WeChat development. 1. Introduction to PHP WeChat development PHP is an open source server-side scripting language that is widely used in the field of Web development. Combined with the development interface provided by WeChat public platform, we can use PHP language to conduct WeChat

In the development of WeChat public accounts, user tag management is a very important function, which allows developers to better understand and manage their users. This article will introduce how to use PHP to implement the WeChat user tag management function. 1. Obtain the openid of the WeChat user. Before using the WeChat user tag management function, we first need to obtain the user's openid. In the development of WeChat public accounts, it is a common practice to obtain openid through user authorization. After the user authorization is completed, we can obtain the user through the following code

As WeChat becomes an increasingly important communication tool in people's lives, its agile messaging function is quickly favored by a large number of enterprises and individuals. For enterprises, developing WeChat into a marketing platform has become a trend, and the importance of WeChat development has gradually become more prominent. Among them, the group sending function is even more widely used. So, as a PHP programmer, how to implement group message sending records? The following will give you a brief introduction. 1. Understand the development knowledge related to WeChat public accounts. Before understanding how to implement group message sending records, I

How to use PHP to develop WeChat public accounts WeChat public accounts have become an important channel for promotion and interaction for many companies, and PHP, as a commonly used Web language, can also be used to develop WeChat public accounts. This article will introduce the specific steps to use PHP to develop WeChat public accounts. Step 1: Obtain the developer account of the WeChat official account. Before starting the development of the WeChat official account, you need to apply for a developer account of the WeChat official account. For the specific registration process, please refer to the official website of WeChat public platform

With the development of the Internet and mobile smart devices, WeChat has become an indispensable part of the social and marketing fields. In this increasingly digital era, how to use PHP for WeChat development has become the focus of many developers. This article mainly introduces the relevant knowledge points on how to use PHP for WeChat development, as well as some of the tips and precautions. 1. Development environment preparation Before developing WeChat, you first need to prepare the corresponding development environment. Specifically, you need to install the PHP operating environment and the WeChat public platform
