Alipay payment access finishing

Alipay payment access finishing

This is the first day I participated in the Wenwen Challenge. For details of the event, please view: Wenwen Challenge


background

Generally companies will have related requirements for access to Alipay and WeChat Pay. Record the relevant content of the document and personal records here

Pay with Ali-Pay

Special note: Alipay has two versions of the interface, and the historical system may use the old interface

Old version (mapi)

New version (openapi)

The payment purposes supported by Alipay are as follows, because only used

Web & Mobile Application
, So it is mainly aimed at this expansion.

to

Web & mobile applications as an example
, The general process is as shown in the figure below

The picture comes from Alipay

Document viewing instructions

The classification in the Alipay document can be divided into three steps based on my personal viewing experience, as shown below

  1. The first step is to register an account and understand the application
  2. View usage scenarios and open capabilities, take payment as an example, which payment capabilities the business scenario meets, and view access examples (also Alipay's sdk&demo)
  3. For the access steps in 2, the development documentation of the detailed api that needs to be accessed

Before development

Create application

After logging in to the open platform console with your Alipay account, you can choose to create an application, which is mainly divided into

Self-developed application
with
third-party usage
(Applicable to service providers). The main difference between the two applications is that the user is not the developer.

Creation can be done step by step according to the process in the document. One thing to pay attention to is the development information in the application environment

The picture comes from Alipay
Word segment namedescription
Interface signature method (step 1)Required . Developers can choose according to demand access to the public key certificate mode or public key scheme , and to ensure that the interface used in the private and public key pairs matching set here, otherwise you can not call interface, and the interface parameters sign_type = RSA2. Refer to generate a key and upload .
IP whitelist (step 2)Optional. In order to improve the security of merchants' access to the open platform and avoid business damage caused by the disclosure of application private keys, the open platform provides an IP whitelist mechanism. For details, please refer to the IP Whitelist Access Guide . The IP whitelist is designed to ensure the security of the developer's funds, and the developer chooses it according to the actual situation.
Application Gateway (Step 3)Optional. It is used to receive Alipay asynchronous notification, and the developer can fill it out according to actual needs. For example: cash red envelopes , alipay.fund.trans.order.changed (notice of status change of transfer documents) triggered after the status of the documents in the transfer to the Alipay account is changed. [C2C Cash Red Packet ]( opendocs.alipay.com/open/201901 Cash Red Packet ) Alipay.fund.trans.refund.success (notice of successful return of funds) triggered when the refund is successful . **Note: ** Asynchronous notification of payment results Alipay will notify the merchant system of the payment result as a parameter in the form of a POST request according to the asynchronous notification address notify_url passed in the payment API.
Interface content encryption method (step 4)Optional. That is, the AES key can be used to encrypt and decrypt data information. Access to obtain the phone number of members , the motion data and other required functions must be configured to decrypt the data. Please refer to the content encryption guidelines .
Authorized callback address (step 5)Optional. Callback address after third-party application authorization or [User Information Authorization] ( opendocs.alipay.com/open/284/we... redirect_uri description). The value of redirect_uri configured in the authorization link must be consistent with this value (for example: www.alipay.com ). After successful authorization, the user will carry the authorization code and other information behind the url and jump to the page. ** Note: ** When fill this address, the system will automatically detect security, please refer to safety testing .

Bind application

Binding applications are divided into similar creation applications, but also into two types,

Ordinary merchant binding
with
The service provider waits for the merchant to bind the operation
, The main difference is whether the application is yours.

Binding apps to the same principal account will not notify the merchant, and different principal accounts do not support binding apps

Key

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

  • Web online encryption (download free, new online) recommendation
  • WINDOWS (Please do not install the windows version tool in a directory path with spaces, otherwise it will cause the problem of garbled public and private keys)
  • MAC_OSX

For more information, please see the Development Assistant Introduction

Openness

In order to meet the business demands of developers, Alipay has opened up Alipay s business capabilities in the form of interfaces. Developers interact with Alipay servers through these open interfaces to implement business logic.

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

Ability to pay

In order to support users' payment needs using Alipay in scenarios such as web, mobile, platform merchants, and offline payment, Alipay provides the following payment capabilities for merchants to quickly integrate.

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

Ability nameApplication scenarioSupport account type
Pay in personIn offline transaction scenarios in supermarkets and restaurants, merchants can generate order QR codes for users to scan and pay; they can also scan user QR codes to complete collection.Individual industrial and commercial households with corporate Alipay accounts
App paymentAlipay provides merchants with client & server SDK to help merchants quickly integrate Alipay payment functions in their own apps.Individual industrial and commercial households with corporate Alipay accounts
Mobile website paymentProvide integrated Alipay payment interface for merchants mobile web applications.Individual industrial and commercial households with corporate Alipay accounts
Computer website paymentProvide integrated Alipay payment interface for merchants PC-side web applications.Individual industrial and commercial households with corporate Alipay accounts
Brush faceIn offline self-service payment scenarios such as shopping malls and unmanned sales, users can use Alipay to pay by swiping their faces.Individual industrial and commercial households with corporate Alipay accounts
Internet platform direct paymentThe direct payment capability that integrates payment, settlement, account splitting and other functions can help e-commerce and mutual entertainment platforms solve possible compliance problems.Enterprise Alipay account

Pay in person

Ready access

The main line under the corresponding scene, the main thing is to be with the way we usually use are: bar code payment and scan code payment , most intuitive understanding can be understood as you sweep sweep your business or business , pay attention, pay sweep code needs to call a pre-payment

The features of paying in person are:

  1. Fast offline payment
  2. There is no network requirement for the user s mobile phone, and offline payment
  3. Merchants receive funds in real time, no cash flow pressure

Frequently Asked Questions

Barcode payment

Buyers show Alipay wallet bar code, two-dimensional code, business users scan the bar code to complete the bar code payment collection, all the receiving process completed by the end of the business.

Barcode payment is more suitable for merchants that need to connect to various merchant systems and have strong demand for account reconciliation , such as shopping malls and supermarkets. Which is divided into two types of access: store direct connection and merchant/supplier back-end system forward

The process is as follows:

  1. Create a transaction and pay ( alipay.trade.pay (uniform acquiring transaction payment interface))

  2. According to the returned results, determine the payment status, and then perform corresponding processing (including closing the transaction if necessary), as shown in the opt block, the second step indicates that the payment is successful, and the payment success page is returned;

  3. Step 3 indicates that the returned parameters are the processing methods in scenarios such as waiting for user payment (code=10003) or system abnormality (code=20000), network timeout, etc.;

  4. Step 4 means that the polling has not been processed successfully, and the order needs to be cancelled;

  5. Step 5 means that when the payment failed (code=40004) is returned, the parameters need to be rechecked and the payment is initiated again.

    Refer to exception handling .

Barcode payment method flow chart

Barcode payment-store direct connection method

Barcode payment-background forwarding method

Involved api:

English name of interfaceInterface Chinese namedescription
alipay.trade.payUnified acquiring transaction payment interface (barcode payment)Create Alipay transaction order by calling this interface
alipay.trade.queryUnified acquiring offline transaction queryQuery the status of the order by calling this interface
alipay.trade.cancelUnified acquiring transaction cancellation interfaceCancel the order by calling this interface
alipay.trade.createUnified acquiring transaction creation interfaceCreate Alipay transaction order
alipay.trade.refundUnified acquiring transaction refund interfaceSupport partial and full refunds
alipay.trade.closeUnified acquiring transaction closing interfaceTransaction close interface
alipay.trade.fastpay.refund.queryUnified acquiring transaction refund query interfaceInquire whether the refund request submitted through alipay.trade.refund is executed successfully by calling this interface
alipay.data.dataservice.bill.downloadurl.queryQuery the download address interface of the statementQuery and download the statement
monitor.heartbeat.synTransaction Guarantee InterfaceTransaction Guarantee Interface
alipay.trade.refund.depositback.completedNotice of Completion of Acquiring RefundNotification of refund to bank card
Scan QR code to pay

By using Alipay buyers sweep the function, two-dimensional code scanning business receivables to complete the scan code payment Payment

Scan code payment is more suitable for merchants such as individual pricing, unattended, self-service vending machines (no need to reconcile), such as offline small convenience stores, self-service vending machines, etc., users complete the payment by scanning the code at the self-service terminal.

The process is as follows:

  1. The merchant system calls the alipay.trade.precreate (uniform acquiring offline transaction pre-create) interface to obtain the QR code string qr_code of the order, and the developer needs to use the QR code generation tool to obtain the final order QR code picture;

  2. Initiate polling to obtain the payment result: wait for 5 seconds and then call the alipay.trade.query (unified offline transaction query) interface, and query the payment result by the merchant order number (out_trade_no) passed in during payment (return parameter TRADE_STATUS), if still Return to wait for user payment (WAIT_BUYER_PAY), then wait 5 seconds again and continue to query until the exact payment result (successful TRADE_SUCCESS or closed TRADE_CLOSED has been cancelled) is returned, or the polling time is exceeded. In the case that the last query still returns waiting for the user to pay, you must immediately call alipay.trade.cancel (uniform acquiring transaction cancellation interface) to cancel the transaction to prevent the user from continuing to pay;

  3. In addition to the active polling, pay when an order is successful, businesses can pay to get the results Alipay returned from the server by setting the asynchronous notification (notify_url), see scan code asynchronous notification , attention must be checked to verify asynchronous notification, ensure that the notice is Issued by Alipay.

    Note : If the merchant cannot accept the asynchronous payment notification due to objective reasons (such as no public network server accepting Alipay requests, etc.), ignore the steps 3.4 and 3.4.1 in the above figure. More considerations, please refer exception handling .

Involved api

English name of interfaceInterface Chinese namedescription
alipay.trade.queryUnified acquiring offline transaction queryQuery the status of the order by calling this interface
alipay.trade.cancelUnified acquiring transaction cancellation interfaceCancel the order by calling this interface
alipay.trade.createUnified acquiring transaction creation interfaceCreate Alipay transaction order
alipay.trade.refundUnified acquiring transaction refund interfaceSupport partial and full refunds
alipay.trade.precreatePre-creation of offline transactions for unified acquiring (scan code payment)Create Alipay transaction order (scan code)
alipay.trade.closeUnified acquiring transaction closing interfaceTransaction close interface
alipay.trade.fastpay.refund.queryUnified acquiring transaction refund query interfaceInquire whether the refund request submitted through alipay.trade.refund is executed successfully by calling this interface
alipay.data.dataservice.bill.downloadurl.queryQuery the download address interface of the statementQuery and download the statement
monitor.heartbeat.synTransaction Guarantee InterfaceTransaction Guarantee Interface
alipay.trade.refund.depositback.completedNotice of Completion of Acquiring RefundNotification of refund to bank card

APP payment

Ready access

App payment mainly refers to the situation where Alipay needs to be activated in the merchant's App. The merchant APP calls the SDK provided by Alipay, and the SDK then calls the payment module in the Alipay APP.

If the user has installed Alipay App, jump to Alipay to pay

If the user does not install the Alipay App, pull up the Alipay website to pay the cashier to pay

[FAQ](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 process of an order is as follows

The signature of the transaction must be done on the server. The interface for creating an order is alipay.trade.app.pay (app payment interface 2.0)

Involved api

API English nameAPI Chinese nameDocumentation
alipay.trade.app.payapp payment interface 2.0View document
alipay.trade.queryTransaction query interfaceView document
alipay.trade.closeTransaction close interfaceView document
alipay.trade.refundTransaction refund interfaceView document
alipay.trade.fastpay.refund.queryTransaction refund query interfaceView document
alipay.data.dataservice.bill.downloadurl.queryQuery bill download address interfaceView document
alipay.trade.refund.depositback.completedNotice of Completion of Acquiring RefundView document

Mobile website payment

Ready access

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 (the payment page of h5 is only supported by old merchants).

If it is opened in the web-view, you can consider switching to mobile site transfer payments APP

As the mobile website products have been optimized and upgraded for merchants and users to better guarantee payment security. On the premise that the user installs the Alipay client, the product payment process is basically unchanged, and the wallet is directly invoked for payment according to the original process. Under the premise that the Alipay client is not installed, the payment process has changed. After the upgrade, the h5 web payment will no longer be invoked, and the user will be guided to download the Alipay client for payment.

  • Mobile website payment products signed in August 2019 will follow a new payment process, and merchants of historical contracted products still support the invocation of h5 page payment.
  • For some historical contract merchants, if your h5 payment success rate is extremely low, in order to improve the payment experience and security, it will also be upgraded to a new product process.
Server access process

Mobile website payment flow chart
  1. User after a single payment at the merchant's website H5, the merchant system calls alipay.trade.wap.pay (mobile site payment interface 2.0) Interface specification parameters to generate orders; then to the front page in the form of Form in the form of Alipay system sends a payment request . At this time, Alipay will automatically redirect the page to the Alipay H5 cash register page. If the Alipay App is installed on the user's mobile phone, it will automatically call up the Alipay App, otherwise it will prompt to download the Alipay App.
  2. After the user completes the payment in the Alipay App or H5 cash register, it will automatically jump back to the merchant page according to the front desk return address passed in the mobile website payment API return_url, and the payment result will be attached to the URL request in the form of a Query String parameters, detailed parameters see text late rebound Appendix I: reception bounce parameter description .
  3. In addition to the forward payment process, Alipay also provides supporting APIs such as transaction query, closure, refund, refund query, and account reconciliation.

Description :

  • Developers need to pay attention to the two test scenarios where Alipay is installed and Alipay is not installed. For the mobile phone browser to evoke the H5 page mode, if Alipay is installed but not evoked, most of the reason is that the current browser is not in the whitelist configured by Alipay. Inside.
  • For payment scenarios in the web-view embedded in the merchant App, it is recommended to integrate Alipay App payment products. Or you can use the mobile site transfer payment Native payment scheme does not recommend direct access to the mobile site to pay your App.
  • In the IOS system, after calling the Alipay App to complete the payment, it will not automatically return to the browser or merchant App. The user can manually switch back to the browser or the merchant App; the Alipay H5 cash register will automatically jump back to the page specified by the merchant's return_url.
  • Alipay will pay according to the original API in the incoming asynchronous notification address notify_url, in the form of a POST request to be paid as a result of the notification to the merchant system parameters, as detailed in pay result of the asynchronous notification .

Involving api

API English nameAPI Chinese name
alipay.trade.wap.payMobile website payment interface 2.0
alipay.trade.queryTransaction query interface
alipay.trade.closeTransaction close interface
alipay.trade.refundTransaction refund interface
alipay.trade.fastpay.refund.queryTransaction refund query interface
alipay.data.dataservice.bill.downloadurl.queryQuery bill download address interface

Computer website payment

Ready access

You can directly jump to the Alipay PC website cash register from the merchant s PC website to complete the collection. The process is as follows

  1. After the user selects the product and product style to be purchased on the merchant website, click to buy immediately (you can find a product to try on the PC Taobao website or you can buy a member on the Youku web version)

  2. The webpage jumps to the Alipay cash register page. At this time, there are two payment methods for users to choose

    1. The user can use the Alipay APP to scan the QR code on the screen, and after the mobile phone prompts to pay, select the payment tool and enter the password to complete the payment

    2. If you do not use the phone payment, you can click on the right side of the page Figure 1 login account payments , enter Alipay account number and password to log in to pay the cashier PC

  3. After the user selects a payment method, enter payment password and click confirm payment , the payment was successful jump to the page successful payment page.

Access process
  1. The merchant system calls alipay.trade.page.pay (the unified acquiring order and payment page interface initiates a payment request to Alipay. Alipay verifies the merchant request parameters, and then redirects to the user login page.

  2. After the user confirms the payment, Alipay requests returnUrl via get (merchant input parameters are passed in), and returns the synchronous return parameters.

  3. After the transaction is successful, Alipay requests the notifyUrl through the post (the merchant enters the parameter to pass in), and returns the asynchronous notification parameters.

  4. If the merchant system does not receive the asynchronous notification due to the network and other reasons, the merchant can call alipay.trade.query (the unified offline transaction query interface of the unified acquiring offline transaction query interface to query transaction and payment information) Asynchronous notification).

Involving api

English name of interfaceInterface Chinese name
alipay.trade.page.payUnified acquirer, place an order and pay page interface
alipay.trade.refundUnified acquiring transaction refund interface
alipay.trade.fastpay.refund.queryUnified acquiring transaction refund query interface
alipay.trade.queryUnified acquiring offline transaction query interface
alipay.trade.closeUnified acquiring transaction closing interface
alipay.data.dataservice.bill.downloadurl.queryQuery the download address of the statement
alipay.trade.refund.depositback.completedNotice of Completion of Acquiring Refund

API

Payment API documentation of similar micro-channel, the main difference is that a single, common rest are mainly used to interface parameters about the detailed contents.

The main recommendations of the ability to pay from the open document, understand the specific business needs of the interface and the need to open what , then pay back the document View Interface Details

The picture also comes from Alipay
Order interface apiInterface sceneInterface method
Unified acquiring transaction payment interfaceThe merchant scans your payment code (scan code gun)alipay.trade.pay
Pre-creation of offline transactions for unified acquiringYou scan the merchant s payment code, which is generated by the merchant through the cashier counter or the merchant s backstage call Alipay interfacealipay.trade.precreate
app payment interface 2.0The external APP pulls up Alipay by calling Alipay's sdkalipay.trade.app.pay
Mobile website payment interface 2.0Request Alipay on the website on the mobile phonealipay.trade.wap.pay
Unified acquirer, place an order and pay page interfaceRequest Alipay to pull up the page on the PC websitealipay.trade.page.pay

summary

For Alipay access it, you create the application, the most important [should be] the ability to open this column, here in detail for each ability needs to prepare, business scenarios, and download examples and associated code , you can make Developers have a clear direction.

For api access, you can first check the api list of the corresponding business in [Open Capability]. Connect each interface in detail (also listed in the article)

During the access process, there are also corresponding gadgets or sandbox environments to help better access, such as the XXX access assistant in the product introduction

In [Open Ability], each specific scene will also have corresponding FAQs. If you have any doubts, you can generally find answers here. If you really can't find the answer in the document, you can also choose to answer it online, just click the inquiry question on the right side of the page.

problem

1. Will the new gateway configuration key affect the old key and interface?

There are two interfaces for Alipay, the old and the new Wang Mansion, each of which does not affect each.

Related documents