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

    Class PaymentsService

    Simplified payments service

    const payment = await square.payments.create({
    sourceId: 'cnon:card-nonce-ok',
    amount: 1000, // $10.00 in cents
    idempotencyKey: 'order-1042', // one key per order, so a retry can't charge twice
    });
    Index
    • Parameters

      • client: SquareClient
      • OptionaldefaultLocationId: string
      • defaultCurrency: "USD" | "CAD" | "GBP" | "EUR" | "AUD" | "JPY" = 'USD'

      Returns PaymentsService

    • Cancel a payment

      Parameters

      • paymentId: string

        Payment ID to cancel

      Returns Promise<Payment>

      Cancelled payment

      const payment = await square.payments.cancel('PAYMENT_123');
      
    • Complete a payment (for payments created with autocomplete: false)

      Parameters

      • paymentId: string

        Payment ID to complete

      Returns Promise<Payment>

      Completed payment

      const payment = await square.payments.complete('PAYMENT_123');
      
    • Create a payment

      Parameters

      Returns Promise<Payment>

      Created payment

      When payment processing fails

      When input validation fails, including a missing idempotencyKey

      // Simple payment
      const payment = await square.payments.create({
      sourceId: 'cnon:card-nonce-ok',
      amount: 1000, // $10.00 in cents
      idempotencyKey: 'order-1042', // one key per order, so a retry can't charge twice
      });

      // Payment with all options
      const payment = await square.payments.create({
      sourceId: 'cnon:card-nonce-ok',
      amount: 1000,
      currency: 'USD',
      customerId: 'CUST_123',
      orderId: 'ORDER_123',
      note: 'Payment for order #123',
      autocomplete: true,
      buyerEmailAddress: 'buyer@example.com',
      statementDescriptionIdentifier: 'ORDER123',
      idempotencyKey: 'order-123-payment',
      });

      // Merchant-initiated charge of a card on file (e.g. a renewal)
      const payment = await square.payments.create({
      sourceId: 'ccof:CARD_123',
      customerId: 'CUST_123',
      amount: 1000,
      customerDetails: { customerInitiated: false, sellerKeyedIn: false },
      idempotencyKey: 'renewal-SUB_123-2026-12',
      });
    • Get a payment by ID

      Parameters

      • paymentId: string

        Payment ID

      Returns Promise<Payment>

      Payment details

      const payment = await square.payments.get('PAYMENT_123');
      
    • List payments with optional filters

      Parameters

      • Optionaloptions: { limit?: number; locationId?: string }

        List options

      Returns Promise<Payment[]>

      Array of payments

      const payments = await square.payments.list({
      limit: 10,
      });