Create a PaymentIntent
POST
/v1/payment_intentsAfter the PaymentIntent is created, attach a payment method and confirm to continue the payment.
When confirm=true is used during creation, it is equivalent to creating and confirming the PaymentIntent in the same call. You may use any parameters available in the confirm API when confirm=true is supplied.
请求参数
Set to true to attempt to confirm this PaymentIntent this PaymentIntent immediately. This parameter defaults to false. When creating and confirming a PaymentIntent at the same time, you can also provide the parameters available in the Confirm a PaymentIntent
If provided, this hash will be used to create a PaymentMethod. The new PaymentMethod will appear in the payment_method property on the PaymentIntent.
Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
Three-letter ISO currency code, in lowercase. Must be a supported currency.
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.
ONLY WHEN CONFIRM=TRUE. The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method’s app or site. If you’d prefer to redirect to a mobile application, you can alternatively supply an application URI scheme. This parameter can only be used with confirm=true.
only when confirm=true. Set to true to indicate that the customer isn’t in your checkout flow during this payment attempt and can’t authenticate
{
"amount": 10,
"currency": "USD",
"confirm": true,
"payment_method_data": {
"type": "card",
"card": {
"exp_month": "12",
"exp_year": "2026",
"number": "4111111111111111",
"cvc": "123"
},
"billing_details": {
"address": {
"line1": "XX mansion",
"line2": "XX Town",
"city": "city",
"state": "California",
"country": "US",
"postal_code": "55555"
},
"name": "Tom"
}
},
"description": "product description",
"quantity": 2,
"metadata": {
"key1": "value1"
},
"merchant_user_id": "123456",
"merchant_order_id": "Order112344343",
"shipping": {
"address": {
"line1": "XX mansion",
"line2": "XX Town",
"city": "city",
"state": "California",
"country": "US",
"postal_code": "xxx xxx"
},
"name": "tom",
"phone": "xxxx"
},
"return_url": "https://your.website"
}
示例代码
Responses
{
"id": "pi_1604012360740110336",
"object": "payment_intent",
"created": 1671261323000,
"currency": "USD",
"amount": 10,
"status": "succeeded",
"description": "product description",
"metadata": {
"key1": "value1"
},
"livemode": false,
"shipping": {
"address": {
"city": "city",
"country": "US",
"line1": "XX mansion",
"line2": "XX Town",
"state": "California",
"postal_code": "xxx xxx"
},
"carrier": null,
"name": "tom",
"phone": "xxxx",
"tracking_number": null
},
"customer": null,
"quantity": 2,
"invoice": null,
"merchant_user_id": "123456",
"merchant_order_id": "Order112344343",
"client_secret": "pi_1604012360740110336_secret_YYFHuk8Lago3RSqjbVFe68AA",
"last_payment_error": null,
"next_action": null,
"payment_method_types": "[\"wechat_pay\",\"alipay\",\"card\"]",
"receipt_email": null,
"canceled_at": null,
"cancellation_reason": null,
"confirmation_method": "automatic",
"payment_method_options": "{\"card\":{\"request_three_d_secure\":\"auto\",\"capture_method\":\"automatic\"}}",
"3ds_status": null,
"amount_capturable": null,
"return_url": "https://your.website",
"payment_method": "pm_1604012357044928512",
"amount_received": null,
"capture_method": "automatic"
}