Filter
Results
Frontend API
Methods to manage and update credit cards stored on a customer's account.
Use to get a list of credit cards on file for the account. These are stored automatically when a non-guest user checks out and chooses to save their information for later.
Returns all addresses, with offset pagination using limit and page.
await swell.account.listCards()
Use to save a tokenized credit card to the account for future use. Credit card tokens can be created using swell.card.createToken or Stripe.js.
await swell.account.createCard({
token: '...'
})
Used to update information on an existing card on file by ID.
await swell.account.updateCard('5c15505200c7d14d851e510f'){
exp_month: 11,
exp_year: 2050
})
Use to remove a saved credit card from the account by ID.
await swell.account.deleteCard('5c15505200c7d14d851e510f')
When fetching an account, the default payment method is listed account.billing.account_card_id. The account's default card can be updated by passing the desired card ID to account.billing.account_card_id
import swell from 'swell-js'
swell.init('my-store', 'public-key')
account = await swell.account.get()
Swell supports deleting the default card. If the default card that is deleted is associated with an active subscription, it will remain associated with the subscription unless the subscription itself is modified.