Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solution

Quickstart

This quickstart guides you through the integration process of Cashier Payment using Alipay+ APIs.

Set up the server
Server-side
(Optional) Add dependency

If you use the JAR file provided by Alipay+, add the dependency to your project.

Add Maven dependency:
XML
Editor
Configure requests

To configure requests, obtain the following information first:

  • Log in to Alipay+ Dashboard. Go to Developers > Quickstart, find Integration resources, and get the following details:
    • Gateway domain name
    • Client ID
    • API keys: You need to generate keys yourself. For more information about how to generate or replace keys, see API key configuration.
  • API path: Get the path for a specific API in Alipay APIs.

Then configure the obtained gateway domain name, Client ID, API keys, and API path to your API request.

Note: If you use the JAR file provided by Alipay+, you can use the codes directly without additional processing. If you prefer to sign a request and verify the signature by yourself, see Sign a request and verify the signature.

Set up a HTTPS request:
Java
Editor
Create a checkout page
Client-side

Create a checkout page on your client to display the goods ID, order information, available payment methods, the payment button, and other payment information.

Add payment methods

Add payment methods on your checkout page:

Note: For Alipay+ payment methods, you must display the Alipay+ Partner logo as in the picture.

Display of Alipay+ payment methods:
Quickstart
Initiate a payment
Server-side

When initiating a pay request, you need to pass in the following URLs:

  • paymentRedirectUrl: Your payment result page URL. Alipay+ redirects the buyer to this URL after the payment is completed. Pass in the required redirect URL types for different client-side terminals:
    • Web: Pass in a PC website redirect URL.
    • WAP: Pass in a web URL redirect URL.
    • App: Pass in a deep link URL.
  • paymentNotifyUrl: Alipay+ sends the payment and capture results to this URL after the payment and capture reaches a final status. Specify paymentNotifyUrl as an HTTPS URL and make sure that the URL can receive notifications.

After the buyer clicks the payment button, initiate the pay request using the alipayPayRequest object created in the Configure requests step.

Refer to samples in the code editor according to the following different payment types:

  • Non-card payment: includes payments of the following payment method categories:
    • Alipay+
    • Wallet
    • Online banking
    • Bank transfer
    • Mobile banking app
  • Card Payment (hosted payment page mode): In this mode, Alipay+ provides a page for collecting card payment information. If the buyer chooses to save the card on the page, Alipay+ stores the buyer's card information and generates a corresponding card token (cardToken). You can use the card token for future payments.
  • Card Payment (server-to-server mode): This mode requires that you are PCI-qualified.

Additionally, for card payments, when sending a pay request, you can also choose whether to use value-added features according to your business needs.

For specific payment requirements of different payment methods, see the pay API.

Order information:
Java
Editor
Environment information:
Java
Editor
Payment information:
Non-card
Card (hosted payment page mode)
Card (server-to-server mode)
Editor
Card information (server-to-server mode):
Java
Editor
Card authorization (Card payments):
Java
Editor
Payment redirect URL:
Java
Editor
Payment notification URL:
Java
Editor
Signing a request:
Java
Editor
Handle the payment result
Client-side & Server-side
pay response (Client-side)

When receiving the pay response from Alipay+, handle the payment result according to the value of result.resultStatus:

  • result.resultStatus=S: indicates that the payment was successful. Display the buyer the payment success result.
  • result.resultStatus=F: indicates that the payment failed. Display the buyer the payment failure result.
  • result.resultStatus=U: indicates that the payment is in process. Redirect the buyer to the URL returned by Alipay+.

Handle the redirect URL

When the value of result.resultStatus is U, at least one of the following URLs is returned:

  • normalUrl: The URL of an HTTPS address, used to redirect the buyer to the website page of the payment method on the same browser page of your website. Note that this URL may include a button to invoke the payment method App.
  • schemeUrl: The scheme URL that is used to open a payment method app.
  • applinkUrl: The Android App Link or iOS Universal Link that is used for redirection in the payment process.

Handle the URLs based on different terminal types (Web, WAP, and App) and operating systems (iOS and Android).

Web: The buyer places an order on your PC website.
JavaScript
Editor
WAP: The buyer places an order on your mobile browser website.
JavaScript
Editor
App (iOS): The buyer places an order from your App on iOS.
Objective-C
Editor
App (Android): The buyer places an order from your App on Android.
Java
Editor
Asynchronous notification (Server-side)

Alipay+ sends you an asynchronous notification when the payment reaches a final status of success or failure. Make sure that paymentNotifyUrl that you provide through the pay API can receive notifications.

When you receive the payment result notification, follow the steps below to handle it:

  1. Verify the notification.
  2. Update your order status.
  3. Send a notification response to Alipay+ following the fixed format shown in the code editor. You do not need to sign the response.
Verifying the notification:
Java
Editor
Notification response:
JSON
Editor
Handle the capture result notification
Server-side

Alipay+ automatically captures funds for you after the buyer completes the card authorization payment. When the capture reaches a final status of success or failure, Alipay+ sends an asynchronous notification to you. Make sure that paymentNotifyUrl that you provide through the pay API can receive notifications.

When you receive the capture result notification, follow the steps below to handle it:

  1. Verify the notification.
  2. Update your order status.
  3. Send a notification response to Alipay+ following the fixed format shown in the code editor. You do not need to sign the response.
Verifying the notification:
Java
Editor
Notification response:
JSON
Editor