Create a test Confirmation Token Test helper

Creates a test mode Confirmation Token server side for your integration tests.

Parameters

  • payment_methodstring

    ID of an existing PaymentMethod.

  • payment_method_dataobject

    If provided, this hash will be used to create a PaymentMethod.

  • payment_method_optionsobject

    Payment-method-specific configuration for this ConfirmationToken.

  • return_urlstring

    Return URL used to confirm the Intent.

  • setup_future_usageenum

    Indicates that you intend to make future payments with this ConfirmationToken’s payment method.

    The presence of this property will attach the payment method to the PaymentIntent’s Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete.

    Possible enum values
    off_session

    Use off_session if your customer may or may not be present in your checkout flow.

    on_session

    Use on_session if you intend to only reuse the payment method when your customer is present in your checkout flow.

  • shippingobject

    Shipping information for this ConfirmationToken.

Returns

Returns a testmode Confirmation Token

POST /v1/test_helpers/confirmation_tokens
curl https://api.stripe.com/v1/test_helpers/confirmation_tokens \
-u "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2:" \
-d payment_method=pm_card_visa
Response
{
"id": "ctoken_1Ow71CL4FhS6zgoxWjxc7sfr",
"object": "confirmation_token",
"created": 1710871450,
"expires_at": 1710914650,
"livemode": false,
"payment_intent": null,
"payment_method_preview": {
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "unchecked"
},
"country": "US",
"display_brand": "visa",
"exp_month": 3,
"exp_year": 2025,
"fingerprint": "jbGyCKrSRsFpOBWP",
"funding": "credit",
"generated_from": null,
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"type": "card"
},
"return_url": null,
"setup_future_usage": null,
"setup_intent": null,
"shipping": null,
"use_stripe_sdk": true
}

Tokens 

Tokenization is the process Stripe uses to collect sensitive card or bank account details, or personally identifiable information (PII), directly from your customers in a secure manner. A token representing this information is returned to your server to use. Use our recommended payments integrations to perform this process on the client-side. This guarantees that no sensitive card data touches your server, and allows your integration to operate in a PCI-compliant way.

If you can’t use client-side tokenization, you can also create tokens using the API with either your publishable or secret API key. If your integration uses this method, you’re responsible for any PCI compliance that it might require, and you must keep your secret API key safe. Unlike with client-side tokenization, your customer’s information isn’t sent directly to Stripe, so we can’t determine how it’s handled or stored.

You can’t store or use tokens more than once. To store card or bank account information for later use, create Customer objects or External accounts. Radar, our integrated solution for automatic fraud protection, performs best with integrations that use client-side tokenization.

Payment Methods 

PaymentMethod objects represent your customer’s payment instruments. You can use them with PaymentIntents to collect payments or save them to Customer objects to store instrument details for future payments.

Related guides: Payment Methods and More Payment Scenarios.

Payment Method Configurations 

PaymentMethodConfigurations control which payment methods are displayed to your customers when you don’t explicitly specify payment method types. You can have multiple configurations with different sets of payment methods for different scenarios.

There are two types of PaymentMethodConfigurations. Which is used depends on the charge type:

Direct configurations apply to payments created on your account, including Connect destination charges, Connect separate charges and transfers, and payments not involving Connect.

Child configurations apply to payments created on your connected accounts using direct charges, and charges with the on_behalf_of parameter.

Child configurations have a parent that sets default values and controls which settings connected accounts may override. You can specify a parent ID at payment time, and Stripe will automatically resolve the connected account’s associated child configuration. Parent configurations are managed in the dashboard and are not available in this API.

Related guides:

Payment Method Domains 

A payment method domain represents a web domain that you have registered with Stripe. Stripe Elements use registered payment method domains to control where certain payment methods are shown.

Related guide: Payment method domains.