Menu

Alipay

API v1
Last updated January 2024

Alipay is a popular payment method, for customers based in China, to make payments online from their Alipay eWallet.

Set your headers

Setting your headers is an important part of an API request. The headers represent the meta-data associated with your API request.

Copied!
Authorization: {your_credentials}
Content-Type: application/json
WP-Api-Version: 2023-06-01
HeaderDescription
AuthorizationWe use the Authorization header to identify and authenticate you within Access Worldpay. You must use the Authorization header for any request you send to our APM API, unless you are using client certificate authentication over TLS. If you must use this, read our reference guide onAuthenticating with SSL/TLS.
Content-TypeWe require the Content-Type header if the request you're sending includes a request body, and if the HTTP method is a POST or a PUT.
WP-Api-VersionWe use the Accept header to identify which version of our APM API you are using. You must use the Accept header for any request you send to our API.

If you're using both the Content-Type and WP-Api-Version headers, they must match.

Note: Replace {your_credentials} with your base64-encoded Basic Auth username and password. To get your Access Worldpay credentials contact your Implementation Manager.

Take a payment

POST https://try.access.worldpay.com/apmPayments

Example request

Copied!
{
    "transactionReference": "Memory265-13/08/1876",
    "merchant":
    {
        "entity": "MindPalaceLtd"
    },
    "instruction":
    {
        "narrative":
        {
            "line1": "Mind Palace Ltd"
        },
        "value":
        {
            "amount": 1234,
            "currency": "CNY"
        },
        "paymentInstrument":
        {
            "type": "alipay",
            "country": "CN",
            "shopperEmailAddress": "email@example.com",
            "successURL": "https://example.com/success",
            "pendingURL": "https://example.com/pending",
            "failureURL": "https://example.com/failure",
            "cancelURL": "https://example.com/cancel"
        }
    }
}

Parameters

ParameterRequired?DescriptionData typeLength
instructionAn object that contains all the information related to the payment.ObjectN/A
instruction.narrativeAn object that helps your customers better identify you on their statement.ObjectSee ourformatting rules
instruction.narrative.line1The first line of the narrative which appears on your customer's statement (24 characters max. If a character is not supported it is replaced with a space.).
Seenarrative line1 formatfor more details.
Object24
instruction.paymentInstrumentAn object that contains information about the payment method.ObjectN/A
instruction.paymentInstrument.typeAn object that contains the payment type and details. It defines which alternative payment method you wish to use. Value is alipay or alipay_mobile for a mobile optimized flow.ObjectN/A
instruction.paymentInstrument.countryAn object that contains the country of your customer. Followsalpha 2 ISO 3166-1standard.Object2
instruction.paymentInstrument.shopperEmailAddressAn object that contains your customer's email address.StringN/A
instruction.paymentInstrument.languageAn object that contains the language of your customer. Follows ISO 639-1 standard.String2
instruction.paymentInstrument.cancelURLWhen your customer cancels a transaction, we redirect that customer to the cancel URL.StringN/A
instruction.paymentInstrument.failureURLWhen a payment fails, we redirect your customer to the failure URL.StringN/A
instruction.paymentInstrument.pendingURLWhen we receive the payment result for a pending payment transaction, we redirect your customer to the pending URL.StringN/A
instruction.paymentInstrument.successURLWhen we receive the payment result for a successful payment, we redirect your customer to the success URL.StringN/A
instruction.valueAn object that contains information about the payment transaction.ObjectN/A
instruction.value.amountThe payment amount. This is a whole number with an exponent e.g. if exponent is two, 250 is 2.50. You can find the relevant exponent in ourcurrency table.IntegerN/A
instruction.value.currencyThe payment currency. Refer to the individual APM page for supported currencies.Integer3
merchantAn object that contains information about the merchant.ObjectN/A
merchant.entityDirect your payment to assist with billing, reporting and reconciliation. This is mandatory for Authentication and Queries.
Contact your Implementation Manager for more details.
StringMust be between 1 and 32 characters.
transactionReferenceA unique reference generated by you that is used to identify a payment throughout its lifecycle. Seetransaction reference format.StringMust be between 1 to 64 characters.
instruction.paymentInstrument.languageAn object that contains the language of your customer. Follows ISO 639-1 standard.String2

Recommendation: We suggest you provide the cancelURL,failureURL, pendingURL and successURL attribute to redirect your customer to, once you have received the payment result.

Response

Successful request response

  • an HTTP code 201
  • an id which is unique to the payment, we recommend storing the "id" as this can be used to manage the payment later
  • a url to redirect your customer to the APM provider to complete the payment
  • a link to query the payment status

Example Response

Copied!
{
    "paymentId": "nFxASqw-LV9HE_rr1mMONJmqBDeXmnv5dzt9IxAXgXbfpu0O_8mOnTpFSIM9gnTSygCKQgvlwQdUbu5rExIpJA_5Uq2LEGXXAanycRpxfDPNA-E70zIWdnaMb2gJhC8AIhbOkM6xDiVNu90YCXo2snTzi_k1sEOQnKIAJNTW3Qc",
    "lastEvent": "pending",
    "_links": {
        "self": {
            "href": "https://access.worldpay.com/apmPayments/nFxASqw-LV9HE_rr1mMONJmqBDeXmnv5dzt9IxAXgXbfpu0O_8mOnTpFSIM9gnTSygCKQgvlwQdUbu5rExIpJA_5Uq2LEGXXAanycRpxfDPNA-E70zIWdnaMb2gJhC8AIhbOkM6xDiVNu90YCXo2snTzi_k1sEOQnKIAJNTW3Qc"
        }
    },
    "_actions": {},
    "url": "https://payments.worldpay.com/app/hpp/integration/wpg/corporate?OrderKey="
}

Note: In case of an error, you can get further information in ourerror reference.

Next Steps


Manage your Alipay payment