Alipay

Overview

Introduction

Alipay is a payment method which allows you to process payments in different currencies by using e-wallets China. This method supports purchases and refunds.

This article provides information about working with the Alipay method: general insights are presented in the Overview section, while information about the actions required to process payments and perform other actions is presented in the sections that follow.

General information

Payment method type digital wallet payments
Payment instruments digital wallets
Countries and regions CN
Payment currencies AUD, CAD, CNY, EUR, GBP, HKD, JPY, SGD, USD *
Currency conversion
One-time purchases +
Credential-on-file purchases
Full refunds Refer to your ecommpay key account manager
Partial refunds Refer to your ecommpay key account manager
Payouts
Chargebacks
Notes
  • Alipay supports purchases via web and mobile application versions by using QR code
  • in some cases there is a limit for payment lifetime—30 minutes. For more information refer to the ecommpay key account manager
Onboarding and access fee refer to your ecommpay key account manager; additional information is available in ecommshop
Note:

* For information about available currencies and availability of refunds, refer to your ecommpay key account manager.

Interaction diagram

Payment processing by using the Alipay method involves the merchant's web service, one of ecommpay interfaces, the ecommpay payment platform, and technical facilities of the Alipay service.



Operations support

Various platform interfaces can be used to process payments and perform operations using the Alipay method. Purchases can be processed by using Payment Page, Gate and Dashboard (using payment links), refunds—by using Gate and Dashboard. At the same time, regardless of the interfaces used, the following properties and limitations are applicable.

When working with the Alipay the following properties and limitations are applicable.

Amounts Times ¹
minimum maximum basic threshold
Purchases 10.00 CNY or 1,00 USD 5,000.00 CNY or unlimited USD up to one hour *
Refunds * *

* For more information refer to your ecommpay key account manager.

Note:
  1. The base and threshold times are defined as follows:
    • The base time is the average estimated time between the moment a payment is initiated in the payment platform to the moment the payment result is sent to the web service. The base time evaluation is made on the assumption of normal operation of all technical facilities and communication channels and typical customer behaviour (if any input from the customer is required). Use the base time to estimate when to react to the absence of payment result callbacks or when to check payment status (details).
    • The threshold time is the maximum possible time between the moment a payment is initiated in the payment platform to the moment the web service receives the callback with the payment result. A payment is automatically assigned the decline status if it wasn't processed within the threshold time. For individual customisation of the threshold time limit, contact ecommpay technical support.

Processing scenarios

To perform a purchase by using the Alipay method, you need to redirect the customer to the Alipay service, while to make a refund, you need to receive a request from the customer and notify the customer about the result of the refund via the web service.

Purchases via Payment Page

General information

To process a purchase through Payment Page by using the Alipay method, the merchant's web service is required to send a request with all required parameters and signature to the ecommpay URL and receive a callback with the result. The full sequence and special aspects of purchase processing are provided below.



Figure 4. Purchase processing by using Payment Page: step-by-step description
  1. A customer initiates a purchase in the web service.
  2. The web service sends the request for opening Payment Page to the specified ecommpay URL.
  3. The request for opening Payment Page is sent to the payment platform.
  4. The payment platform receives the request and validates the required parameters and signature.
  5. Payment Page is generated based on the project and request parameters.
  6. Payment Page is displayed to the customer.
  7. The customer selects the Alipay method.
  8. The payment platform receives the request for processing the payment by using the Alipay method.
  9. The payment platform processes the request and sends it to the Alipay service.
  10. The request is processed on the Alipay service side.
  11. The data for redirecting the customer to the Alipay service is sent from the Alipay service to the payment platform.
  12. The data for redirecting the customer is sent from the payment platform to Payment Page.
  13. The customer is redirected to the Alipay service.
  14. The customer completes all required payment steps.
  15. The purchase is processed in the Alipay service.
  16. The Alipay service sends a notification about the result to the payment platform.
  17. The payment platform sends the payment result callback to the web service.
  18. The payment platform sends the result information to Payment Page.
  19. The result information is displayed to the customer on Payment Page.

Information about the formats of requests and callbacks used for processing payments by using the Alipay method via Payment Page is presented further in this section; general information about working with the Payment Page API is presented in Interaction concepts.

