A summary of the business process of WeChat payment, public number payment, H5 payment and small program payment

Source: Internet
Author: User
Tags openid

Objective

For a long time, has been wanting to write a payment related to the summary document, on the one hand is summed up some of their own experience, on the other hand can help others, but for various reasons do not fully understand the deep payment of several major payment methods, today is fortunate to do some summary of the article, also take advantage of this opportunity, more than a year of experience

Overview

1. Scan Code Payment

Merchant on the PC side show a payment QR code, the user uses sweep sweep function, sweep code to realize payment method.

2. Public number Payment

The merchant opens the H5 Web page within the app (browser) to pay for payment by paying the way.

3. H5 Payment

The merchant opens the H5 Web page in a mobile browser other than the browser, paying for payment by payment method.

4. Small program Payment

The merchant is in a small program that pays for the payment function by paying the way.

Preparation before development

The first step, login to the merchant platform settings related parameters configuration

First to the merchant platform to apply for a business account, and to open the payment, set up the corresponding public number payment, scan code payment, H5 payment of relevant parameters configuration.

Among them, the public number payment needs to set up the JSAPI payment authorization directory, and can only set up 5;

Scan code to pay the need to set up a scan callback link, both users through the scan code after payment callback to the merchant's page link;

H5 payment is required to set up a secure payment domain name.

Step two, introduce the official SDK

The official provides a set of Java,. NET, PHP and other three versions of the Development SDK, I am currently using. NET, so only need to download. Nte's SDK.

Address:pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=11_1

When you're done downloading, open the project in Visual Studio, with the following structure:

Folder example is a well-packaged instance, and the content in Lib and business is the core of the SDK, so you need to copy the two folders as they are to our actual development project:

Business process

Sweep Code Payment

1. The user orders, select Payment;

2. The merchant backstage according to the order information, calls the unified next single interface;

3. Unify the next single interface to return the pre-payment information, the merchant backstage will be the pre-payment information through technical means to generate two-dimensional code images, and displayed in the Web page;

4. The user uses the sweep code to pay, enters the payment password;

5. Payment completed, backstage to the merchant backstage to send asynchronous notification;

6. After receiving the asynchronous notification from the merchant background, obtain the relevant parameters, and carry out the corresponding business processing, such as modifying the order status and returning the success or fail flag to inform.

7. When sending asynchronous notifications to the merchant background, a jump will be made to the callback address set up in the merchant platform, the merchant should obtain the relevant parameters in the callback address and do business processing, and once the order status is known as the payment status, it jumps to the corresponding payment success screen.

For detailed instructions, please see the Payment official development documentation:

Pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1

Public Number Payment

1. The user orders, select Payment;

2. The merchant backstage according to the order information, calls the unified next single interface;

3. Unify the next single interface to return the pre-payment information, the merchant backstage to obtain the pre-payment information, and through JSAPI to initiate payment request, JSAPI adjust the payment;

4. The user enters the payment password, the payment completes;

5. Backstage sends the asynchronous notification to the merchant backstage, and returns the payment information on the JSAPI initiating page;

6. An asynchronous notification received by the Merchant in the background, the relevant business processing, and return the success or fail flag to inform.

7. The merchant obtains the callback information in the JSAPI launch page, requests the database to obtain the order status, and makes the page jump corresponding to the payment success or failure.

For detailed instructions, please see the Payment official development documentation:

Pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_1

H5 Payment

1. The user orders, select Payment;

2. The merchant backstage obtains the code parameter according to the AppID, then passes the code parameter to exchange the OpenID parameter;

3. The merchant backstage according to the order information, calls the unified next single interface;

4. Unified next single interface to return the pre-payment information, the merchant backstage to obtain the Mweb_url parameter in the pre-payment information, this parameter is the URL of the payment, the merchant backstage according to the actual need to decide whether to add the URL after the completion of the callback page address, and then jump to the URL, you can adjust the payment.

5. The user enters the payment password and the payment is completed.

