# WeChat Non-tax payment

# 1 Business Dxplaination

# 1.1 Concept introduction

Non-tax income: Financial funds obtained from public service provided by governments and public service units at all levels. Examples include: fees for entry and exit, identity cards, etc., forfeiture of income by traffic police, business and industry, prices, and tourist tickets for municipal parks and national scenic spots. Take Guangzhou as an example, last year there were 10 million pen, more than 100 billion revenue. In 2016, local non-tax revenue reached 6 trillion yuan and central non-tax receipts reached 400 billion yuan. Remittance collection mode: Implementing a "two line" of revenue and expenditure, a unit can in principle only open one special account of income and one special account for expenditure. A special account of income can only receive and cannot expend, except for financial deduction; Expenditure accounts can only be spent and cannot be received except for financially appropriated expenditures. Units are not allowed to have income transition accounts, and taxable non-tax income is paid directly into the corresponding government non-tax-income fiscal special account, and a special fiscal account is opened in a designated proxy bank, and non-tax tax income is implemented "by unit billing, bank receipt, real-time inventory (or special account)."

# 1.2 The current difficulties

Collection mode: After completing the transaction on-site, you must go to another window to pay the fee, and only swipe cards are accepted, or go to the bank to pay the payment. The vast majority of public services online are only accessible and cannot be paid for.Or even if the implementation of the process, but also after the completion of the process, to other Service Account or line payment. Information interaction: In addition to special collection methods, the need for business information interaction requires business departments to connect with banks, which is very costly for banks and business departments. For the above reasons, the improvement of service delivery capacity in the field of public services has been seriously constrained.

# 1.3 Solving the problem

We will build a non-tax platform to establish and simplify connectivity between business units and non-tax payments between finance and banks.Connect banks' non-tax accounts to WeChat After payment, establish a flexible income account selection mechanism, build a standardized information transmission API interface, facilitate access for various business departments, and solve the core problem that limits the closed-loop development of public platform services.

# 2 Character Dxplaination

# 2.1 bank

Banks, primarily as payment channels. After the user makes a payment, the fee will be transferred to the bank's merchant number, and the non-tax platform will invoke the interface provided by the bank to notify the payment status of the order.WeChat Payments will be paid to the corresponding bank account at regular intervals (T + 1).

# 2.2 finance

The main task of the fiscal role is to record the status of the bill of contributions. After a user makes a payment, the non-tax platform will invoke the interface provided by the Ministry of Finance to notify the payment status of the payment order. The status of all bills of contributions is based on the status of financial records.

In some areas, banks may play a financial role. For example, in some local public finance projects in Guangdong, China Construction Bank collects fees and records bills of payment. You can refer to the bank direct connection model in the Access Mode explaination.

# 2.3 Bureau of Administrative Affairs

The commission office (i.e. the business party) can invoke the order placement interface provided by the non-tax platform to place orders for users.

# 3 Dxplaination of Access Mode

This section briefly describes the three modes of access for non-tax payments in WeChat. Later, we will detail the information flow and interface content of the three modes (business process explaination, other scenario specifics, interface details).

# 3.1 The bank-connected model

Non-tax payments are bridged by banks to connect the finances and open up a mode of information flow. This applies to cases where local finances do not provide integrated access or where local financial resources for development are inadequate. Time series of front and back-office processes for non-tax payments in the Bank Connect model

# 3.2 The Fiscal Linkage Model

Non-tax payments are directly linked to the fiscal system, opening up the mode of information flow. It applies to situations where local financial access is integrated and local financial development capacity is strong. Time series of front and back-office processes for non-tax payments in the fiscally connected model

# 3.3 The Business Connected Model

Non-tax payments are based on the information receivable by the business unit, which crosses the bridge to the financial system to open the information flow. Applicable to cases where local business units are not directly connected to the financial system. Time series of front and back office processes for non-tax payments in the business-connected model

# 4.1 Information that the accessor needs to prepare

# 4.1.1 APPID and APPSECRET of Service Account

  1. APPID and APPSECRET of Service Account are mainly used to obtain access_token.Best practices for the use of access_token can be found in getAccessToken
  2. Developers need to provide Service Account APPID to WeChat non-tax payers to configure interface permissions.If you have two service numbers for the test environment and the official environment, please provide them separately.

# 4.1.2 WeChat Web Page Authorization

With WeChat web authorization, Service Account can obtain the user's openid.OpenID is the unique identity of the user under the service number.