Request format

There are several things you need to consider when sending purchase requests by using the Alipay method:

  1. The following parameters required for any payment must be specified:
    • project_id—project identifier obtained from ecommpay during integration
    • payment_id—payment identifier unique within the project
    • payment_currency—payment currency code in the ISO-4217 alpha-3 format
    • payment_amount—payment amount in the smallest currency unit
    • customer_id—customer identifier unique within the project
  2. The following parameters required for any payment must be specified: project_id, payment_id, payment_currency, payment_amount, customer_id.
  3. The available currencies of purchase specify with ecommpay key account manager.
  4. There is one more mandatory parameter—language_code. In the language_code parameter, you must use zh code of Payment Page.
  5. If you need to have the payment form displayed with the Alipay method selected, set the force_payment_method parameter to alipay.
  6. Additionally, any other parameters available for working with Payment Page can be used (details).
  7. After all target parameters are specified, generate a signature (details).

Thus, a correct request for opening the payment form using the Alipay method must contain the project identifier, basic payment information (identifier, amount, and currency code), customer identifier, language code and signature.

{
   "project_id": 120,
   "payment_id": "580",
   "payment_amount": 1000,
   "payment_currency": "CNY",
   "customer_id": "customer1",
   "language_code": "zh",
   "signature": "kUi2x9dKHAVNU0FYldOcZzUCwX6R\/ekpZhkIQg=="
}
Figure 5. Example of sufficient data in a purchase request
{
   "project_id": 120,
   "payment_id": "580",
   "payment_amount": 1000,
   "payment_currency": "CNY",
   "customer_id": "customer1",
   "language_code": "zh",
   "signature": "kUi2x9dKHAVNU0FYldOcZzUCwX6R\/ekpZhkIQg=="
}

Callback format

The Alipay method uses the standard format for callbacks to deliver purchase results. For more information, see Callbacks.

The following is the example of a callback with information about a 10.00 CNY purchase made by the 125 customer in the 201 project.

Figure 6. Example of callback data indicating that the purchase has been processed
 {
        "project_id": 201,
        "payment": {
            "id": "ECT_TEST_155125514200636",
            "type": "purchase",
            "status": "success",
            "date": "2019-02-27T16:01:25+0000",
            "method": "alipay",
            "sum": {
                "amount": 1000,
                "currency": "CNY"
            },
            "description": "ECT_TEST_1551255142006"
        },
        "customer": {
            "id": "125"
        },
        "operation": {
            "id": 20891000000045,
            "type": "sale",
            "status": "success",
            "date": "2019-02-27T16:01:25+0000",
            "created_date": "2019-02-27T15:46:21+0000",
            "request_id": "85d4801f8fa9dead54d315ae19ecb4550201cdcafab",
            "sum_initial": {
                "amount": 1000,
                "currency": "CNY"
            },
            "sum_converted": {
                "amount": 1000,
                "currency": "CNY"
            },
            "provider": {
                "id": 1189,
                "payment_id": "Abe9VAEokJyIqyRcX10TLkz30XQbmK3f",
                "date": "2019-02-27T16:01:24+0000",
                "auth_code": ""
            },
            "code": "0",
            "message": "Success"
        },
        "signature": "T/v8rquB+C0K7TR7sz1vvOrpCsV1/hr9LhIh27fY9PF7Q=="
    }

The following is the example of a callback with information about a declined purchase.

Figure 7. Example of callback data indicating that the purchase has been declined
 {
            "id": "ECT_TEST_1551103453746538344",
            "type": "purchase",
            "status": "decline",
            "date": "2019-02-27T14:41:30+0000",
            "method": "alipay",
            "sum": {
                "amount": 10000,
                "currency": "CNY"
            },
            "description": ""
        },
        "operation": {
            "id": 20370000000023,
            "type": "sale",
            "status": "decline",
            "date": "2019-02-27T14:41:30+0000",
            "created_date": "2019-02-26T13:39:44+0000",
            "request_id": "36e07e85504ec76924432b3d6e59e5d5066ebb",
            "sum_initial": {
                "amount": 10000,
                "currency": "CNY"
            },
            "sum_converted": {
                "amount": 10000,
                "currency": "CNY"
            },
            "provider": {
                "id": 1189,
                "payment_id": "g4Ld5b6iSuzTmukZUj1RVkXNMuYSj07I",
                "date": "2019-02-27T14:41:29+0000",
                "auth_code": ""
            },
            "code": "20105",
            "message": "Insufficient funds on customer account"
        },
        "signature": "EezTcWDrcp8RW2Wb+bLmytXRRWctzaanCrzhw=="
    }

