@bates-solutions/squareup API Reference - v3.2.0
    Preparing search index...

    Class CardsService

    Cards on file: store a customer's card, then charge it later with payments.create({ sourceId: card.id, customerId, ... }).

    const card = await square.cards.create({
    sourceId: 'cnon:card-nonce-ok',
    customerId: 'CUST_123',
    idempotencyKey: 'save-card-CUST_123',
    });

    await square.cards.disable(card.id!);
    Index
    • Store a card on file for a customer

      Parameters

      Returns Promise<Card>

      The stored card

      When sourceId, customerId or idempotencyKey is missing

      When Square declines to store the card

      const card = await square.cards.create({
      sourceId: 'cnon:card-nonce-ok',
      customerId: 'CUST_123',
      idempotencyKey: 'store-card-user-42',
      cardholderName: 'Amelia Earhart',
      billingAddress: { postalCode: '94103', country: 'US' },
      referenceId: 'user-42',
      });
    • Disable a card on file. A disabled card cannot be charged or enabled again.

      Parameters

      • cardId: string

        Card ID

      Returns Promise<Card>

      The disabled card (enabled: false)

      await square.cards.disable('ccof:CARD_123');
      
    • List cards on file, one page at a time

      Parameters

      Returns Promise<{ cards: Card[]; cursor?: string }>

      One page of cards, and the cursor of the next page if there is one

      const page1 = await square.cards.list({ customerId: 'CUST_123' });
      const page2 = await square.cards.list({ customerId: 'CUST_123', cursor: page1.cursor });