Backend API
The account cards collection houses a customer's card information used for payments and transactions—allowing for storing multiple cards on a customer account.
Fields
id
objectIdautoThe unique identifier for the card.
parent_id
objectIdrequiredThe ID of the parent account.
token
stringrequiredLink to the associated payment token.
active
booleanIndicated whether this card is active and available for use.
address_check
stringIndicates results of the address check for the card: unchecked, pass, or fail.
billing
objectThe customer's billing details. Defaults to account.billing. Updating billing will also update the corresponding account billing object.
billing.name
stringBilling full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
billing.email
stringCustomer's email address.
billing.company
stringCustomer's company, if applicable.
billing.first_name
stringBilling first name. If name is updated, then first_name will be automatically updated as the first word of the name.
billing.last_name
stringBilling last name. If name is updated, then last_name will be automatically updated as the last word of the name.
billing.phone
stringBilling phone number.
billing.address1
stringrequiredBilling address line 1: street address/PO box/company name.
billing.address2
stringBilling address line 2: apartment/suite/unit/building.
billing.city
stringBilling city/district/suburb/town/village.
billing.state
stringBilling state/county/province/region.
billing.zip
stringBilling zip/postal code.
billing.country
stringTwo-letter ISO country code.
billing.vat_number
stringVAT number for tax purposes, if applicable.
brand
stringName of card issuer. E.g., "visa".
cvc_check
stringIndicates results of the CVC check for the card: unchecked, pass, or fail.
date_created
dateautoThe date the card entry was created.
date_updated
dateautoDate the card entry was last updated.
exp_month
intThe expiration month on the card, 1 through 12.
exp_year
intFour-digit card expiration year.
fingerprint
stringA hashed fingerprint generated using client_id, brand, and last4.
gateway
stringName of the payment gateway.
last4
stringThe last four digits of the card number.
parent
AccountLink to the parent account.
test
booleanIndicated the card is for testing purposes.
zip_check
stringIndicates results of the zip check for the card: unchecked, pass, or fail.
The account card model
{
"parent_id": "627308bc32db26001276f091",
"billing": {
"name": "Glarthir",
"first_name": "Glarthir",
"last_name": null,
"address1": "Glarthir's House",
"address2": null,
"city": "Skingrad",
"state": "CA",
"zip": "95051",
"country": "US",
"phone": null,
"company": null
},
"brand": "Visa",
"last4": "4242",
"exp_month": 2,
"exp_year": 2024,
"token": "card_mgLMIJrqdFKjapNnKQXzbGSg",
"address_check": "pass",
"zip_check": "pass",
"cvc_check": "pass",
"fingerprint": "011778e5080632a4701cb5628266007d",
"date_created": "2022-05-19T17:17:31.167Z",
"active": true,
"id": "62867bab67e544001a6a3218"
},
Create a new customer account card. If you wish to generate your own unique ID for the record, it must use BSON ObjectID format for compatibility.
Arguments
id
objectIdautoThe unique identifier for the card.
parent_id
objectIdrequiredThe ID of the parent account.
token
linkrequiredLink to the associated payment token.
active
booleanIndicates whether this card is active and available for use.
address_check
enumIndicates results of the address check for the card: unchecked, pass, or fail.
Possible enum values:
billing
objectThe customer's billing details. Defaults to account.billing. Updating billing will also update the corresponding account billing object.
billing.name
stringBilling full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
billing.email
stringCustomer's email address.
billing.company
stringCustomer's company, if applicable.
billing.first_name
stringBilling first name. If name is updated, then first_name will be automatically updated as the first word of the name.
billing.last_name
stringBilling last name. If name is updated, then last_name will be automatically updated as the last word of the name.
billing.phone
stringBilling phone number.
billing.address1
stringbilling.address2
stringbilling.city
stringbilling.state
stringbilling.zip
stringbilling.country
stringbilling.vat_number
stringbrand
stringName of card issuer. E.g., "visa".
cvc_check
enumIndicates results of the CVC check for the card: unchecked, pass, or fail.
Possible enum values:
date_created
dateautoThe date the card entry was created.
date_updated
dateautoDate the card entry was last updated.
exp_month
intThe expiration month on the card, 1 through 12.
exp_year
intFour-digit card expiration year.
fingerprint
stringA hashed fingerprint generated using client_id, brand, and last4.
gateway
stringName of the payment gateway.
last4
stringThe last four digits of the card number.
parent
AccountLink to the parent account.
test
booleanIndicated the card is for testing purposes.
zip_check
enumIndicates results of the zip check for the card: unchecked, pass, or fail.
Possible enum values:
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/accounts:cards', {
first_name: 'Jarl',
last_name: 'Balgruff',
address1: '543 Castle Way',
city: 'Whiterun',
state: 'CA',
country: 'US',
brand: 'Visa',
last4: '1234',
exp_month: 10,
exp_year: 2023,
});
Response
{
"parent_id": "621e53a6213eaf013d1fa6b2",
"billing": {
"name": "Jarl Balgruff",
"first_name": "Jarl",
"last_name": "Balgruff",
"address1": "543 Castle Way",
"address2": null,
"city": "Whiterun",
"state": "CA",
"zip": null,
"country": "US",
"phone": null,
"company": null
},
"brand": "Visa",
"last4": "1234",
"exp_month": 10,
"exp_year": 2023,
"token": "card_QD5rOXP3I4bOmUCKlmLo7AzC",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"fingerprint": "3628a7581fec797682e06740213c08f1",
"date_created": "2022-07-13T15:52:53.253Z",
"active": true,
"id": "64ceea552fa37600132711f4"
}
Retrieve an existing account card using the ID that was returned when created.
Arguments
id
objectIdrequiredID of the customer account card to retrieve.
expand
stringExpanding link fields and child collections is performed using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit,
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
fields
stringReturn only the specified fields in the result. For example fields=name,slug would return only the fields name and slug in the response. Supports nested object and array fields using dot-notation, for example items.product_id. The customer account card id is always returned.
include
stringInclude one or more arbitrary queries in the response, possibly related to the main query.
See including for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/accounts:cards/{id}', {
});
Response
{
"parent_id": "621e53a6213eaf013d1fa6b2",
"billing": {
"name": "Jarl Balgruff",
"first_name": "Jarl",
"last_name": "Balgruff",
"address1": "543 Castle Way",
"address2": null,
"city": "Whiterun",
"state": "CA",
"zip": null,
"country": "US",
"phone": null,
"company": null
},
"brand": "Visa",
"last4": "1234",
"exp_month": 10,
"exp_year": 2023,
"token": "card_QD5rOXP3I4bOmUCKlmLo7BzC",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"fingerprint": "3628a7581fec797682e06740213c08f1",
"date_created": "2022-07-13T15:52:53.253Z",
"active": true,
"id": "64ceea552fa37600131711f3"
}
Update an existing account card using the ID that was returned when created.
Arguments
id
objectIdrequiredUnique identifier for the account card.
name
stringFull name of the customer. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
first_name
stringCustomer's first name. If name is updated, then first_name will be automatically updated as the first word of the name.
last_name
stringIf name is updated, then last_name will be automatically updated as the last words of the name.
address1
stringBilling address line 1: street address/PO box/company name.
address2
stringBilling address line 2: apartment/suite/unit/building.
city
stringBilling city/district/suburb/town/village.
state
stringBilling state/county/province/region.
zip
stringBilling zip/postal code.
country
stringTwo-letter ISO country code.
brand
stringCredit card brand. Can be American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown.
exp_month
intTwo-digit number representing the credit card expiration month.
exp_year
intFour-digit number representing the credit card expiration year.
last4
stringLast four digits of the card number.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.put('/accounts:cards/{id}', {
email: 'sheogorath@shiveringisles.com'
});
Response
{
"parent_id": "621e53a6213eaf013d1fa6b2",
"billing": {
"name": "Jarl Balgruff",
"first_name": "Jarl",
"last_name": "Balgruff",
"address1": "543 Castle Way",
"address2": null,
"city": "Whiterun",
"state": "CA",
"zip": null,
"country": "US",
"phone": null,
"company": null
},
"brand": "Visa",
"last4": "1234",
"exp_month": 10,
"exp_year": 2023,
"token": "card_QD4rOXP3I5bOmUCKlmLo8AzC",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"fingerprint": "3618a9581fec797682e06740212c08f3",
"date_created": "2022-07-13T15:52:53.253Z",
"active": true,
"date_updated": "2022-07-18T20:00:49.662Z",
"email": "sheogorath@shiveringisles.com",
"id": "62ceea552fa37600132911f6"
}
Return a list of customer account cards.
Arguments
expand
stringExpand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
fields
stringReturns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
include
objectInclude one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
limit
intLimit the number of records returned, ranging between 1 and 1000. Defaults to 15.
page
intThe page number of results to return given the specified or default limit.
search
stringA text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
sort
stringExpression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
where
objectAn object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/accounts:cards', {
where: {
order_count: {
$gt: 1
}
},
limit: 25,
page: 1
});
Response
{
"parent_id": "621e53a6213eaf013d1fa6b2",
"billing": {
"name": "Jarl Balgruff",
"first_name": "Jarl",
"last_name": "Balgruff",
"address1": "543 Castle Way",
"address2": null,
"city": "Whiterun",
"state": "CA",
"zip": null,
"country": "US",
"phone": null,
"company": null
},
"brand": "Visa",
"last4": "1234",
"exp_month": 10,
"exp_year": 2023,
"token": "card_QD5rOXP3I4bOmUCKlmLo7BzC",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"fingerprint": "3628a7581fec797682e06740213c08f1",
"date_created": "2022-07-13T15:52:53.253Z",
"active": true,
"id": "64ceea552fa37600131711f3"
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}
Delete a customer account card.
Arguments
id
objectIdrequiredThe ID of the account card to delete.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.delete('/accounts:cards/{id}', {
id: '62ceea552fa37600132911f6'
});