Useful links

The following articles can be useful when implementing purchases via Payment Page:

Purchases via Gate

General information

To process a purchase through Gate by using the Alipay method, the merchant's web service is required to do the following:

  1. Send a request with all the required parameters and signature to the ecommpay URL.
  2. Receive an intermediate callback from the payment platform and redirect the customer to the Alipay service.
  3. Receive the final callback from the payment platform.

The full sequence and special aspects of purchase processing are provided below.



Figure 8. Purchase processing by using Gate: step-by-step description
  1. A customer initiates a purchase by using the Alipay method in the web service.
  2. The web service sends the request for processing the purchase by using Gate to the specified ecommpay URL.
  3. The payment platform receives the request.
  4. The payment platform validates the required parameters and signature in the request.
  5. The payment platform sends the response to the web service with information about the receipt of the request and its validity (details).
  6. The payment platform performs further processing of the request (with parameter consistency check) and sends it to the Alipay service.
  7. The request is processed on the Alipay service side.
  8. The Alipay service sends the redirection data to the payment platform.
  9. The payment platform sends the callback with the redirection data to the web service.
  10. The customer is redirected to the Alipay service.
  11. The customer completes all required payment steps.
  12. The purchase is processed in the Alipay service.
  13. The Alipay service sends the payment result notification to the payment platform.
  14. The payment platform sends the payment result callback to the web service.
  15. The customer receives the payment result information from the web service.

Information about the formats of requests and callbacks used for processing payments by using the Alipay method via Gate is presented further in this section. General information about working with the Gate API is presented in Interaction concepts.

Request format

There are several things you need to consider when sending purchase requests by using the Alipay method:

  1. To initiate each purchase, send a separate POST request to the /v2/payment/wallet/alipay/sale endpoint. This endpoint belongs to the group /v2/payment/wallet/{payment_method}/sale.
  2. Each request must include the following objects and parameters:
    • Object general—general purchase information:
      • project_id—project identifier obtained from ecommpay during integration
      • payment_id—payment identifier unique within the project
      • signature—request signature generated after all required parameters are specified (details—in the Signature generation and verification) (details)
    • Object payment—payment information:
      • amount—payment amount in the smallest currency unit
      • currency—payment currency code in the ISO-4217 alpha-3 format
      • description*—description or comment to the payment
    • Object customer—customer information:
      • id—customer identifier unique within the project
      • ip_address—customer IP address relevant for the initiated payment
      • first_name*—customer first name
      • last_name*—customer last name
      • phone*—customer phone number without +
      • email*—customer email
      • zip*—customer postal code
      • country*—customer country of residence in the ISO 3166-1 alpha-2 format
      • city*—customer city of residence in Chinese
      • street*—customer address of residence in Chinese
    • Object return_url—contains the URLs to which customer is redirected during or after payment processing:
      • success*—URL for redirecting a customer after a performed purchase
      • return—URL for redirecting a customer during a purchase
    Note: * Refer to your ecommpay key account manager for more information on the necessity of using theses parameters. If any of these parameters are missing, the payment platform may send the list of missing parameters in a callback requesting additional information submission (details are available in Submission of additional payment information).
  3. The available currencies of purchase specify with ecommpay key account manager.
  4. Additionally, any other parameters included in the specification can be used.

Thus, a correct purchase request by using the Alipay method must contain the project identifier, basic payment information (identifier, amount, and currency code), customer information, URLs for redirection and signature.

