This is the first day of my participation in Gwen Challenge


background

Generally, companies have relevant requirements for accessing Alipay and wechat Payment, and record relevant contents of documents and personal records here

Alipay Payment

Special note: Alipay is composed of two versions of the interface, the history of the system may be the old interface

The old version (mapi)

The new version (openapi)

Alipay supports the following payment purposes, because only used web & mobile applications, so mainly aimed at this expansion.

Take web & mobile application as an example, the general process is shown in the figure below

Document Viewing Instructions

According to my personal experience, the classification of Alipay documents can be divided into three steps, as shown in the figure below

  1. The first step is to register an account and learn about the application
  2. View the usage scenarios and open capabilities. Take payment as an example, which payment capabilities are suitable for the business scenarios, and view the access examples (there are also SdK&Demo of Alipay).
  3. The development documentation of the detailed API that needs to be accessed for the access step in 2

Before the development of

Create an

After logging in to the open platform console with alipay account, you can choose to create applications, which are mainly divided into self-developed applications and third-party applications (applicable to service providers). The main difference between the two applications is that the users are not the developers themselves.

The creation can be done step by step by following the process in the documentation. One of the things to watch out for is development information in the application environment

wordSection names describe
Interface Signing mode (Step 1) mandatory. Developers can choose according to access product requirementsPublic Key Certificate modePublic key model, and ensure that the private key used in the interface matches the public key set here. Otherwise, the interface cannot be invoked, and the interface parameter sign_type=RSA2. For details, seeGenerate a key and upload it.
IP Address whitelist (Step 2) Optional. To improve the security of merchants’ access to the open platform and avoid business damage caused by leakage of application private keys, the open platform provides an IP whitelist mechanism. For details, please refer to itIP address whitelist access guide. The IP whitelist is designed to ensure the security of developers’ funds, and developers choose the IP whitelist based on the actual situation.
Application Gateway (Step 3) Optional. It is used to receive alipay asynchronous notification, and the developer can fill it according to actual needs. Such as:Cash bonus,Transfer to alipay accountTriggered after the state of documents inalipay.fund.trans.order.changed (Notice of change of status of transfer documents). [C2C Cash Red Envelope](Opendocs.alipay.com/open/201901…Cash red envelope) triggered when the refund is successfulalipay.fund.trans.refund.success(Notice of successful fund return). ** Note: ** Asynchronous notification of payment results Alipay will notify the payment results as parameters to the merchant system in the form of POST request according to the notify_URL of the asynchronous notification address passed in the payment API.
Interface content encryption Mode (Step 4) Optional. That is, AES keys can be used to encrypt and decrypt data information. Access to theGet member’s mobile phone number,Movement dataThe decryption function must be configured. Please refer toContent Encryption Guidelines.
Authorization Callback Address (Step 5) Optional.Third-party Application AuthorizationOr [User Information Authorization](Opendocs.alipay.com/open/284/we…Redirect_uri) after the callback address. The redirect_URI value configured in the authorization link must be the same as this value (for example:www.alipay.com), after successful authorization, the user will carry the authorization code and other information after the URL and jump to the page. ** Note: ** When you fill in this address, the system will automatically perform security detection, please refer to the detailsSafety inspection.

Binding application

Binding applications are divided into similar creation applications, which are also divided into two types, common merchant binding and service providers for merchant binding operations. The main difference lies in whether the application is yours.

Merchants will not be notified of the application bound to the same principal account, and different principal accounts cannot be bound to the application

The key

For the interface of system interaction, the importance of key is undeniable. Alipay provides three key generation tools:

  • Web online encryption (free download, new online) recommended
  • WINDOWS (Do not install the tool of the WINDOWS version in the directory path containing Spaces. Otherwise, garbled public and private keys may occur.)
  • MAC_OSX

See the Development Assistant introduction for more information

Ability to open

In order to meet the business demands of developers, Alipay opens up its business capabilities in the form of interfaces, through which developers interact with the Alipay server to realize business logic.

This corresponds to the second document directory in the upper right corner of the document of Alipay. Here we focus on the ability to pay, and the corresponding application scenarios of different abilities will be mentioned

Ability to pay

In order to meet users’ demand for alipay payment in web, mobile, platform merchant and offline payment scenarios, Alipay provides the following payment capabilities for quick integration of merchants.

Including face-to-face payment, App payment, mobile website payment, computer website payment, etc., with the following form to briefly introduce

