Create Payment Method
  • 06 Sep 2024
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Create Payment Method

  • Dark
    Light

Article summary

Post
/payments/v1/customers/{customerId}/methods

Register a token from a payment provider and create a payment method.

Security
HTTP
Type bearer
Path parameters
customerId
stringRequired
Min length1
Body parameters
object

Create a payment method on the gateway and configured payment provider.

paymentMethodToken
string Required

A token from a payment provider.

registerExistingToken
boolean

Setting this option to true allows registration of a token that already exists on the payment provider but is not yet registered on the gateway. This is useful when migrating from one gateway to another.

Defaultfalse
providerCustomerId
string

The ID of the customer on the payment provider. This ID should match the ID used by the payment provider. If not provided, the customer ID will be used instead. Braintree allows to set the customer ID to a custom value Stripe generates the customerId automatically and does not allow to set it to a custom value so it's required to provide it here.

matchProviderId
boolean

When registerExistingToken is true, this option ensures the ID given to the new payment method matches the existing ID used by the provider.

Responses
201

Payment Method Created

Expand All
object
data
OneOf
object
type
string

Payment method type is a bank card.

Valid values[ "\"card\"" ]
card
object

The bank card details related to this payment method.

brand
string

The brand of the card.

Examplevisa
mechanism
string

The payment method mechanism.

Valid values[ "\"applePay\"", "\"googlePay\"", "\"samsungPay\"", "\"direct\"" ]
cardHolderName
string

The name on the card.

expiryDate
string

The expiry date of the card in the format YYYY-MM

Min length7
Max length7
Example2012-10
bin
string

The first 4-6 digits of the card number (bank identification number).

Min length4
Max length6
last4
string

The last 4 digits of the card number.

Min length4
Max length4
country
string

The country where the card was issued.

billingDetails
object

The billing details associated with the payment method.

address
object

The billing address.

line1
string

The first line of the address.

line2
string

The second line of the address.

city
string

The city.

region
string

The region.

country
string

The country.

postalCode
string

The zip/postal code.

name
string

The name associated with the payment method.

email
string

The email address associated with the payment method.

phone
string

The phone number associated with the payment method.

paymentMethodId
string

A unique identifier for the payment method.

Min length1
customerId
string

A unique identifier for the customer to whom the payment method belongs. A customer can have multiple payments methods.

Min length1
object
type
string

Payment method type is Paypal.

Valid values[ "\"paypal\"" ]
paypal
object

The PayPal account details related to this payment method.

payerEmail
string (email)

The email address associated with the PayPay account.

payerId
string

The ID of the PayPal account.

revokedAt
string

The date and time the PayPal account revoked this object.

paymentMethodId
string

A unique identifier for the payment method.

Min length1
customerId
string

A unique identifier for the customer to whom the payment method belongs. A customer can have multiple payments methods.

Min length1
400

Invalid Request

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
401

Invalid Authentication Credentials

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
403

Invalid Authorization Credentials

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
404

Resource Not Found

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
409

Duplicate Resource

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
422

Action Cannot Be Performed

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
429

Too Many Requests

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
500

Internal Server Error

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
502

Provider Error

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
503

Service Unavailable

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value
504

Provider Unavailable

Expand All
object
message
string
causes
Array of object
object
message
string
metadata
Array of object
object
key
string
value

Was this article helpful?