6. Backstage sends an asynchronous notification to the merchant background and jumps to the Payment Initiation page or callback page;

7. The merchant backstage receives the callback information in the Payment initiation page or the callback page, requests the database to obtain the order status, and makes the page jump corresponding to the payment success or failure.

For detailed instructions, please see the Payment official development documentation:

Pay.weixin.qq.com/wiki/doc/api/h5.php?chapter=15_1

Small program Payment

1. The user orders within the small program, choose to pay;

2. The Merchant calls the applet login API in the applet, obtains the parameter code;

3. The applet side initiates an interface call to the merchant and sends the code and order related parameters to the merchant backstage.

4. The merchant backstage receives the code and the Order correlation parameter which the applet sends, and unifies Appid,secret two parameters, obtains the OpenID;

5. The merchant backstage according to the order information, calls the unified next single interface;

6. Unified next single interface to return the pre-payment information, the merchant backstage to obtain pre-payment information, and re-signed, return payment parameters (5 parameters and sign) to the small program;

7. The small procedure obtains the payment parameter, initiates the payment request;

8. The user enters the payment password, the payment completes;

9. Background asynchronous notification to the merchant background, while the small program callback payment results;

10. The merchant backstage receives sends to the asynchronous notification, and carries on the related business processing, and returns the success or the fail the sign to inform;

11. The applet obtains the payment callback result, and initiates the interface request to the merchant backstage, obtains the order status, and makes the page jump corresponding to the payment success or failure.

For detailed instructions, please see the Payment official development documentation:

pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_3&index=1

Business Flowchart

Analysis and summary

Sweep code payment, public number payment, H5 payment, small program payment all have a synchronous callback address and asynchronous notification address, but the way to set the difference:

1. Scan Code Payment

The synchronous callback address is set in the merchant platform, and the asynchronous notification address is set in the request parameter of the unified single interface;

2. Public number Payment

The synchronous callback address is returned in the return function of the JSAPI initiating payment, and the asynchronous notification address is set in the request parameter of the unified single interface;

3. H5 Payment

Synchronous callback Address: There is one parameter Mweb_url in the return parameter of the single interface, in Mweb_url, a new parameter is added in the form of get parameters Redirect_url,redirect_url is a synchronous callback function;

Asynchronous notification Address: Unified under the single interface of the request parameters set;

4. Small program Payment

Synchronous callback Address: In the small program to obtain the payment parameters, and through the JS after the payment, JS will have a callback function, synchronous callback address in the callback function to add;

Asynchronous notification Address: Set in the request parameters of the unified next single interface.

Where the scan code payment is mainly used for the computer, the public number payment and H5 payment is mainly used for mobile, so the merchant will need to determine whether the browser is currently open in the mobile, and choose the public number or H5 payment according to the result; the small program is mainly used in the small program inside Therefore, such as the acquisition of OpenID, call the unified next single interface and other operations in the small program to provide data interface services interface background implementation.

Synchronous callback address is the background with the merchant page jump channel, so the synchronization callback address is critical, if not filled, it may cause the payment after the completion of the page will not be able to jump.

The asynchronous notification address is the background to the merchant backstage after the completion of payment notification of the important channel, the merchant background of the asynchronous notification address must be accessible, after receiving the notification, to do the relevant business processing, and ultimately return success or fail of the identification given, to inform do not send notifications.

End

Here is only for the sweep code payment, the public number payment, the H5 payment, the small program payment and so on the four medium payment way has done the approximate analysis and the summary, the specific each payment method's access method also requests to pay the development document as the important reference; Because of the space is limited, the code quantity is large, here does not have the concrete implementation code

Reference Documentation:

Scan Code Payment:pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1

Public number payment:pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_1

H5 Payment:pay.weixin.qq.com/wiki/doc/api/h5.php?chapter=15_1

Small program Payment:pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_3&index=1

If you find errors and improper explanations, please correct me.

Please specify the source of this article:www.cnblogs.com/luckyyang/p/9509631.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.