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

    Function isRetryableSquareError

    • Whether retrying the failed call could succeed: a network failure or timeout, a request timeout (408), rate limiting (429), a Square server error (5xx), or a response carrying Square's TEMPORARY_ERROR code, whatever its status. Validation, auth and other 4xx errors return false.

      For a mutating call, retry with the same idempotencyKey. Otherwise a request that reached Square before the failure can be applied twice.

      Parameters

      • error: unknown

      Returns boolean

      const idempotencyKey = createIdempotencyKey();
      try {
      await square.payments.create({ sourceId, amount, idempotencyKey });
      } catch (error) {
      if (isRetryableSquareError(error)) {
      await square.payments.create({ sourceId, amount, idempotencyKey }); // same key
      } else {
      throw error;
      }
      }