Apple Pay session validation request
This method proxies the Apple Pay merchant validation through the payment processor. Call this endpoint from the onvalidatemerchant callback of your ApplePaySession.
This endpoint is only available for operations initialized with payment_method.type: APPLE_PAY. Calling it on a Google Pay operation returns a 400 error.
Decode the returned session_data (base64) and pass the parsed JSON to session.completeMerchantValidation().
Security: The validationURL is validated to ensure it points to a legitimate Apple Pay gateway host (apple-pay-gateway*.apple.com). Only HTTPS URLs are accepted.
- URL syntax: /api/v2/merchant/payment/{id}/wallet/applepay/session
- Method: POST
Request parameters
| Name | Type | Details | Mandatory | Description |
|---|---|---|---|---|
| id | integer | Path parameter | Y | Operation ID returned by the init endpoint. |
| validationURL | string | URI | Y | The validation URL from the onvalidatemerchant event. Must be an Apple Pay gateway URL (https://apple-pay-gateway*.apple.com/...). |
| domain | string | Y | The domain where the Apple Pay button is displayed. |
Example request
{
"validationURL": "https://apple-pay-gateway.apple.com/paymentservices/startSession",
"domain": "checkout.mystore.com"
}
Response parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| session_data | string | Y | Base64-encoded Apple Pay merchant session JSON. Decode and parse as JSON, then pass the resulting object to session.completeMerchantValidation(). |
Usage: JSON.parse(atob(response.session_data))
Example response
{
"session_data": "eyJlcG9jaFRpbWVzdGFtcCI6MTcwODMwMDAwMDAwMCwiZXhwaXJlc0F0IjoxNzA4MzAzNjAwMDAwLCJtZXJjaGFudFNlc3Npb25JZGVudGlmaWVyIjoiU1NIMTIzNDU2Nzg5MCJ9"
}
Error responses
Not an Apple Pay operation (400)
{
"error_code": 400,
"errors": [
{
"class": "error",
"message": "Apple Pay session validation is only available for Apple Pay payments"
}
]
}
Missing validationURL (400)
{
"error_code": 400,
"errors": [
{
"class": "error",
"property": "validationURL",
"message": "validationURL is required"
}
]
}
Invalid validationURL host (400)
{
"error_code": 400,
"errors": [
{
"class": "error",
"property": "validationURL",
"message": "validationURL must be an Apple Pay gateway URL"
}
]
}
Missing domain (400)
{
"error_code": 400,
"errors": [
{
"class": "error",
"property": "domain",
"message": "domain is required"
}
]
}
Init not called (400)
{
"error_code": 400,
"errors": [
{
"class": "error",
"message": "Apple Pay session not initialized"
}
]
}
Payment processor failure (502)
{
"error_code": 502,
"errors": [
{
"class": "error",
"message": "Failed to validate merchant with Apple Pay"
}
]
}