This 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.
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; |
字段名 | 变量名 | 必填 | 类型 | 示例值 | 说明 |
---|---|---|---|---|---|
返回状态码 | return_code | 是 | String(16) | SUCCESS | SUCCESS/FAIL 此字段是通信标识,非交易标识,交易是否成功需要查看result_code来判断 |
返回信息 | return_msg | 否 | String(128) | 签名失败 | 返回信息,如非空,为错误原因 签名失败 参数格式校验错误 |
以下字段在return_code为SUCCESS的时候有返回
字段名 | 变量名 | 必填 | 类型 | 示例值 | 描述 |
---|---|---|---|---|---|
签名类型 | sign_type | 是 | String(32) | MD5 | 暂只支持MD5 |
签名 | sign | 是 | String(32) | C380BEC2BFD727A4B6845133519F3AD6 | 签名,详见签名生成算法 |
公众账号ID | appid | 是 | String(32) | wxd678efh567hg6787 | 微信分配的公众账号ID |
商户号 | mch_id | 是 | String(32) | 1230000109 | 微信支付分配的商户号 |
业务结果 | result_code | 是 | String(16) | SUCCESS | SUCCESS/FAIL |
错误代码 | err_code | 否 | String(32) | SYSTEMERROR | 详细参见错误列表 |
错误代码描述 | err_code_des | 否 | String(128) | 系统错误 | 错误返回的信息描述 |
以下字段在return_code 和result_code都为SUCCESS的时候有返回
字段名 | 变量名 | 必填 | 类型 | 示例值 | 描述 |
---|---|---|---|---|---|
状态码 | state | 是 | String(2) | UNDECLARED | 状态码 UNDECLARED -- 未申报 SUBMITTED -- 申报已提交(订单已经送海关,商户重新申报,并且海关还有修改接口,那么记录的状态会是这个) PROCESSING -- 申报中 SUCCESS -- 申报成功 FAIL-- 申报失败 EXCEPT --海关接口异常 |
微信支付订单号 | transaction_id | 是 | String(28) | 1000320306201511078440737890 | 微信支付返回的订单号 |
商户订单号 | out_trade_no | 是 | String(32) | 20150806125346 | 商户系统内部的订单号 |
商户子订单号 | sub_order_no | 否 | String(32) | 20150806125346 | 商户子订单号,如有拆单则必传 |
微信子订单号 | sub_order_id | 否 | String(32) | 20150806125346 | 微信子订单号 |
最后更新时间 | modify_time | 是 | String(14) | 20091227091010 | 最后更新时间,格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。时区为GMT+8 beijing。该时间取自微信服务器 |
名称 | 描述 | 原因 | 解决方案 |
---|---|---|---|
132011004 | 参数错误 | 报关时仅传入订单号,不传入子订单号(sub_order_no)时,不能填费用信息,须以支付系统中的值为准 | 请检查参数是否都正确 |
132021028 | 交易币种与商户结算币种不一致】 | 报关时传入子订单号(sub_order_no)时,币种参数(fee_type)必填 | 请检查所传币种参数(fee_type)是否为空 |
MCHID_NOT_SET | 商户号未设置 | 商户号为必传参数,请求时必传 | 请检查商户号是否为空 |
MCHID_INVALID_LENGTH | 无效的商户号长度 | 报关接口只支持12开头10位数字的商户号 | 请检查商户号长度是否为10位 |
CUSTOMSCONFIG_NOT_SET | 海关配置未设置 | 报关接口需要商户已配置过海关信息才可以访问 | 请参照上文中的海关备案指引,进行海关信息报备 |
FEETYPE_NOT_SET | 币种类型未设置 | 拆单情况下,币种为必填参数 | 请检查fee_type是否为空 |
OUTTRADENO_NOT_SET | 商户订单号(out_trade_no)未设置 | 商户订单号为必传参数 | 请检查商户订单号(out_trade_no)是否为空 |
TRANSACTION_ID_NOT_SET | 微信订单号(transaction_id)未设置 | 微信订单号(transaction_id)为必传参数 | 请检查微信订单号(transaction_id)是否为空 |
INVALID_TRANSACTION_ID | 无效的微信订单号长度 | 微信订单号为28位数字,请确保长度一致 | 请检查微信订单号(transaction_id)是否正确 |
CUSTOMS_NOT_SET | 海关信息未设置 | 海关信息为必传字段 | 请检查海关信息是否为空 |
CHCUSTOMSNO_NOT_SET | 海关备案号未设置 | 海关备案号为必传字段 | 请检查备案号是否为空 |
INVALID_MCHCUSTOMSNO | 无效的海关备案号长度 | 海关备案号一般为6位字符串 | 请检查海关备案号是否正确 |
PAYFEE_NOT_MATCH | 金额不匹配 | 报关的订单金额必须和支付的金额一致 | 请检查报关订单的金额是否正确 |
INVALID_SUBORDER_NO | 无效的子订单号长度(sub_order_no) | 子订单号要求是32位以内的字符串 | 请检查子订单号长度是否正确 |
APPID_NOT_EXIST | AppId未设置(sub_order_no) | appid为必传字段 | 请检查appid是否正确 |
MCHID_NOT_EXIST | 商户号(mch_id)未设置 | MCH_ID为必传字段 | 请检查mch_id是否正确 |
AUTHORITY_NOT_FOUND | 未开通自助清关功能 | 须先开通自助清关功能才可成功调用接口 | 请检查是否已开通自助清关功能,开通路径:微信支付商户平台-产品中心-自助清关中申请开通。 |
NO_AUTH | 无权限 | 未获得此接口的调用权限 | 请检查当前商户号是否已获得此接口的调用权限 |
sdk定义
发送数据如下
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" }
接收到的数据如下
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!