{
  "general": {
    "project_id": 201,
    "payment_id": "ECT_TEST_155125514400636",
    "signature": "cMlzFj8zqZJbum1w62aewWX7xcG+Ttb0fhuenWNptFZg=="
  },
  "customer": {
    "id": "123",
    "ip_address": "192.0.2.0",
    "first_name": "之的",
    "last_name": "张",
    "phone": "13632264148",
    "email": "2524243674@example.com",
    "street":"street",
    "city": "city",
    "zip": "123045608",
    "country": "CH"
  },
  "payment": {
    "amount": 1000,
    "currency": "CNY",
    "description": "test payment"
  },
   "return_url": {
    "return": "http://example.com/return",
    "success": "http://example.com/success"
    }
}
Figure 9. Example of sufficient data in a purchase request
{
  "general": {
    "project_id": 201,
    "payment_id": "ECT_TEST_155125514400636",
    "signature": "cMlzFj8zqZJbum1w62aewWX7xcG+Ttb0fhuenWNptFZg=="
  },
  "customer": {
    "id": "123",
    "ip_address": "192.0.2.0",
    "first_name": "之的",
    "last_name": "张",
    "phone": "13632264148",
    "email": "2524243674@example.com",
    "street":"street",
    "city": "city",
    "zip": "123045608",
    "country": "CH"
  },
  "payment": {
    "amount": 1000,
    "currency": "CNY",
    "description": "test payment"
  },
   "return_url": {
    "return": "http://example.com/return",
    "success": "http://example.com/success"
    }
}

Formats of intermediate callbacks for customer redirection

To redirect a customer from the web service to the Alipay service, a callback containing redirection data is sent to the web service. Depending on the provider processing the payment a URL or a QR code can be used for customer redirection:

  • URL—in this case the callback contains the redirect_data object
  • QR code—in this case the callback contains the display_data array

Refer to your ecommpay key account manager regarding the appropriate redirection type.

Object redirect_data

Each payment made with the Alipay method requires redirection of customers from the merchant's web service to the Alipay service. To redirect a customer it is necessary to receive an intermediate callback from the payment platform and use the information included in the redirect_data object. The format of such callbacks is standard (details), and the following objects and parameters are included in the redirect_data object:

  • body—object with data to be sent in the request body
  • method—parameter specifying the HTTP method for sending the request (GET or POST)
  • url—parameter containing a link for redirection
Figure 10. redirect_data example
"redirect_data": {
            "method": "POST",
            "body": {
                "order_no": "29895000000582",
                "amount": "13.00",
                "payment_channel": "ALIPAY",
                "sign": "****************",
                "return_url": "https://example.com/process/wsid=njf2h9cd3",
                "signType": "RSA",
                "currency": "CNY",
                "body": "ECT_TEST_1552972940011",
                "app_id": "4391"
            },
            "encrypted": [],
            "url": "https://example.com:443/payment/otoSoft/v3/h5.html"
        }

Array display_data

To redirect a customer from the web service to the Alipay site, you must receive a callback from the payment platform containing the display_data array. This array can contain one or more objects with the following parameters:

  • type—object type
  • title—object title
  • data—data corresponding to the object type

The display_data array is formed taking into account the following conditions:

  • The object containing data for displaying the QR code is always present in the array. The value of the data parameter depends on the value of the type parameter which can have one of the following values:
    • qr_url—QR code is passed as a link the image. In this case the data parameter contains a URL.
    • qr_img—QR code is passed as an image. In this case the data parameter contains a string encoded using the Base64 scheme.
    • qr_data—QR code is passed as a string. In this case the data parameter contains a string which should be used to generate a QR code on the web service side.
  • In addition to the object containing the data for displaying the QR-code the display_data array can contain one or several objects with additional information. The type parameter of such objects is assigned the add_info value, while the data parameter can contain various information.
  • If the array contains one or more objects with additional information, then the array includes an object with the information on the lifespan of the QR code (starting when the code is created on the Alipay side). The title parameter of such an object is assigned the QR Code Timeout value, while the lifespan is specified in seconds in the data parameter.

The following is the callback fragment containing the string to be used to generate a QR code as well as the lifespan of the code.

 "display_data": [
            {
                "type": "qr_data",
                "title": "QR code",
                "data": "weixin://wxpay/bizpayurl?pr=dMrSpJG"
            },
            {
                "type": "add_info",
                "title": "QR Code Timeout",
                "data": "600"
            }
        ]