Ability to name Application scenarios Supported Account Types
In person to pay In offline transaction scenarios of supermarkets and restaurants, merchants can generate qr codes of orders for users to scan for payment; You can also scan the user’s QR code to complete payment. Enterprise Alipay account individual industrial and commercial households
App to pay Alipay provides merchants with client & server SDK to help merchants quickly integrate alipay payment function in their own App. Enterprise Alipay account individual industrial and commercial households
Mobile website payment Provide integrated Alipay payment function interface for merchants’ mobile web applications. Enterprise Alipay account individual industrial and commercial households
Computer website payment It provides integrated Alipay payment function interface for PC web applications of merchants. Enterprise Alipay account individual industrial and commercial households
Brush face pay In offline self-service payment scenarios such as shopping malls and unsold goods, users can make payment by alipay through face scanning. Enterprise Alipay account individual industrial and commercial households
Internet platform direct Payment The direct payment capability, which integrates payment, settlement, account distribution and other functions, can help e-commerce and mutual entertainment platforms solve possible compliance problems. Enterprise Alipay account

In person to pay

Access to

Mainly corresponding to the offline scene, the main way should be we usually use: bar code payment and scan code payment, the most intuitive understanding can be understood as you scan the merchant or the merchant scan you, note that scan code payment needs to call a pre-payment

The characteristics of in-person payment are:

  1. Offline fast payment
  2. There is no network requirement for the user’s phone and payment can be made offline
  3. Merchants receive funds in real time, no cash flow pressure

Q&A

Bar code to pay

The buyer shows the barcode and QR code in the Alipay wallet, and the merchant can scan the barcode of the user to complete the barcode payment and collection. All the collection process is completed by the merchant end.

Bar code payment is more suitable for the need to docking all kinds of business systems, businesses with strong demand for reconciliation, such as shopping malls and supermarkets. There are two types of access modes: direct connection mode of stores and background forwarding mode of merchants/system vendors

The process is as follows:

  1. Create transactions and pay(Alipay.trade.pay(unified billing transaction payment interface))

  2. According to the returned results, the payment status is determined for corresponding processing (including closing the transaction if necessary), as shown in the OPT block in the figure. Step 2 indicates that the payment is successful and the payment success page is returned.

  3. Step 3 indicates that the returned parameter is the processing mode in the case of payment pending (code=10003), system exception (code=20000), network timeout, etc.

  4. Step 4 indicates that the polling is still not processed successfully and the order needs to be cancelled.

  5. Step 5 indicates that when the payment failure (code=40004) is returned, the parameters need to be checked again and the payment needs to be initiated again.

    For details, see Exception Handling.

Involving the API:

Interface Name Interface Chinese name describe
alipay.trade.pay Unified billing transaction Payment interface (barcode payment) Create alipay transaction order by calling this interface
alipay.trade.query Unified receiving line trading inquiry This interface is invoked to query the status of the order
alipay.trade.cancel Unified receipt transaction cancellation interface Cancel the order by calling this interface
alipay.trade.create Unified receipt transaction creation interface Create alipay transaction order
alipay.trade.refund Unified billing transaction refund interface Partial and full refunds are supported
alipay.trade.close Unified billing transaction closing interface Transaction closing interface
alipay.trade.fastpay.refund.query Unified receipt transaction refund inquiry interface Call this interface to check whether the refund request submitted through Alipay. Trade. Refund is successfully executed
alipay.data.dataservice.bill.downloadurl.query Query statement download address interface Query and download statements
monitor.heartbeat.syn Transaction assurance interface Transaction assurance interface
alipay.trade.refund.depositback.completed Notice of receipt, refund and refund completion Refund to bank card notice
scan to pay

By using the alipay scan function, buyers can scan the qr code of merchants to complete the payment by scanning the code

Scanning code payment is more suitable for independent pricing, unattended, vending machines and other businesses (without strong reconciliation), such as offline small convenience stores, vending machines, etc., users can complete payment by scanning code at self-service terminals.

The process is as follows:

  1. The merchant system calls the Interface of Alipay. Trade. precreate(transaction pre-creation under unified receiving line) to obtain the QR code string qR_code of the order. The developer needs to use the QR code generation tool to obtain the qr code picture of the final order.

  2. Initiate polling to obtain payment results: Wait for 5 seconds and call the Alipay. Trade. query(unified transaction query) interface to query the payment result (return parameter TRADE_STATUS) by the merchant order number (out_trade_no) passed in during payment. If it still returns waiting for the user to pay (WAIT_BUYER_PAY), wait another 5 seconds and continue the query until the exact payment result is returned (TRADE_SUCCESS or TRADE_CLOSED reversed) or the polling time has expired. In the case that the last query still returns waiting for the user to pay, the transaction must be cancelled immediately by calling Alipay. Trade-cancel (unified transaction cancellation interface) to avoid the user to continue to pay;

  3. In addition to active polling, when the order payment is successful, merchants can also set notify_URL to get the payment results returned by alipay server. Please refer to the code sweep asynchronous notification. It is important to check the signature of the asynchronous notification to ensure that the notification is sent by Alipay.

    Note: If the merchant cannot accept the asynchronous payment notice due to objective reasons (such as no public network server to accept alipay request, etc.), step 3.4 and 3.4.1 in the figure above will be ignored. For more precautions, see Exception Handling.

