Home  >  Article  >  WeChat Applet  >  WeChat public platform develops WeChat payment customs declaration interface

WeChat public platform develops WeChat payment customs declaration interface

高洛峰
高洛峰Original
2017-03-08 16:49:053979browse

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

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>

注:参数值用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_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实现

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!

Statement:
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