1. Set up web authorization to callback domain names

  1. Before WeChat Service Account requests user web page authorization,Developers need to first go to the "Development - Interface Rights - Web Services - Web Accounts - Web Authorisation for Basic User Information" configuration option in the public platform's official website and modify the authorization callback domain name.Note that this is the domain name (a character string), not URL, so do not prefix http://;

  2. The domain name configuration specification is the full domain name, such as the domain name that requires web page authorization is:www.qq.com,Configure the next page for this domain name " http://www.qq.com/music.html ","http://www.qq.com/login.html " OAuth2.0 authentication is possible. but " http://pay.qq.com "," http://music.qq.com, " http://qq.com " OAuth2.0 authentication cannot be performed.

2. The process of web page authorization

  1. Guide the user to the authorization page to agree to the authorization and get the code

  2. Exchange code for web authorisationaccess_token(Different fromaccess_tokenin basic support)

  3. If necessary, developers can refresh the page licenseaccess_tokento avoid expiration

  4. Web authorizingaccess_tokenand openid to obtain user basic information (supportsUnionID]]mechanisms)

For more information on WeChat web page authorization, please see WeChat web authorization.

# 4.1.3 Notification Interface for Payment Results

The payment result notification interface is used to receive payment status for bills of contributions.For more details, seeNotification of Payment Result.

Please provide the payment notification interface of the test environment and the formal environment to the docking person of WeChat for non-tax payment for configuration.

# 4.1.4 Interface for querying receivable information

The development of a banking / finance role requires the provision of an inquiry interface for information receivable.For more information, see the section onQuery for Receivable Information.

Please provide the payment notification interface of the test environment and the formal environment to the docking person of WeChat for non-tax payment for configuration.

# 4.1.5 The IP address of the call refund interface

WeChat The refund interface provided by non-tax payments has an IP limit, and the caller needs to provide their own IP list.

Developers will be asked to test environment and formal environment of the refund IP provided to WeChat non-tax payment docking person configuration.

# 4.2 Public test account resources

# 4.2.1 Test merchant number

WeChat Non-tax payment public test merchant number is1900016021.

The orders tested were all paid to this merchant number, which can be used to download the corresponding statement.

# 4.2.2 Test Bank ID

Test_bank_id is a special test bank ID for WeChat non-tax payments.

This bank ID can test the process of placing a payment order without being affected by the payment result notification interface and the receivables query interface.

# 4.3 WeChat Non-Tax Payment Export IP

WeChat The export IP of the non-tax payment call payment interface notification interface and receivables inquiry interface are:

101.227.131.239
101.227.169.13
182.254.90.117
121.51.76.135
101.89.14.152
180.97.118.178
223.167.253.106
58.246.221.98
117.184.239.113
183.192.201.151

Please add the above IP to the firewall white list.

# 5 Business Process Dxplaination

At present, WeChat non-tax payment supports a variety of business scenarios, and can refer to the explaination of the payment single interface.The following is illustrated primarily with the most commonly used payment scenarios.

# 5.1 The overall module architecture



The business side's front-end page initiates a payment request to the business side''s back office.access_tokenCentral Control Serviceaccess_token。 The business side backend assembles the request parameters as required, and calls the WeChat non-tax payment API usingaccess_token.access_tokenCentral Control Service Timing Refreshaccess_token(For example: refresh once in an hour).

# 5.2 Chart of the time order is placed and payment is made

WeChat Non-tax payments currently support a variety of payment methods to meet the needs of different payment scenarios.The following is the most commonly used JSAPI payment as an example to introduce the timing of the order payment. The interaction sequences of other payment scenarios are generally not very different, mainly in terms of the order request parameter and the order return parameter.

Chart of the time order is placed and payment is made

The user confirms the order on the business side's page or payment slip (click a button or scan a two-dimensional code), and the business side obtains the useropen_id,And initiate a order request, WeChat Non-tax payment query bill information, the execution of a single operation, return the order number and payment link. The business side returns the payment link to the front end (or directly to HTTP302) to open the payment link. Users initiate payment on the payment page. After the user pays, WeChat non-tax payment calls the payment notification interface of finance, bank, and commission office to notify the payment result of the bill. Refresh the payment results on the payment page (whichever is the financial record).

# 5.3 Other special case scenarios explained

# 5. 3.1 Weixin Mini Program Non-tax payments

Weixin Mini Program In the scenario where an order is placed through the appId of the caller Mini Program, the interface returns the parameters (appId and path) needed to pull up the non-tax payment Mini Program. See the return result explaination for the payment placing interface.

Calling wx.navigateToMiniProgram in Weixin Mini Program can evoke a non-tax payment Mini Program, the specific documentation can be found in the Mini Program API, where appId and path are required (the payment interface will return parameters)

wx.navigateToMiniProgram({
    appId: '',
    path: 'pages/index/index?id=123',
    success(res) {
        // 打开成功
    }
})

