Create payment method

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Overview

Attach a payment method to a customer using a gateway token. The new payment method is automatically set as the customer's default, and their subscriptions are updated to charge automatically.

Example: A customer adds a new credit card during checkout. Pass the Stripe token to create the payment method and start charging their subscription.


Conditional Requirements

ConditionRequired Fields
Alwayscustomer_id, object_gateway
Stripeobject_id (must match src_, card_, or pm_ prefix)
Tapobject_id (must match card_ prefix), properties.tap_customer_id (must match cus_ prefix)
Vantivobject_id (unique per account), properties.exp_month, properties.exp_year, properties.last4, properties.card_type
Cybersourceobject_id (max 32 chars), properties.exp_month, properties.exp_year, properties.last4, properties.card_type
Braintreeobject_id (unique per account), properties.braintree_customer_id

Validation Constraints

FieldConstraint
customer_idMust exist under the current site and account
object_gatewayMust be a valid, active payment gateway on the account
object_idMust be unique (Stripe: globally unique; Vantiv/Braintree: unique per account)
object_id (Stripe)Validated against Stripe API to confirm token exists
properties.exp_month2 digits (Vantiv, Cybersource)
properties.exp_year4 digits (Vantiv, Cybersource)
properties.last44 digits (Vantiv, Cybersource)
customer_old_provider_idIf provided, must match the same customer as customer_id

Side Effects (All Gateways)

These side effects apply regardless of the payment gateway:

  • Auto-default: The new payment method is automatically set as the customer's default source.
  • Billing update: All of the customer's subscriptions are switched to charge_automatically billing and updated to use the new default payment method. This behavior is enabled by default and can be configured via Billing Settings — see Automatic Collection Method Transition and Automatic Update of Default Payment Method.
  • Event fired: source.created event is dispatched after successful creation.

Side Effects by Payment Gateway

Stripe

BehaviorDetail
External API callValidates the token against Stripe (pm_ tokens retrieved via PaymentMethods API, others via Sources API)
Customer syncIf the customer does not yet exist on Stripe, creates the Stripe customer first
Ownership validationFor pm_ tokens, verifies the payment method belongs to the customer on Stripe
Set default (Stripe sync)Syncs the new default payment method to Stripe so future charges use it automatically
Local effectCreates or updates the payment method record

Braintree

BehaviorDetail
External API callRetrieves and validates the payment method from Braintree
Ownership validationVerifies that braintree_customer_id matches the payment method's customer on Braintree
Integration syncStores the braintree_customer_id as a customer integration ID
Local effectCreates or updates the payment method record

Tap

BehaviorDetail
External API callRetrieves card details from the Tap API
Integration syncStores the tap_customer_id as a customer integration ID
Local effectCreates or updates the payment method record with card properties from Tap. The object_id is stored as the card's fingerprint from Tap, not the card_id.

Vantiv

BehaviorDetail
Gateway interactionExpects a pre-existing Vantiv token — the token is not validated against the gateway. Typically used for importing or migrating payment methods.
Local effectCreates the payment method record with cnpToken, cnpTxnId, and networkTransactionId in properties

Cybersource

BehaviorDetail
Gateway interactionExpects a pre-existing Cybersource token — the token is not validated against the gateway. Typically used for importing or migrating payment methods.
Local effectCreates the payment method record with cybersource_card_id in properties
Query Params
int32
required
int32
required
Body Params
string
required
string
required
properties
object
string
Headers
string
required
Defaults to Bearer eyJ***
Responses

Language
Credentials
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json