Apple Pay 会话
POST
/api/v1/bank/public/charge/applepay/{uuid}/session公共端点
此端点在 Apple Pay 支付流程中从浏览器调用。当用户点击 Apple Pay 按钮时,您的 JavaScript 调用 ApplePaySession.onvalidatemerchant,该操作会触发此端点,向 Apple 服务器验证 A55 作为支付处理商的身份。
请求头
| 请求头 | 值 | 必填 |
|---|---|---|
Content-Type | application/json | 是 |
路径参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
uuid | string (UUID) | 是 | Apple Pay 支付的收费 UUID |
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
validation_url | string | 是 | 来自 onvalidatemerchant 事件的 Apple 商户验证 URL |
domain | string | 是 | 您的网站域名(例如 www.your-store.com) |
display_name | string | 否 | Apple Pay 界面上显示的商户名称 |
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
merchant_session | object | 不透明的 Apple Pay 会话对象——传递给 completeMerchantValidation() |
merchant_session.epochTimestamp | number | 会话创建时间戳 |
merchant_session.expiresAt | number | 会话过期时间戳 |
merchant_session.merchantSessionIdentifier | string | Apple 会话 ID |
merchant_session.merchantIdentifier | string | Apple 商户 ID |
HTTP 状态码
| 状态码 | 说明 |
|---|---|
| 200 | 商户会话已创建 |
| 400 | validation_url 或域名无效 |
| 404 | 收费未找到或不是 Apple Pay 收费 |
| 409 | 此收费已创建会话 |
| 422 | 域名未在 Apple Pay 注册 |
| 429 | 超出请求频率限制 |
| 500 | 服务器内部错误 |
代码示例
- cURL
- Python
- Node.js
curl -s -X POST "https://core-manager.a55.tech/api/v1/bank/public/charge/applepay/a1b2c3d4-e5f6-7890-abcd-ef1234567890/session" \
-H "Content-Type: application/json" \
-d '{
"validation_url": "https://apple-pay-gateway.apple.com/paymentservices/startSession",
"domain": "www.your-store.com",
"display_name": "示例商户"
}'
import requests
charge_uuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
try:
response = requests.post(
f"https://core-manager.a55.tech/api/v1/bank/public/charge/applepay/{charge_uuid}/session",
json={
"validation_url": "https://apple-pay-gateway.apple.com/paymentservices/startSession",
"domain": "www.your-store.com",
"display_name": "示例商户",
},
headers={"Content-Type": "application/json"},
)
response.raise_for_status()
session = response.json()
print(f"会话 ID:{session['merchant_session']['merchantSessionIdentifier']}")
except requests.exceptions.HTTPError as e:
print(f"HTTP {e.response.status_code}: {e.response.json()}")
except requests.exceptions.RequestException as e:
print(f"请求失败:{e}")
const chargeUuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
try {
const response = await fetch(
`https://core-manager.a55.tech/api/v1/bank/public/charge/applepay/${chargeUuid}/session`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
validation_url: "https://apple-pay-gateway.apple.com/paymentservices/startSession",
domain: "www.your-store.com",
display_name: "示例商户",
}),
}
);
if (!response.ok) throw new Error(`请求失败(HTTP ${response.status}):${await response.text()}`);
const { merchant_session } = await response.json();
// 传递给 ApplePaySession.completeMerchantValidation(merchant_session)
console.log(`会话:${merchant_session.merchantSessionIdentifier}`);
} catch (error) {
console.error("Apple Pay 会话失败:", error.message);
}
错误响应示例
{
"status": "error",
"message": [
{
"code": "DOMAIN_NOT_REGISTERED",
"source": "applepay",
"description": "Domain www.your-store.com is not registered for Apple Pay. Register it in the A55 dashboard."
}
]
}