The user makes a payment or other operation back to the caller Weixin Mini Program. The caller can confirm the payment status of the order by invoking the inquiry and order interface through orderId (the order interface returns)

# 5.3.2 H5 non-tax payments on non-[ WeChat browsers

H5 that is open in a non-[ WeChat browser cannot get openids. Openids do not need to be passed when placing an order. Trade_type passes MBEB.

Some questions about H5 payments:

User IP: It is necessary to ensure that the incoming user IP for the order and the user IP for the final WeChat payment are consistent. It is recommended to call this interface on the user page to get the user IP.Otherwise, an error will be reported (as shown in the figure below). Some browsers, such as Huawei browser and UC browser, access the internet through proxy servers, and the IP may change every time.


Referer:发起微信支付的时候,会检查 Referer 参数,以确保请求是在合法的域名上发起的。正常浏览器一般会自动带上 Referer,如果出现这种错误,请自行抓包确认。 Referer的作用是,检查请求的来源。H5支付调用微信客户端时,会检查请求是否是从 https://mp.weixin.qq.com 这个域名发起的。所以,如果要在APP上使用H5支付,请针对域名为 https://mp.weixin.qq.com 的页面发起的请求设置 referer 为 https://mp.weixin.qq.com,同时设置一个可以标识 APP 的 User-Agent(用于支付完APP 回跳,下面会说明)。

iOS Webview 设置 Referer,请参考本文。 Android Webview 设置 Referer,请参考本文

APP 的跳转:如果是从 APP 上发起 H5 支付,微信支付成功后,默认情况下可能不会跳回到原来的APP,而是回到默认浏览器。如果希望支付结束回到 APP,请在打开 Webview 设置一个能标识 APP 的 User-Agent,同时将 User-Agent 上能标识APP的关键字和 Url Scheme 提供给我们进行配置。支付结束后会根据 User-Agent 使用不同的 Url Scheme 进行跳转。

如果不清楚 Url Scheme,可以参考这篇文章
Android Webview 设置 User-Agent,可以参考这篇文章
webview加载网页出现找不到网页net:err_unknown_url_scheme,解决方法请参考这篇文章

# 6 Interface Details

The list of interfaces involved is as follows:

Interface NameEnglish nameRequest Path
Enquire about receivable informationnontaxqueryfee/nontax/queryfee
Get a list of contributions ordersnontaxgetorderlist/nontax/getorderlist
Get Payment Order Detailsnontaxgetorder/nontax/getorder
Refund for Payment Ordersnontaxrefund/nontax/refund
Payment to place the ordernontaxunifiedorder/nontax/unifiedorder
Simulated query for receivable informationnontaxmockqueryfee/nontax/mockqueryfee
Notification of simulated payment resultsnontaxmocknotification/nontax/mocknotification
Submit a swipe paymentnontaxmicropay/nontax/micropay
Notification of an inconsistent ordernontaxnotifyinconsistentorder/nontax/notifyinconsistentorder
Download Payment Statementnontaxdownloadbill/nontax/downloadbill

# 7 FAQs

7.1 Payment intermediate page displays status as processed after payment

Answer: The reason is that notification of payment results has not been successful. Specific notifications can be viewed through the Inquiry and Order api.

7.2 The following occurs when placing an order:

Answer: The reason may be that the order openid is not consistent with the payment openid.

7.3 How long do non-tax payments take orders to return orders be valid? Answer: Order number is valid for 10 minutes.

7.4 When calling AccessToken, how do I whitelist an IP? Answer: login WeChat public platform, in the page settings - > Security Center - > IP whitelist added.

7.5 When invoking the API in a non-tax document, access_token is invalid? Answer: 1. Check whether the access_token of the call is consistent with the AppID of the access_token at the time of acquisition. 2, check whether the call access_token expired, you can refer to the cache access_token method: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183

7.6 In what file format do download statement data return? Answer: Return text in csv format.

7.7 How do I judge whether a duplication of payment is being made? Answer: To determine whether a payment is duplicate: a payment notice number + a collection unit code + an administrative area code unique.

7.8 Transactions within how many days of the refund cycle can be refunded? Answer: Currently, the maximum is one year.

7.9 When the PC scenario calls the payment interface, how should openid be obtained? Answer: the business side can show the two dimensional code, the user scan the code, open the business side of the web page, do WeChat web page authorization in the web page, and then you can get the openid.

7.10 Weixin Mini Program In the case of successful payment, why not return the order status through the front-end API? Answer: Many actions that trigger the return caller Weixin Mini Program do not trigger the API wx.navigateBackMiniProgram, so passing parameters using this interface is unreliable.