POST /api/v1/apple-pay/merchant-session
Request an Apple Pay merchant session for use with the Apple Pay JS API.
The origin must match a registered payment page domain. Pass the returned session object to completeMerchantValidation() in the Apple Pay JS API.
Guide: Apple Pay Guide — conceptual walkthrough, flow diagrams, and integration patterns.
Headers
| Header | Value |
|---|---|
Content-Type | application/json |
Authorization | Bearer {token} — see Authentication |
Request Body Parameters
| Field | Type | Required | Description |
|---|---|---|---|
validationUrl | String | Yes | Apple's validation URL provided by the Apple Pay JS API on the client side |
origin | String | Yes | Origin of the page requesting the session (e.g. https://checkout.your-site.com). Must match a registered payment page domain |
intentToken | String | Yes | Payment intent token used to look up the intent and its Apple Pay configuration |
Response
Returns an opaque Apple Pay session object as JSON. Pass it directly to completeMerchantValidation() in the Apple Pay JS API. Do not parse or modify it.
Example Request
{
"validationUrl": "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession",
"origin": "https://checkout.your-site.com",
"intentToken": "your-intent-token"
}Error Responses
| HTTP Status | Description |
|---|---|
400 | Bad Request — missing or invalid parameters |
401 | Unauthorized — missing, expired, or invalid bearer token |
404 | Not Found — the requested resource does not exist |
500 | Internal Server Error — unexpected error, retry with backoff |
Code Examples
cURL
curl -X POST https://sandbox.facilero.com/api/v1/apple-pay/merchant-session \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"validationUrl": "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession",
"origin": "https://checkout.your-site.com",
"intentToken": "your-intent-token"
}'Python
import requests
url = "https://sandbox.facilero.com/api/v1/apple-pay/merchant-session"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
payload = {
"validationUrl": "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession",
"origin": "https://checkout.your-site.com",
"intentToken": "your-intent-token"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Node.js
const response = await fetch("https://sandbox.facilero.com/api/v1/apple-pay/merchant-session", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN",
},
body: JSON.stringify({
validationUrl: "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession",
origin: "https://checkout.your-site.com",
intentToken: "your-intent-token"
}),
});
const data = await response.json();
console.log(data);Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload := map[string]interface{}{
"validationUrl": "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession",
"origin": "https://checkout.your-site.com",
"intentToken": "your-intent-token",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://sandbox.facilero.com/api/v1/apple-pay/merchant-session", bytes.NewBuffer(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
}Kotlin
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
fun main() {
val client = OkHttpClient()
val json = """
{
"validationUrl": "https://apple-pay-gateway-cert.apple.com/paymentservices/startSession",
"origin": "https://checkout.your-site.com",
"intentToken": "your-intent-token"
}
""".trimIndent()
val body = json.toRequestBody("application/json".toMediaType())
val request = Request.Builder()
.url("https://sandbox.facilero.com/api/v1/apple-pay/merchant-session")
.post(body)
.addHeader("Authorization", "Bearer YOUR_TOKEN")
.build()
client.newCall(request).execute().use { response ->
println(response.body?.string())
}
}