Callback format

The Alipay method uses the standard format for callbacks to deliver purchase results. For more information, see Callbacks.

The following is the example of a callback with information about a 10.00 CNY purchase made by the 125 customer in the 201 project.

Figure 11. Example of callback data indicating that the purchase has been processed
 {
        "project_id": 201,
        "payment": {
            "id": "ECT_TEST_155125514200636",
            "type": "purchase",
            "status": "success",
            "date": "2019-02-27T16:01:25+0000",
            "method": "alipay",
            "sum": {
                "amount": 1000,
                "currency": "CNY"
            },
            "description": "ECT_TEST_1551255142006"
        },
        "customer": {
            "id": "125"
        },
        "operation": {
            "id": 20891000000045,
            "type": "sale",
            "status": "success",
            "date": "2019-02-27T16:01:25+0000",
            "created_date": "2019-02-27T15:46:21+0000",
            "request_id": "85d4801f8fa9dead54d315ae19ecb4550201cdcafab",
            "sum_initial": {
                "amount": 1000,
                "currency": "CNY"
            },
            "sum_converted": {
                "amount": 1000,
                "currency": "CNY"
            },
            "provider": {
                "id": 1189,
                "payment_id": "Abe9VAEokJyIqyRcX10TLkz30XQbmK3f",
                "date": "2019-02-27T16:01:24+0000",
                "auth_code": ""
            },
            "code": "0",
            "message": "Success"
        },
        "signature": "T/v8rquB+C0K7TR7sz1vvOrpCsV1/hr9LhIh27fY9PF7Q=="
    }

The following is the example of a callback with information about a declined purchase.

Figure 12. Example of callback data indicating that the purchase has been declined
 {
            "id": "ECT_TEST_1551103453746538344",
            "type": "purchase",
            "status": "decline",
            "date": "2019-02-27T14:41:30+0000",
            "method": "alipay",
            "sum": {
                "amount": 10000,
                "currency": "CNY"
            },
            "description": ""
        },
        "operation": {
            "id": 20370000000023,
            "type": "sale",
            "status": "decline",
            "date": "2019-02-27T14:41:30+0000",
            "created_date": "2019-02-26T13:39:44+0000",
            "request_id": "36e07e85504ec76924432b3d6e59e5d5066ebb",
            "sum_initial": {
                "amount": 10000,
                "currency": "CNY"
            },
            "sum_converted": {
                "amount": 10000,
                "currency": "CNY"
            },
            "provider": {
                "id": 1189,
                "payment_id": "g4Ld5b6iSuzTmukZUj1RVkXNMuYSj07I",
                "date": "2019-02-27T14:41:29+0000",
                "auth_code": ""
            },
            "code": "20105",
            "message": "Insufficient funds on customer account"
        },
        "signature": "EezTcWDrcp8RW2Wb+bLmytXRRWctzaanCrzhw=="
    }

Useful links

The following articles can be useful when implementing purchases via Gate:

Refunds by using Gate

General information

To perform a refund through Gate by using the Alipay method, send a request with all required parameters and signature to the ecommpay URL and receive a callback with the result. The full sequence and special aspects of refund performing are provided below.



Figure 13. Refund performing by using Gate: step-by-step description
  1. A customer initiates a refund.
  2. The web service sends the request for performing the refund by using Gate to the specified ecommpay URL.
  3. The payment platform receives the request.
  4. The payment platform validates the required parameters and signature in the request.
  5. The payment platform sends the response to the web service with information about the receipt of the request and its validity (details).
  6. The payment platform performs further processing of the request (with parameter consistency check) and sends it to the Alipay service.
  7. The refund is processed on the side of the Alipay service.
  8. The Alipay service sends the result notification to the payment platform.
  9. The payment platform sends the result callback to the web service.
  10. The customer receives the refund result information from the web service.

Information about the formats of requests and callbacks used for performing refunds by using the Alipay method via Gate is presented further in this section. General information about working with the Gate API is presented in Interaction concepts.

Request format