Involved in the API

Interface Name Interface Chinese name describe
alipay.trade.query Unified receiving line trading inquiry This interface is invoked to query the status of the order
alipay.trade.cancel Unified receipt transaction cancellation interface Cancel the order by calling this interface
alipay.trade.create Unified receipt transaction creation interface Create alipay transaction order
alipay.trade.refund Unified billing transaction refund interface Partial and full refunds are supported
alipay.trade.precreate Pre-creation of transactions under unified Billing Line (Scan payment) Create alipay transaction order (scan code)
alipay.trade.close Unified billing transaction closing interface Transaction closing interface
alipay.trade.fastpay.refund.query Unified receipt transaction refund inquiry interface Call this interface to check whether the refund request submitted through Alipay. Trade. Refund is successfully executed
alipay.data.dataservice.bill.downloadurl.query Query statement download address interface Query and download statements
monitor.heartbeat.syn Transaction assurance interface Transaction assurance interface
alipay.trade.refund.depositback.completed Notice of receipt, refund and refund completion Refund to bank card notice

APP to pay

Access to

App payment mainly refers to the need to pull up Alipay payment in the App of merchants. Merchant APP calls the SDK provided by Alipay, and the SDK then calls the payment module in Alipay APP.

If the user has installed alipay App, skip to Alipay payment

If the user has not installed the Alipay App, pull up the Alipay webpage to pay the cashier to pay

[FaQs](App Payment FAQ)

Client iOS integration process

Opendocs.alipay.com/open/204/10…

Client Android integration process

Opendocs.alipay.com/open/204/10…

Server access process

The server access needs to go through the sandbox environment first. The system interaction flow of an order is as follows

The transaction signature must be carried out at the server, and the interface for creating orders is Alipay.trade.app.pay (APP Payment interface 2.0).

Involved in the API

API English name API Chinese name The document
alipay.trade.app.pay App Payment Interface 2.0 To view the document
alipay.trade.query Transaction query interface To view the document
alipay.trade.close Transaction closing interface To view the document
alipay.trade.refund Transaction refund interface To view the document
alipay.trade.fastpay.refund.query Transaction refund query interface To view the document
alipay.data.dataservice.bill.downloadurl.query Query the bill download address interface To view the document
alipay.trade.refund.depositback.completed Notice of receipt, refund and refund completion To view the document

Mobile website payment

Access to

Mobile website payment provides the integration of Alipay payment function in the merchant’s mobile web page. Place an order on the page, return to the Alipay link, and pull up the Alipay client (h5’s payment page is only supported by old merchants).

If you open it in a Web-view, you can consider switching to a mobile website for APP payment

Due to the mobile website products for merchants and users to better payment security, product optimization and upgrading. On the premise that users have installed alipay client, the payment process of the product is basically unchanged, and the wallet is directly evoked for payment according to the original process. If alipay client is not installed, the payment process will be changed. After the upgrade, h5 webpage payment will no longer be evoked, and users will be guided to download Alipay client for payment.

  • The new payment process will be adopted for payment products on mobile websites starting from August 2019. Merchants of historical products will still support payment on the H5 page.
  • For some merchants with historical contracts, if your H5 payment success rate is very low, in order to improve the payment experience and security, we will also upgrade to the new product process.
Server access process

  1. After users place an order and pay on the merchant’s H5 website, the merchant system invoks the interface parameter specification of Alipay.trade.wap. Pay (payment interface 2.0 of mobile website) to generate order data. Then send payment request to Alipay system through Form Form in front page. At this point, Alipay will automatically redirect the page to the cashier desk page of Alipay H5. If alipay App is installed on the user’s mobile phone, it will automatically evoke alipay App; otherwise, it will prompt the user to download Alipay App.
  2. After the user completes the payment in Alipay App or H5 cashier desk, the user will automatically jump back to the merchant page according to the foreground hop address return_URL imported from the payment API of the mobile website, and at the same time, the payment result parameter is attached in the FORM of Query String in the URL request. For details, see Appendix 1: Description of Foreground Jump Parameters.
  3. In addition to the forward payment process, Alipay also provides supporting apis such as transaction inquiry, closing, refund, refund inquiry and reconciliation.

