Skip to Content
Docs
Payment methods

Create a payment method from token

POST/payment_methods/create_from_token

Creates a card payment method for a customer from a Pay.com card token (tok_card_) or from the reference of a card imported with POST /payment_methods/import.

Headers

AuthorizationstringRequired
HTTP Basic auth: your API key as the password, with an empty username. See Authentication.
idempotency-keystring

A unique key, such as a UUID, that makes a POST or DELETE request safe to retry. Pay.com keeps each key for 24 hours, separately for each workspace.

  • A retry with the same key, endpoint and body gets the first request's stored status and body, without running the request again.
  • If the first request is still being processed, a retry gets 409 idempotency_error (request_in_progress).
  • The same key on another endpoint, or with another body, gets 400 idempotency_error (invalid_parameters).
  • GET, PUT and PATCH requests ignore the key.

The response repeats the key in its Idempotency-Key header.

Parameters

customer_reference_idstringRequired

Your unique identifier for the customer that the payment method belongs to.

tokenstringRequired

A Pay.com card token (tok_card_), or the reference of a card imported with POST /payment_methods/import.

metadataobject

Set of key-value pairs attached to the object.

Returns

Returns the created payment method object.

idstring

Unique identifier for the payment method.

resourcestring

String representing the object's type.

typestring

The type of the payment method. Always card.

cardobject

Details of the card. Fields that are not known are null.

Show 14 child attributesHide child attributes
binstring or null

The first six digits of the card number.

brandstring or null

The brand of the card.

cardholder_currencystring or null

Three-letter ISO currency code of the cardholder's card, in lowercase.

countrystring or null

Two-letter ISO code of the country of the card issuer.

exp_monthstring or null

Two-digit string representing the card's expiration month.

exp_yearstring or null

Four-digit string representing the card's expiration year.

fingerprintstring or null

Unique identifier for this card number.

fundingstring or null

The funding type of the card.

last4string or null

The last four digits of the card number.

networkstring or null

The card network.

tokenstring

The card token.

three_d_securenull
security_checksnull
walletobject or null

Digital wallet of the token (type googlepay or applepay), if applicable.

Show 1 child attributeHide child attributes
typestring

Type of the digital wallet.

flow_directionsobject

Supported flow directions.

Show 2 child attributesHide child attributes
paymentboolean

Whether the payment method can be used for payments.

payoutboolean

Whether the payment method can be used for payouts.

test_modeboolean

Whether the payment method was created in the sandbox.

statusnull
referencestring or null

The payment method's ID at the provider it was imported from, if applicable.

metadataobject

Set of key-value pairs attached to the object.

Errors

400
Invalid request parameters. Also returned with Invalid token provided when token is a payment method ID (pm_) rather than a token.
401
The API key or access token is missing, unknown or no longer works (invalid_key, invalid_token, legacy_keys_ended, legacy_keys_off or permission_denied).
403
The request was refused: the API key may not make it (for example resource_not_allowed, key_disabled, network_not_allowed, pci_required or merchant_required), or this resource isn't enabled for your account (permission_denied). code says why.
409
Another request with the same idempotency-key is still being processed (request_in_progress). Wait, then retry with the same key.
422
Unprocessable content. Returned when token is an external token that is not stored for your account (No card was found for external payment method id).
500
Internal server error.
503
Service unavailable. Retry after the number of seconds in Retry-After, or after a few seconds when there's none.
Was this page helpful?