There are several things you need to consider when sending refund requests by using the Alipay method:

  1. To initiate each refund, send a separate POST request to the /v2/payment/wallet/alipay/refund endpoint. This endpoint belongs to the group /v2/payment/wallet/{payment_method}/refund.
  2. Each request must include the following objects and parameters:
    • Object general—general refund information:
      • project_id—project identifier obtained from ecommpay during integration
      • payment_ididentifier of the payment that needs to be refundedpayment identifier
      • signature—request signature generated after all required parameters are specified (details—in the Signature generation and verification)
    • Object payment—refund information:
      • description—refund description or comment
      • amount—refund amount in the smallest currency unit (required for a partial refund)
    • Object customer—customer information:
      • ip_address—customer IP address relevant for the initiated refund
  3. Additionally, any other parameters included in the specification can be used.

Thus, a correct refund request by using the Alipay method must contain the project and payment identifiers, description of the refund, the customer IP address, signature, and, if necessary, refund amount.

  "general": {    
    "project_id": 239,    
    "payment_id": "refund_02",   
    "signature": "of8k9xerKSK40CIcjmOwSwKJ7KLTZYO56lCv+f1M0Sf/7eg=="
  },  
   "customer": {    
     "ip_address": "192.0.2.0" 
 },  
  "payment": {    
    "amount": 10000,    
    "description": "refund_02"
}
Figure 14. Example of sufficient data in a refund request
  "general": {    
    "project_id": 239,    
    "payment_id": "refund_02",   
    "signature": "of8k9xerKSK40CIcjmOwSwKJ7KLTZYO56lCv+f1M0Sf/7eg=="
  },  
   "customer": {    
     "ip_address": "192.0.2.0" 
 },  
  "payment": {    
    "amount": 10000,    
    "description": "refund_02"
}

Callback format

The Alipay method uses the standard format for callbacks to deliver refund results. For more information, see Callbacks.

Useful links

The following articles can be useful when implementing refunds via Gate:

Testing

General information

For the Alipay method, it is possible to test purchases by using Payment Page and Gate, as well as refunds by using Gate. To enable and disable testing, as well getting assistance with setting up a test project, refer to ecommpay technical support.

When testing payments and operations keep in mind that the test project identifier must be indicated in requests, the interfaces of the emulator of Payment Page and Alipay payment forms can differ from the production environment.

Statuses of test payments and operations

The final status of test payments and operations is determined by the amount specified in the request.

Test purchases:

  • decline status with 40000 or 40400 amount
  • success status with any other amount

Test refunds:

  • decline status with 50000 or 50500 amount
  • success status with any other amount

Purchases by using Payment Page

To perform a test purchase by using Payment Page:

  1. Send a correct test request for opening Payment Page to the payment platform.
  2. If the alipay method was not specified in the request—select the method on the emulator page.
  3. Make sure that the payment instructions are displayed and click the Pay button.
  4. Specify a random last name in the data entry field.
  5. Click the Success or Decline button (depending on the amount specified in the request).
  6. Receive the final callback with information about the payment result.

More information about processing purchases by using the Alipay method via Payment Page is provided in the Purchases via Payment Page section.

Purchases by using Gate

To perform a test purchase by using Gate, do the following:

  1. Send a correct test request for purchase to the payment platform.
  2. Receive the intermediate callback with the redirection data.
  3. Go to the received URL and click the Success or Decline button (depending on the amount specified in the request).
  4. Receive the final callback with information about the payment result.

More information about processing purchases by using the Alipay method via Gate is provided in the Purchases via Gate section.

Refunds by using Gate

To perform a test refund by using Gate, send a valid test request for a refund of a previously processed test purchase to the payment platform and receive a final callback with information about the refund result. More information about performing refunds by using the Alipay method via Gate is provided in the Refunds by using Gate section.

Analysis of payments results

To analyse information about payments made with the Alipay method and other methods, you can use:

  • Dashboard interface toolkit with various lists and analytic panels.
  • Reports in CSV file format, available via the Reports section (one-time and periodically).
  • Data in JSON format, sent by program requests to a specified URL available by using the Data API interface.

If you have any questions, refer to the documentation (Dashboard and Using Data API) and ecommpay technical support.