创建Token
创建支付Token以安全存储客户支付信息。Token用于创建订阅,具有24小时有效期以确保安全性。
POSThttps://api.efundpay.com/v4/tokens
This endpoint requires the
subscriptions.write
scope.Authorizations
Authorizationstringheaderrequired
Bearer认证头,格式为 `Bearer <token>`,其中 `<token>` 是您的认证令牌。
Headers
x-merchant-account-idstringrequired
用于此请求的商户账户ID。
Examples:
""default""
Body
application/jsonexternal_identifierstringrequired
此Token的商户引用标识。用于在您的系统中识别Token。
Length:1 - 64
Examples:
"token-12345"
amountintegerrequired
订阅金额,以分为单位(最小货币单位)。
Examples:
"1000"
"2999"
currencystringrequired
订阅货币(ISO 4217格式)。
Examples:
"USD"
"EUR"
customerobjectrequired
客户信息对象。
payment_methodobjectrequired
支付方式信息对象。如果商户没有PCI资质,请使用收银台模式重定向到收银台支付页面收集卡信息。
billing_detailsobject
此Token的账单详情。
cart_itemsarray
表示Token行项目的购物车项目数组。
browser_infoobject
客户使用的浏览器信息。**直接API模式下必需**。这可用于反欺诈服务。
metadataobject
用于附加信息的自定义键值对。
Examples:
"{"source": "website", "campaign": "summer_promotion"}"
Response
application/json
Successful Response
idstring | null
唯一Token标识符。如果为null,用户需要通过payment_url_link完成支付。Token ID将在支付成功后通过webhooks返回。
Examples:
"token_1234567890abcdef"
"null"
objectstringrequired
对象类型,始终为"token"。
Examples:
"token"
createdstringrequired
Token创建时间(ISO 8601)。
Examples:
"2025-08-12T09:00:00Z"
amountintegerrequired
订阅金额,以分为单位(最小货币单位)。
Examples:
"1000"
currencystringrequired
订阅货币(ISO 4217格式)。
Examples:
"USD"
customerobjectrequired
带有生成ID的客户信息。
payment_methodobjectrequired
支付方式信息。
expires_atstringrequired
Token到期时间(ISO 8601)。
Examples:
"2025-08-13T09:00:00Z"
payment_url_linkstring | null
完成此Token支付的URL。**当id为null时必需**。用户必须通过此链接完成支付才能通过webhooks接收Token ID。
Examples:
"https://pay.efundpay.com/token/abc123"
"null"
curl --request POST \--url https://api.efundpay.com/v4/tokens \--header 'Authorization: Bearer <token>' \--header 'x-merchant-account-id: <x-merchant-account-id>' \--header 'Content-Type: application/json' \--data '{"external_identifier": "token-12345","amount": 1000,"currency": "USD","customer": {"display_name": "John Doe","external_identifier": "customer-12345","first_name": "John","last_name": "Doe","email_address": "john@example.com","phone_number": "+1234567890","account_number": "123456789"},"payment_method": {"payment_channel_code": "card","type": "card","webhooks_url": "https://merchant.com/webhooks/token","card": {"number": "4111111111111111","expiration_date": "12/27","security_code": "123"}},"cart_items": [{"name": "Premium Plan","description": "Premium subscription plan with advanced features","quantity": 1,"unit_amount": 1000,"discount_amount": 0,"tax_amount": 0,"external_identifier": "premium-plan","sku": "PREMIUM001","product_url": "https://example.com/catalog/premium-plan","image_url": "https://example.com/images/premium-plan.jpg","categories": ["subscription", "premium", "feature"],"product_type": "service"}],"browser_info": {"javascript_enabled": true,"java_enabled": false,"language": "en-US","color_depth": 24,"screen_height": 1080,"screen_width": 1920,"time_zone_offset": -480,"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","user_device": "desktop","accept_header": "*/*"},"billing_details": {"first_name": "John","last_name": "Doe","email_address": "john@example.com","phone_number": "+1234567890","address": {"city": "San Jose","country": "US","postal_code": "94560","state": "California","state_code": "US-CA","house_number_or_name": "10","line1": "Stafford Appartments","line2": "29th Street","organization": "EFundFlow"}}}'
{"id": null,"object": "token","created": "2025-08-12T09:00:00Z","amount": 1000,"currency": "USD","customer": {"id": "cus_abc123","display_name": "John Doe","external_identifier": "customer-12345","first_name": "John","last_name": "Doe","email_address": "john@example.com","phone_number": "+1234567890","account_number": "123456789"},"payment_method": {"type": "card","card": {"brand": "visa","last4": "4242","exp_month": 12,"exp_year": 2027}},"expires_at": "2025-08-13T09:00:00Z","payment_url_link": "https://pay.efundpay.com/token/abc123"}