Description:

  • Developers need to pay attention to the two test scenarios with and without Alipay installed. In the mode of arousing H5 page in mobile browser, if alipay is installed but not arousing H5 page, most of the reason is that the current browser is not in the white list of Alipay configuration.
  • For the payment scenario embedded in web-view of merchant App, it is recommended to integrate Alipay App payment products. Or you can use the mobile website payment to Native payment scheme. It is not recommended to directly access the mobile website payment in your App.
  • In the IOS system, alipay App will not automatically return to the browser or merchant App after the payment is completed. Users can manually cut back to the browser or merchant App; Alipay H5 cashier will automatically jump back to the page specified by merchant return_url.
  • Alipay will also notify the payment result as a parameter to the merchant system in the form of POST request according to the asynchronous notification address notifY_URL passed in the original payment API. See payment Result Asynchronous Notification for details.

Involved in the API

API English name API name
alipay.trade.wap.pay Mobile web payment interface 2.0
alipay.trade.query Transaction query interface
alipay.trade.close Transaction closing interface
alipay.trade.refund Transaction refund interface
alipay.trade.fastpay.refund.query Transaction refund query interface
alipay.data.dataservice.bill.downloadurl.query Query the bill download address interface

Computer website payment

Access to

Merchants can directly jump to the cashier desk of Alipay PC website to complete collection. The process is as follows

  1. The user selects the product to be purchased and the product style on the merchant website, and then clicks to buy it immediately (you can try any product under the WEBSITE of PC Taobao or buy a member on the website of Youku).

  2. The page jumps to the cashier page of Alipay, and there are two payment methods for users to choose

    1. Users can use the Alipay APP to scan the QR code on the screen, select the payment tool and enter the password to complete the payment when prompted by the mobile phone

    2. If you do not use your mobile phone to pay, you can also click the login account on the right side of the page in Figure 1 to pay and enter your Alipay account and payment password to log in to the CASHIER desk on the PC

  3. After the user selects the payment method, input the payment password and click confirm payment. If the payment is successful, the page will jump to the successful payment page.

Access to the process
  1. The merchant system invokes Alipay. Trade.page.pay (unified order placing and payment page interface initiates a payment request to Alipay, which verifies the merchant request parameters and then redirects to the user login page.

  2. After the user confirms the payment, Alipay requests returnUrl through GET (merchant input parameter) and returns the synchronization return parameter.

  3. After the transaction is successful, Alipay requests notifyUrl (incoming merchant entry parameter) through POST and returns the asynchronous notification parameter.

  4. If the merchant system does not receive the asynchronous notification due to network or other reasons, the merchant can call Alipay. Trade. query (the transaction query interface under the unified collection line can query the transaction and payment information (the merchant can also directly call the query interface, without relying on the asynchronous notification).

Involved in the API

Interface Name Interface Chinese name
alipay.trade.page.pay Unified receiving, ordering and payment page interface
alipay.trade.refund Unified billing transaction refund interface
alipay.trade.fastpay.refund.query Unified receipt transaction refund inquiry interface
alipay.trade.query Unified single – line transaction inquiry interface
alipay.trade.close Unified billing transaction closing interface
alipay.data.dataservice.bill.downloadurl.query Query the statement download address
alipay.trade.refund.depositback.completed Notice of receipt, refund and refund completion

API

The documentation of payment API is similar to wechat, with the main difference being placing orders, while the rest are universal and mainly used to describe detailed interface parameters.

It is recommended to know the interfaces required by specific businesses and what contents need to be opened from the open ability of payment documents, and then go back to the payment documents to check the details of the interfaces

Single interface API The interface scenario Interface methods
Unified billing transaction payment interface Merchant scan your payment code (scan gun) alipay.trade.pay
Unified collection line under trade pre – creation You scan the merchant’s payment code, which is generated by the merchant calling alipay interface through the cashier desk or merchant background alipay.trade.precreate
App Payment Interface 2.0 External apps pull Up Alipay by calling the SDK of Alipay alipay.trade.app.pay
Mobile web payment interface 2.0 Request Alipay on mobile Internet sites alipay.trade.wap.pay
Unified receiving, ordering and payment page interface Ask Alipay to pull up the page on the PC website alipay.trade.page.pay

conclusion

For Alipay payment access, the most important thing should be the column of “open ability” after the application is created. Here, the preparation and business scenarios required for each ability are described in detail, as well as the download of samples and relevant codes, so that developers can have a clear direction.

For API access, you can view the API list of the corresponding service in Open Capability. Then connect each interface in detail (also listed in the article)

During the access process, a corresponding gadget or sandbox environment is available to facilitate better access, as described in the product introductionXXX Access Assistant

In Open Power, there are frequently asked questions for each specific scene, and answers to questions can be found here. If you really can’t find the answer in the document, you can also choose to answer online, click on the right side of the page.

The problem

1. Whether the new gateway configuration key affects the old key and interface

Alipay exists the interface between the old and new Wang mansions, which is not affected by each.

The related documents