Store a card

Store the card is used to store the card information for a customer.

POST /v1/customers/:id/sources

curl https://testapi.txpmnts.com/v1/customers/P2ZTA56JQ7-AvwGf0pHd2Q/sources \
  -u sk_test_yFStF-KUmgr-7CoumuY2JA: \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d card[number]=5159084567916624 \
  -d card[exp_month]=12 \
  -d card[exp_year]=2022 \
  -d card[name]=John Doe \
  -d card[address_line1]=Address line 1 \
  -d card[address_state]=mz \
  -d card[address_city]=Cardholder City \
  -d card[address_zip]=24310 \
  -d card[address_country]=pl \
  -d client_ip=127.0.0.1

The above command returns JSON structured like this:

{
	"id": "TlnNDVS6TteSn2-FEh3ZKg",
	"created_at": 1568904725,
	"name": "John Doe",
	"exp_month": 12,
	"exp_year": 2022,
	"last4": "6624",
	"brand": "mastercard",
	"customer": "P2ZTA56JQ7-AvwGf0pHd2Q",
	"fingerprint": "R1gbK7BauiX3XdnUCQRhzlnvMxxtSKVS7NqScFBeVRE",
	"client_ip": "127.0.0.1",
	"address_line1": "Address line 1",
	"address_city": "Cardholder City",
	"address_state": "mz",
	"address_zip": "24310",
	"address_country": "PL",
	"type": "card"
}

Arguments

Contain the card information to be stored.

Parameter
Type
Required
Description

card[number]

numeric

required is source is not present

Credit card number.

card[exp_month]

numeric

required is source is not present

Card expiration month.

card[exp_year]

numeric

required is source is not present

Card expiration year.

card[name]

string

required is source is not present

Cardholder name.

card[address_line1]

string

optional

Cardholder line 1 address.

card[address_line2]

string

optional

Cardholder line 2 address.

card[address_state]

string

optional

Cardholder address state using the iso 3166-2 code for country states.

card[address_city]

string

optional

Cardholder address city.

card[address_zip]

string

optional

Cardholder zip address.

card[address_country]

string

optional

Cardholder iso 2 country code.

source

string

optional if card data is not present

Contain the token ID received from the token creation.

client_ip

string

optional

IP address of the client that generate the token.

Returns

Return the card object linked to the card information stored.

Last updated