创建支付意图
创建支付意图后,请绑定支付方式并确认该意图以完成交易。
在创建时使用 confirm=true 相当于在同一调用中同时创建并确认支付意图。应用 confirm=true 可启用 confirm API 中的所有参数。
POST https://api.stripe.com/v1/payment_intents
备注
您必须通过 HTTPS 提交 confirm 请求。
示例
cURL 示例:
cURL
curl -X POST https://api.stripe.com/v1/payment_intents \
-u <YOUR_SECRET_KEY>: \
-d "amount=212¤cy=usd&payment_method=pm_card_visa&confirm=true"
响应
响应返回标准代码。
200: OK
Response
{
"id": "pi_3Rsx4dDtWMrPDtgt0mUrePJ9",
"object": "payment_intent",
"amount": 212,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": {
"allow_redirects": "always",
"enabled": true
},
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic_async",
"client_secret": "pi_3Rsx4dDtWMrPDtgt0mUrePJ9_secret_7sqfufxuIYiBhbw52Vi51Z47o",
"confirmation_method": "automatic",
"created": 1754447247,
"currency": "usd",
"customer": null,
"description": null,
"last_payment_error": null,
"latest_charge": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_configuration_details": {
"id": "pmc_1RsGk1DtWMrPDtgtcaQ0d3Sg",
"parent": null
},
"payment_method_options": {
"amazon_pay": {
"express_checkout_element_session_id": null
},
"card": {
"installments": null,
"mandate_options": null,
"network": null,
"request_three_d_secure": "automatic"
},
"cashapp": {},
"klarna": {
"preferred_locale": null
},
"link": {
"persistent_token": null
}
},
"payment_method_types": [
"card",
"klarna",
"link",
"cashapp",
"amazon_pay"
],
"processing": null,
"receipt_email": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
}
错误响应
400: Bad Request
Response
{
"error": {
"code": "parameter_invalid_integer",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-integer",
"message": "Invalid integer: <integer>",
"param": "amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_UQf6XBwBl9yk66?t=1734829676",
"type": "invalid_request_error"
}
}
401: Unauthorized
Response
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API Key provided: sk_test_********************1234"
}
}
参数
正文参数
| 参数 | 类型 | 说明 |
|---|---|---|
amount | 整数 | (必填) 要收取的总金额。请输入以该货币最小单位格式表示的正整数(例如,1.00 美元即为 100 美分)。 |
currency | 字符串 | (必填) 三字母 ISO 货币代码,小写。必须是受支持的货币。 |
confirm | 布尔值 | 设置为 true 以尝试立即确认此 PaymentIntent。 |
customer | 字符串 | 该 PaymentIntent 所属的客户 ID(如有)。 |
description | 字符串 | 附加到对象上的任意字符串。 |
payment_method | 字符串 | 要附加到此 PaymentIntent 上的支付方式的 ID。 |
payment_method_types[] | 字符串数组 | 此 PaymentIntent 可使用的支付方式类型列表。 |
shipping | 对象 | PaymentIntent 的配送信息。 |
statement_descriptor | 字符串 | 显示在客户信用卡账单上的任意字符串。 |
statement_descriptor_suffix | 字符串 | 提供将在客户信用卡账单上显示的附加详细信息。 |
expand[] | 字符串数组 | 用于标识需要进行数据增强并内联返回的嵌套响应对象。 |