Setup
Please follow the common Adyen instructions to get set up with Alipay.
Next, make sure to enable Alipay as a payment method on your configured account.
Testing
Adyen has instructions on how to test Alipay.
Integration
For the alternative payment methods the default integration for Adyen is through a redirect to a hosted payments page.
Redirect integration
Start by creating a new transaction with the following required fields.
{
"amount": 100,
"currency": "EUR",
"country": "NL",
"intent": "capture",
"payment_method": {
"method": "<method>",
"redirect_url": "https://example.com/callback",
"country": "NL",
"currency": "EUR"
}
}
Please use "" for the value of the <method>.
After the transaction is created, the API response includes
payment_method.approval_url and the transaction will be in the
buyer_approval_pending state.
{
"type": "transaction",
"id": "ea1efdd0-20f9-44d9-9b0b-0a3d71e9b625",
"payment_method": {
"type": "payment-method",
"approval_url": "https://cdn.sandbox.spider.gr4vy.app/connectors/adyen/apm.html?token=..."
},
"method": "<method>"
}
Redirect the buyer to the approval_url (open in a browser or Webview) so they can complete authentication and approve the payment.
After approval the buyer is redirected to the redirect_url you provided when creating the transaction.
Do not rely solely on the redirect — either poll the transaction or (recommended) rely on webhooks to detect the final status (for example capture_succeeded or failure states).
Direct integration
Adyen provides web,
Android
and iOS for a direct integration. For these flows you should indicate the platform by setting an appropriate integration_client
when creating the transaction, and then build a client-side integration that uses the POST /transactions/:transaction_id/session API to initialize the Adyen SDK.
To start, create a new transaction with the appropriate integration_client.
POST /transactions
{
"amount": 100,
"currency": "EUR",
"country": "NL",
"intent": "capture",
"integration_client": "web",
"payment_method": {
"method": "<method>",
"redirect_url": "https://example.com/callback",
"country": "NL",
"currency": "EUR"
}
}
Please use "" for the value of the <method>.
After the transaction is created, the API response includes a session_token which can be used to get the session data for that transaction.
POST /transactions/:transaction_id/session?token=:session_token
{
"session_data": {
"sessionId": "CS04C0B8AC9849A7D8E25B20D",
"sessionData": "Ab02b4c0!BQABAgBLgbLpvkt1r3",
"environment": "live",
"clientKey": "client-key",
"returnUrl": "https://example.com/callback",
"paymentMethod": "<method>",
"storePaymentMethod": true // this is an optional key
},
"default_completion_url": "https://api.sandbox.spider.gr4vy.app/transactions/approve/some-token",
"integration_client": "web"
}
This session data provides the sessionId and sessionData required to load the Adyen SDK.
// Determine the URL of the script, and the method to invoke on the Adyen SDK
const adyenEnvironment = sessionData.environment;
const clientKey = sessionData.clientKey;
const sessionId = sessionData.sessionId;
const adyenSessionData = sessionData.sessionData;
const returnUrl = sessionData.returnUrl;
const paymentMethod = sessionData.paymentMethod;
const storePaymentMethod = sessionData.storePaymentMethod;
const configuration = {
environment: adyenEnvironment,
clientKey,
analytics: {
enabled: false,
},
session: {
id: sessionId,
sessionData: adyenSessionData,
},
paymentMethodsConfiguration: {
cashapp: { // only cashapp requires this configuration
storePaymentMethod: storePaymentMethod,
},
},
}
AdyenCheckout(configuration).then(function (checkout) {
let component = checkout
.create(paymentMethod)
.mount('#component');
});
Mobile redirect integration completion
On Mobile integrations, after the buyer completes the payment flow, send a GET request to the default_completion_url provided in the session response with the sessionId and the redirectResult as query parameters
to finalize the transaction. Related docs
The call return a 204 No Content response. After receiving the 204 response, you can poll the transaction or rely on webhooks to detect the final status.
// When you are handling the redirect
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if url.absoluteString.starts(with: RedirectComponent.redirectResultScheme) {
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
let queryItems = components?.queryItems
let redirectResult = queryItems?.first(where: { $0.name == "redirectResult" })?.value
var urlComponents = URLComponents(string: defaultCompletionUrl)!
urlComponents.queryItems = [
URLQueryItem(name: "sessionId", value: /* your session id */),
URLQueryItem(name: "redirectResult", value: redirectResult)
]
var request = URLRequest(url: urlComponents.url!)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
// Handle 204 response, you can now poll the transaction
}
task.resume()
return true
}
return false
}
Please refer to the Adyen documentation for the web,
Android
and iOS for further guidance