WeChat public platform develops WeChat payment customs declaration interface

高洛峰
Release: 2017-03-08 16:49:05
Original
3976 people have browsed it

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.

1. Customs declaration interface API


Interface address

https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclareorder
Copy after login

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).

##Field nameVariable nameRequiredTypeExample valueDescriptionSignaturesign is String(32)C380BEC2BFD727A4B6845133519F3AD6Signature, see signature generation algorithmPublic account IDappidisString(32)wxd678efh567hg6787The public account ID assigned by WeChatBusiness numbermch_id is String(32)1230000109The merchant number assigned by WeChat paymentMerchant order numberout_trade_no isString(32)20150806125346The internal order number of the merchant systemWeChat payment order numbertransaction_id isString(28)1000320306201511078440737890 The order number customscustoms returned by WeChat Pay is String(32)SHANGHAI Merchant Customs Registration Numbermch_customs_noNoString(32)123456The registration number of the merchant registered at the customs, customs is not NO, this parameter is requiredTariffdutyNo Int888Tariff, in cents
NO No need to report to customs

GUANGZHOU Guangzhou

HANGZHOU Hangzhou

NINGBO Ningbo

ZHENGZHOU_BS Zhengzhou (Bonded Logistics Center)

CHONGQING Chongqing

XIAN Xi'an

SHANGHAI Shanghai

ZHENGZHOU_ZH Zhengzhou (Comprehensive Bonded Area)

SHENZHEN Shenzhen

The following fields must be passed when splitting an order or re-declaring customs

Field nameVariable nameRequiredTypeExample value DescriptionMerchant sub-order numbersub_order_noNoString (32)20150806125346 Merchant sub-order number, if there is a split order, currencyfee_typeNoString(3)CNYThe currency used when paying WeChat payment orders. Currently, only RMB CNY is supported. If there is an order split, Must pass. Amount payableorder_feeNoInt888Sub-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. Logistics feetransport_feeNoInt888Logistics fee , divided into units. If there is any split order, it must be transmitted. Product priceproduct_feeNoInt888 Product fee , divided into units. If there is any split order, it must be transmitted.

The following fields are required when WeChat lacks user information. If the merchant has uploaded user information, the information uploaded by the merchant shall prevail.

##Field nameCertificate typeCertificate numberName

举例如下:

<xml>
   <appid>wx2421b1c4370ec43b</appid>
   <customs>ZHENGZHOU_BS</customs>
   <mch_customs_no>D00411</mch_customs_no>
   <mch_id>1262544101</mch_id>
   <order_fee>13110</order_fee>
   <out_trade_no>15112496832609</out_trade_no>
   <product_fee>13110</product_fee>
   <sign>8FF6CEF879FB9555CD580222E671E9D4</sign>
   <transaction_id>1006930610201511241751403478</transaction_id>
   <transport_fee>0</transport_fee>
   <fee_type>CNY</fee_type>
   <sub_order_no>15112496832609001</sub_order_no>
   </xml>
Copy after login

注:参数值用XML转义即可,CDATA标签用于说明数据不被XML解析器解析。


应答参数列表


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_codeString(16)SUCCESS

SUCCESS/FAIL

此字段是通信标识,非交易标识,交易是否成功需要查看result_code来判断

返回信息return_msgString(128)签名失败

返回信息,如非空,为错误原因

签名失败

参数格式校验错误

以下字段在return_code为SUCCESS的时候有返回

字段名变量名必填类型示例值描述
签名类型sign_typeString(32)MD5暂只支持MD5
签名signString(32)C380BEC2BFD727A4B6845133519F3AD6签名,详见签名生成算法
公众账号IDappidString(32)wxd678efh567hg6787微信分配的公众账号ID
商户号mch_idString(32)1230000109微信支付分配的商户号
业务结果result_codeString(16)SUCCESSSUCCESS/FAIL
错误代码err_codeString(32)SYSTEMERROR详细参见错误列表
错误代码描述err_code_desString(128)系统错误错误返回的信息描述

以下字段在return_code 和result_code都为SUCCESS的时候有返回

字段名变量名必填类型示例值描述
状态码stateString(2)UNDECLARED

状态码

UNDECLARED -- 未申报

SUBMITTED -- 申报已提交(订单已经送海关,商户重新申报,并且海关还有修改接口,那么记录的状态会是这个)

PROCESSING -- 申报中

SUCCESS -- 申报成功

FAIL-- 申报失败

EXCEPT --海关接口异常

微信支付订单号transaction_idString(28)1000320306201511078440737890微信支付返回的订单号
商户订单号out_trade_noString(32)20150806125346商户系统内部的订单号
商户子订单号sub_order_noString(32)20150806125346商户子订单号,如有拆单则必传
微信子订单号sub_order_idString(32)20150806125346微信子订单号
最后更新时间modify_timeString(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_EXISTAppId未设置(sub_order_no)appid为必传字段请检查appid是否正确
MCHID_NOT_EXIST商户号(mch_id)未设置MCH_ID为必传字段请检查mch_id是否正确
AUTHORITY_NOT_FOUND未开通自助清关功能须先开通自助清关功能才可成功调用接口请检查是否已开通自助清关功能,开通路径:微信支付商户平台-产品中心-自助清关中申请开通。
NO_AUTH无权限未获得此接口的调用权限请检查当前商户号是否已获得此接口的调用权限

二、SDK实现

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"
}
Copy after login

接收到的数据如下

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"
}
Copy after login

 

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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template