Create a Card Token

Creates a single-use token that represents a credit card’s details. This token can be used in place of a credit card information to create a charge. These tokens can be used only once: by creating a new transaction, or by attaching them to a Customer object. In most cases, you should use our recommended payments integrations.

POST /v1/tokens

curl https://testapi.txpmnts.com/v1/tokens \
  -u sk_test_yFStF-KUmgr-7CoumuY2JA: \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d card[number]=4916594580900113 \
  -d card[exp_month]=02 \
  -d card[exp_year]=2022 \
  -d card[cvc]=251 \
  -d card[name]=John Doe \
  -d client_ip=127.0.0.1 \
  -d card[address_line1]=Address Line 1 \
  -d card[address_state]=sk \
  -d card[address_city]=Address City \
  -d card[address_zip]=24310 \
  -d card[address_country]=PL

The above command returns JSON structured like this:

{
	"id": "aH79qManT3uP4vCKzUiryQ",
	"type": "card",
	"client_ip": "127.0.0.1",
	"created_at": 1627464935,
	"fingerprint": "-hzCuTB1NmGekIyKul2aRAH2rMsbJwKUAvMmQfApbv8",
	"merchant": "7qc0R04oQ0uyGG8goQqHrg",
	"usage": "single_use",
	"customer": "",
	"card": {
		"name": "John Doe",
		"last4": "4242",
		"brand": "visa",
		"exp_month": 12,
		"exp_year": 2022,
		"address_line1": "Address Line 1",
		"address_line2": "",
		"address_city": "Address City",
		"address_country": "PL",
		"address_zip": "24310",
		"address_state": "sk"
	}
}

Arguments

Contain the card information to create the token.

Parameter
Type
Required
Description

card[number]

number

required

Contain the credit card number.

card[cvc]

number

required

Card security code. Highly recommended to always include this value, but it’s required only for accounts based in European countries.

card[exp_month]

number

required

Two-digit number representing the card’s expiration month.

card[exp_year]

int

required

Four-digit number representing the card’s expiration year.

card[name]

string

optional

Cardholder’s full name.

card[address_line1]

string

optional

Address line 1 (Street address / PO Box / Company name).

card[address_line2]

string

optional

Address line 2 (Apartment / Suite / Unit / Building).

card[address_city]

string

optional

City / District / Suburb / Town / Village.

card[address_state]

string

optional

State / County / Province / Region.

card[address_zip]

string

optional

ZIP or postal code.

card[address_country]

string

optional

Billing address country, if provided.

client_ip

string

optional

Client IP address

Returns

Returns the created card token if successful. Otherwise, this call raises an error.

Last updated