square
semver
>=40.0.0postconditions38functions20last verified2026-04-16coverage score80%Postconditions — what we check
- payments.create · square-payments-create-auth-errorerrorWhenAccess token is missing, expired (ACCESS_TOKEN_EXPIRED), revoked (ACCESS_TOKEN_REVOKED), or lacks required permissions (INSUFFICIENT_SCOPES).Throws
SquareError with errors[0].category === AUTHENTICATION_ERROR. Codes: UNAUTHORIZED, ACCESS_TOKEN_EXPIRED, ACCESS_TOKEN_REVOKED, CLIENT_DISABLED, FORBIDDEN, INSUFFICIENT_SCOPES.Required handlingCaller MUST wrap in try-catch. Check errors[0].code to distinguish expired (rotate token) from revoked (alert ops). Do NOT retry without resolving auth.costcriticalin prodimmediate exceptionusers seelost transactionvisibilityvisible - payments.create · square-payments-create-card-declinederrorWhenCard is declined by the issuer during payment processing.Throws
SquareError with errors[0].category === PAYMENT_METHOD_ERROR. Codes: GENERIC_DECLINE, INSUFFICIENT_FUNDS, CVV_FAILURE, CARD_EXPIRED, EXPIRATION_FAILURE, INVALID_CARD, PAN_FAILURE, ADDRESS_VERIFICATION_FAILURE, TRANSACTION_LIMIT, CARD_DECLINED_VERIFICATION_REQUIRED, CARDHOLDER_INSUFFICIENT_PERMISSIONS, VOICE_FAILURE.Required handlingCaller MUST wrap in try-catch and read errors[0].code to show appropriate user message. GENERIC_DECLINE means try another card. INSUFFICIENT_FUNDS means notify user. CARD_DECLINED_VERIFICATION_REQUIRED triggers 3DS flow. Do NOT show raw error codes to users.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - payments.create · square-payments-create-invalid-requesterrorWhenRequired fields missing (sourceId or amountMoney), nonce expired (5 min TTL), nonce already used (single-use only), appFeeMoney exceeds payment amount, or locationId not found or inactive.Throws
SquareError with errors[0].category === INVALID_REQUEST_ERROR. Codes: MISSING_REQUIRED_PARAMETER, CARD_TOKEN_EXPIRED, CARD_TOKEN_USED, INVALID_FEES, INVALID_LOCATION.Required handlingCaller MUST wrap in try-catch. CARD_TOKEN_USED is critical: nonces are single-use. On network error, do NOT retry with same nonce — generate fresh nonce. Check errors[0].code to distinguish token issues from missing fields.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - payments.create · square-payments-create-rate-limitwarningWhenRequest rate exceeds Square API rate limits for the payments endpoint.Throws
SquareError with errors[0].category === RATE_LIMIT_ERROR. SDK does NOT auto-retry. Caller must implement backoff.Required handlingCaller MUST implement exponential backoff with jitter before retrying. MUST use idempotency_key on all retries to prevent duplicate charges.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - payments.create · square-payments-create-timeoutwarningWhenNetwork connection times out before receiving a response from Square servers.Throws
SquareTimeoutError — a distinct class from SquareError. Catching only SquareError does NOT catch SquareTimeoutError. Payment status is UNKNOWN.Required handlingCaller MUST catch SquareTimeoutError separately from SquareError. On timeout, check payment status via payments.get() with the original idempotency_key before retrying. Retrying without checking risks double-charging the customer.costhighin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[3] - refunds.refundPayment · square-refunds-refund-payment-errorerrorWhenPayment is in non-refundable state (too old, fully refunded, or has active dispute), refund amount exceeds available balance, or card issuer declines refund.Throws
SquareError with errors[0].category === REFUND_ERROR. Codes: PAYMENT_NOT_REFUNDABLE, PAYMENT_NOT_REFUNDABLE_DUE_TO_DISPUTE, REFUND_AMOUNT_INVALID, REFUND_DECLINED, INSUFFICIENT_PERMISSIONS_FOR_REFUND.Required handlingCaller MUST wrap in try-catch and read errors[0].code. Route differently: PAYMENT_NOT_REFUNDABLE_DUE_TO_DISPUTE requires escalation to dispute team. REFUND_AMOUNT_INVALID requires checking remaining refundable balance. Use idempotency_key to prevent duplicate refunds on retry.costhighin prodimmediate exceptionusers seelost transactionvisibilityvisible - refunds.refundPayment · square-refunds-auth-or-rate-limiterrorWhenAccess token is invalid or expired, or refund rate exceeds Square limits (common in batch refund jobs processing many orders at once).Throws
SquareError with category AUTHENTICATION_ERROR or RATE_LIMIT_ERROR.Required handlingCaller MUST implement exponential backoff for RATE_LIMIT_ERROR. Track per-refund status in batch jobs to resume correctly after interruption. Do NOT retry AUTHENTICATION_ERROR without fixing the token.costhighin prodimmediate exceptionusers seelost transactionvisibilityvisible - payments.complete · square-payments-complete-errorerrorWhenPayment is not in APPROVED state (already COMPLETED, CANCELED, or FAILED), authorization hold has expired (6 days card-present, 7 days card-not-present), or access token is invalid.Throws
SquareError with INVALID_REQUEST_ERROR (wrong state or expired hold) or AUTHENTICATION_ERROR. Expired hold: new payment must be created, not retried.Required handlingCaller MUST wrap in try-catch. Monitor time between auth and capture to complete before hold expiry. On error, check errors[0].code to determine if a new payment is required vs a retryable transient error.costhighin prodimmediate exceptionusers seelost transactionvisibilityvisible - payments.cancel · square-payments-cancel-errorerrorWhenPayment is already COMPLETED (captured — must refund instead), in FAILED state, already CANCELED, or access token is invalid.Throws
SquareError with INVALID_REQUEST_ERROR (non-cancellable state) or AUTHENTICATION_ERROR. COMPLETED payments cannot be voided.Required handlingCaller MUST wrap in try-catch. If payment is COMPLETED, route to refunds.refundPayment() instead of retrying cancel(). Do not assume cancellation succeeded without confirming the API response.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[8] - subscriptions.create · square-subscriptions-create-customer-errorerrorWhenCustomer ID does not exist in merchant directory, customer has no email (required for invoice delivery), or customer has no recorded name.Throws
SquareError with INVALID_REQUEST_ERROR (400 Bad Request). Confirmed codes: CUSTOMER_NOT_FOUND, CUSTOMER_MISSING_EMAIL, CUSTOMER_MISSING_NAME.Required handlingCaller MUST wrap in try-catch. CUSTOMER_NOT_FOUND: create customer first. CUSTOMER_MISSING_EMAIL: update customer profile before enrolling. Do NOT show subscribed state until API confirms status === ACTIVE.costmediumin prodimmediate exceptionusers seelost transactionvisibilitysilent - subscriptions.create · square-subscriptions-create-card-errorerrorWhencard_id is invalid or declined, or location is not configured for credit card processing (CARD_PROCESSING_NOT_ENABLED, 403 Forbidden). Subscription may be created in PENDING state when card payment fails at enrollment.Throws
SquareError with INVALID_REQUEST_ERROR or PAYMENT_METHOD_ERROR, or 403 with CARD_PROCESSING_NOT_ENABLED. Subscription may exist in PENDING state.Required handlingCaller MUST wrap in try-catch and check response.subscription.status === ACTIVE before granting access. PENDING means Square will invoice but has NOT confirmed payment. Do NOT grant paid-feature access until status is ACTIVE.costhighin prodsilent failureusers seelost transactionvisibilitysilent - subscriptions.cancel · square-subscriptions-cancel-errorerrorWhenSubscription ID does not exist, subscription is already CANCELLED or DEACTIVATED, or access token is invalid.Throws
SquareError with INVALID_REQUEST_ERROR (not found or not cancellable) or AUTHENTICATION_ERROR.Required handlingCaller MUST wrap in try-catch. Swallowing this error leaves the subscription active while the app assumes it was cancelled — customer continues to be billed. Log and alert on all cancellation failures. Verify by checking subscription status after the call. Treat NOT_FOUND as possible soft success (already cancelled) but log for audit trail.costhighin prodsilent failureusers seelost transactionvisibilitysilentSources[11] - orders.create · square-orders-create-errorerrorWhenLocation ID not found or inactive, required order fields missing, line item price or quantity invalid, or currency not supported for merchant location.Throws
SquareError with INVALID_REQUEST_ERROR (400) or 403 for INVALID_LOCATION. Codes: INVALID_LOCATION, MISSING_REQUIRED_PARAMETER, INVALID_VALUE, UNSUPPORTED_CURRENCY. Also AUTHENTICATION_ERROR for bad token.Required handlingCaller MUST wrap in try-catch. INVALID_LOCATION surfaces when merchants deactivate locations — app must refresh cached location_id. Use idempotency_key to safely retry failed order creation without creating duplicates.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - customers.create · square-customers-create-errorerrorWhenNo identifying field provided (givenName, familyName, companyName, emailAddress, or phoneNumber — at least one required), or email/phone format is malformed.Throws
SquareError with INVALID_REQUEST_ERROR. Codes: MISSING_REQUIRED_PARAMETER, INVALID_EMAIL_ADDRESS, INVALID_PHONE_NUMBER. Also AUTHENTICATION_ERROR for bad token.Required handlingCaller MUST wrap in try-catch. Validate email/phone formats client-side before calling. Customer creation failure blocks downstream card-on-file and subscription enrollment. Log repeated INVALID_REQUEST_ERROR — may indicate malformed data pipeline.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - customers.delete · square-customers-delete-errorerrorWhenCustomer ID does not exist in merchant directory, or access token is invalid.Throws
SquareError with INVALID_REQUEST_ERROR (CUSTOMER_NOT_FOUND) or AUTHENTICATION_ERROR.Required handlingCaller MUST wrap in try-catch and verify deletion completed. Operation is irreversible — swallowing errors causes app to assume deletion succeeded while Square customer data persists. GDPR/CCPA requires confirmed deletion. Treat CUSTOMER_NOT_FOUND as soft success (already deleted) but log for audit.costhighin prodsilent failureusers seelost datavisibilitysilentSources[14] - checkout.paymentLinks.create · square-checkout-payment-links-create-errorerrorWhenquickPay missing required fields (name and priceMoney both required), locationId inactive or not found, price data malformed, or access token invalid.Throws
SquareError with INVALID_REQUEST_ERROR (missing fields, INVALID_LOCATION) or AUTHENTICATION_ERROR.Required handlingCaller MUST wrap in try-catch. Validate quickPay fields before calling. Do NOT cache link URLs long-term — payment links expire and redirect customers to Square error page without notifying the application. Regenerate on demand.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[15] - cards.create · square-cards-create-source-usederrorWhenThe sourceId (nonce) provided was already used in a previous cards.create() call. Card nonces are single-use. On network error or timeout, retrying with the same sourceId always fails with SOURCE_USED — even if the first call never reached Square.Throws
SquareError with INVALID_REQUEST_ERROR and code SOURCE_USED. Code SOURCE_EXPIRED occurs if the nonce exceeded its 5-minute TTL.Required handlingCaller MUST wrap in try-catch. On SOURCE_USED or SOURCE_EXPIRED: discard the nonce and generate a fresh one from the Square Web Payments SDK. Do NOT retry with the same sourceId. Storing the nonce for later re-use causes permanent failure on all subsequent calls. This is the #1 mistake in card vaulting flows.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[16] - cards.create · square-cards-create-customer-not-founderrorWhenThe customerId provided in the card object does not exist in the merchant's customer directory. Common when customer creation fails silently and the card vaulting step is not gated on successful customer creation.Throws
SquareError with INVALID_REQUEST_ERROR and code CUSTOMER_NOT_FOUND (HTTP 400).Required handlingCaller MUST wrap in try-catch and ensure customers.create() succeeded before calling cards.create(). Do NOT proceed to subscription enrollment without a valid stored card — caller should surface the failure to the user rather than silently continuing with no card on file.costmediumin prodimmediate exceptionusers seelost transactionvisibilitysilentSources[16] - cards.create · square-cards-create-processing-not-enablederrorWhenThe locationId provided is not enabled for credit card processing. Occurs when a merchant's location is newly created or not activated for payments.Throws
SquareError with HTTP 403 and code CARD_PROCESSING_NOT_ENABLED.Required handlingCaller MUST wrap in try-catch. CARD_PROCESSING_NOT_ENABLED is not a transient error — retrying will always fail. Alert ops team to activate card processing for the location in the Square Dashboard. Do NOT silently swallow this error.costhighin prodimmediate exceptionusers seeservice unavailablevisibilitysilentSources[16] - invoices.create · square-invoices-create-errorerrorWhenThe linked orderId does not exist or is in a non-invoiceable state (already PAID, CANCELED, or has another invoice), primaryRecipient customerId is invalid, paymentRequests fields are missing or malformed, or card-on-file specified is invalid (INVALID_CARD, PAYMENT_METHOD_ERROR).Throws
SquareError with INVALID_REQUEST_ERROR (400 — missing order, invalid customer, malformed payment schedule) or PAYMENT_METHOD_ERROR with code INVALID_CARD.Required handlingCaller MUST wrap in try-catch. Verify the order is in OPEN state before creating invoice. Confirm the customer exists and has an email address (required for email delivery). A successfully created invoice is in DRAFT state — it will NOT charge the customer until invoices.publish() is called. Do NOT assume draft creation means the customer has been notified or charged.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[17] - invoices.publish · square-invoices-publish-card-declinederrorWhenThe invoice is configured for automatic card-on-file payment and the card is declined during publish. Occurs if the stored card expired, was reported stolen, or has insufficient funds at the moment of publishing.Throws
SquareError with PAYMENT_METHOD_ERROR and code CARD_DECLINED (HTTP 402), or INVALID_CARD if the card data cannot be validated.Required handlingCaller MUST wrap in try-catch and check the invoice status after publish failure. On CARD_DECLINED: notify the customer to update payment method. The invoice may still be created and in an error state — do NOT consider it unpublished without confirming via invoices.get(). Do NOT silently swallow this error or show the customer a success message.costhighin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[18] - invoices.publish · square-invoices-publish-wrong-versionerrorWhenThe version field does not match the invoice's current version in Square's system. This is Square's optimistic concurrency control — two concurrent publish attempts for the same invoice, or a publish after an update, will cause a version mismatch.Throws
SquareError with INVALID_REQUEST_ERROR (400). The version must exactly match the current invoice version returned by invoices.get() or invoices.create().Required handlingCaller MUST wrap in try-catch. On version mismatch: re-fetch the invoice with invoices.get() to get the latest version, then retry publish with the new version. Using idempotency_key ensures that if the first publish succeeded, the retry returns the same published invoice. Always pass version from the most recent fetch.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[18] - orders.update · square-orders-update-version-conflicterrorWhenThe version field in the request does not match the current version of the order in Square. Concurrent modifications (e.g., POS and API both updating the same order) or stale cached order data cause this error. Version is required for all updates.Throws
SquareError with INVALID_REQUEST_ERROR (400). Must always include the latest version from a recent orders.get() call. Cannot be retried without re-fetching.Required handlingCaller MUST wrap in try-catch. On version conflict: re-fetch the order with orders.get() to get the current version and state, then re-apply changes and retry. Do NOT retry the same update request with the same version — it will always fail.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisible - orders.update · square-orders-update-closed-ordererrorWhenAttempting to update an order in COMPLETED or CANCELED state. These orders are immutable — all fields are read-only after the order reaches a terminal state.Throws
SquareError with INVALID_REQUEST_ERROR (400). The order state cannot be reverted, and updates to completed/canceled orders are not permitted.Required handlingCaller MUST wrap in try-catch and check order state before calling update. On closed-order error: do NOT retry. If a refund or correction is needed, use refunds.refundPayment() for completed orders, not orders.update(). Log and alert — this often indicates a race condition or UI bug.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[19] - orders.pay · square-orders-pay-amount-mismatcherrorWhenThe sum of all payment_ids does not equal the order total_money. Any partial payment coverage or over-payment causes immediate failure. Also fails if a payment referenced by payment_id is not in APPROVED state (already COMPLETED, CANCELED, or FAILED).Throws
SquareError with INVALID_REQUEST_ERROR (400). Payments not referenced in payment_ids and previously approved for the same order_id are automatically CANCELED by Square.Required handlingCaller MUST wrap in try-catch. Before calling pay(), verify: (1) sum of payment amounts equals order total, (2) all referenced payments are in APPROVED state via payments.get(). On failure, check which payments were auto-canceled by Square — do NOT attempt to re-complete canceled payments without creating new payment authorizations.costhighin prodimmediate exceptionusers seelost transactionvisibilityvisible - orders.pay · square-orders-pay-timeoutwarningWhenNetwork connection times out while Square is processing the pay-order request. Payment status is UNKNOWN — the order may or may not have been marked as COMPLETED.Throws
SquareTimeoutError — a distinct class from SquareError. Catching only SquareError does NOT catch SquareTimeoutError.Required handlingCaller MUST catch SquareTimeoutError separately. On timeout: do NOT immediately retry pay(). First verify order state via orders.get() — if COMPLETED, the payment succeeded. Retrying with the same idempotency_key is safe (returns the same result), but retrying without checking may trigger duplicate captures on APPROVED payments.costhighin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[21] - catalog.batchUpsert · square-catalog-batch-upsert-concurrent-updateerrorWhenAnother catalog update request (batch or non-batch) is already being processed for the same seller account. Square processes only one catalog update at a time per account. Common in sync jobs that fire concurrent batches.Throws
SquareError with RATE_LIMIT_ERROR and HTTP 429. Code: RATE_LIMITED. The entire request is rejected — no objects from this request are inserted.Required handlingCaller MUST wrap in try-catch and implement sequential retry with backoff. Do NOT fire parallel catalog update requests for the same seller — serialize them. On RATE_LIMITED (429), wait and retry the full batch. Use idempotency_key to prevent duplicate insertions on retry.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilitysilentSources[23] - catalog.batchUpsert · square-catalog-batch-upsert-idempotency-reuseerrorWhenThe same idempotency_key is reused with different request parameters (different objects or different batches). This is a developer error that occurs when a sync job generates idempotency keys from a non-unique seed (e.g., date only, not UUID).Throws
SquareError with INVALID_REQUEST_ERROR (400) and code IDEMPOTENCY_KEY_REUSED. Detail: "The idempotency key can only be retried with the same request data."Required handlingCaller MUST wrap in try-catch. Generate idempotency keys from a content hash of the objects being upserted, or use UUID v4 per request. If IDEMPOTENCY_KEY_REUSED is returned, do NOT retry with the same key — generate a new key and retry. This is not retryable without changing the key.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilitysilentSources[24] - catalog.batchUpsert · square-catalog-batch-upsert-partial-batch-failureerrorWhenOne or more batches within the request contain malformed objects (exceeds size limits, references non-existent modifier list, invalid is_deleted flag). Square processes each batch independently — some batches may succeed while others fail.Throws
SquareError with INVALID_REQUEST_ERROR (400). The error response indicates which batch failed. Successful batches in the same request are committed; failed batches are not.Required handlingCaller MUST wrap in try-catch. After a partial failure, inspect errors to determine which batch failed and re-submit only the failed batch with a new idempotency_key. Do NOT re-submit the entire request — already-committed batches will be treated as updates (same IDs), not duplicates. Validate objects client-side to catch size limit violations (max 1,000 objects per batch, 10,000 per request).costmediumin prodimmediate exceptionusers seeservice unavailablevisibilitysilentSources[23] - disputes.accept · square-disputes-accept-financial-debiterrorWhendisputes.accept() succeeds but the caller does not handle the response or swallows errors. Square IMMEDIATELY debits the disputed amount from the seller's Square balance. If the balance is insufficient, Square debits the linked bank account. This is not a queued or asynchronous operation — the debit happens at accept time.Throws
No exception on success. The risk is silent SUCCESS: the caller may not confirm the debit occurred or update internal state. On actual error (wrong dispute state, authentication): SquareError with INVALID_REQUEST_ERROR or AUTHENTICATION_ERROR.Required handlingCaller MUST wrap in try-catch. On success, update internal dispute state to ACCEPTED and trigger accounting entries for the debit. Do NOT accept disputes in batch loops without tracking which disputes were accepted — if the loop crashes mid-way, some disputes are accepted (debited) and some are not, causing accounting inconsistency. Verify dispute is in actionable state (not ACCEPTED, not COMPLETED, not past due_at).costhighin prodimmediate exceptionusers seelost transactionvisibilitysilent - disputes.accept · square-disputes-accept-deadline-missederrorWhenAttempt to accept or challenge a dispute after the due_at deadline has passed. Square automatically challenges the dispute on the seller's behalf after the deadline, transitioning the dispute to a state where seller actions are no longer permitted.Throws
SquareError with INVALID_REQUEST_ERROR (400). Dispute state will be in an auto-challenged terminal state. The seller loses control of the dispute response.Required handlingCaller MUST check dispute.due_at before calling accept() or submitEvidence(). Implement deadline monitoring: alert the operations team at due_at - 24h. Do NOT assume disputes can be accepted at any time — the window is typically 30 days from notification but varies per card network.costhighin prodimmediate exceptionusers seelost transactionvisibilitysilentSources[26] - disputes.submitEvidence · square-disputes-submit-evidence-irrevocableerrorWhensubmitEvidence() succeeds but the caller swallows the response without confirming submission. Evidence submission is permanent — evidence cannot be removed after calling this endpoint. If called before all evidence files are uploaded, the submission is final with incomplete evidence.Throws
No exception on success. Risk is premature submission (no exception thrown). On actual error (dispute already submitted, authentication, wrong state): SquareError with INVALID_REQUEST_ERROR or AUTHENTICATION_ERROR.Required handlingCaller MUST wrap in try-catch. Verify all evidence is uploaded (createEvidenceFile/ createEvidenceText succeed) BEFORE calling submitEvidence(). Do NOT call submitEvidence() in the same request as evidence upload without confirming upload success. After successful submission, update internal state to prevent re-submission. Evidence submission is final — no retry recovers from incomplete evidence submission.costhighin prodsilent failureusers seelost transactionvisibilitysilent - disputes.submitEvidence · square-disputes-submit-evidence-dashboard-exclusionwarningWhenAfter calling any Disputes API endpoint for a specific dispute, the seller can no longer manage that dispute through the Square Dashboard. Evidence and dispute status in the Dashboard are not updated when using the API. If submitEvidence() fails and the seller tries to use the Dashboard as a fallback, the two systems are out of sync.Throws
No exception — this is an operational constraint, not a thrown error. If submitEvidence() fails, callers cannot advise sellers to complete the submission via Dashboard.Required handlingCaller MUST implement complete evidence submission flow with retry logic. Do NOT partially implement dispute management and expect sellers to fall back to the Dashboard. If the API flow fails, the seller is locked out of Dashboard management for that dispute. Alert ops team immediately on any submitEvidence() failure.costhighin prodsilent failureusers seelost transactionvisibilitysilentSources[26] - giftCards.activities.create · square-gift-card-activities-insufficient-fundserrorWhenAttempting a REDEEM activity when the gift card balance is insufficient for the requested redemption amount. GIFT_CARD_AVAILABLE_AMOUNT is thrown when the remaining balance is less than the redemption amount.Throws
SquareError with PAYMENT_METHOD_ERROR (400) and code GIFT_CARD_AVAILABLE_AMOUNT (insufficient balance) or INSUFFICIENT_FUNDS (funding source insufficient). Also PAYMENT_LIMIT_EXCEEDED if the amount exceeds processing limits.Required handlingCaller MUST wrap in try-catch and check the gift card balance before redemption. On GIFT_CARD_AVAILABLE_AMOUNT: split payment (partial gift card + another tender) or reject transaction. Do NOT assume gift card balance equals the full purchase amount without checking first. Log GIFT_CARD_AVAILABLE_AMOUNT errors to detect fraudulent redemption attempts.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[28] - giftCards.activities.create · square-gift-card-activities-pending-stateerrorWhenAttempting to LOAD or REDEEM a gift card that is still in PENDING state (created but never activated). A gift card created via giftCards.create() remains in PENDING state until an ACTIVATE activity is successfully processed.Throws
SquareError with INVALID_REQUEST_ERROR (400). The gift card cannot be used for transactions until an ACTIVATE activity is processed via giftCards.activities.create().Required handlingCaller MUST wrap in try-catch. Do NOT assume a gift card is usable immediately after giftCards.create() — always create an ACTIVATE activity before issuing the gift card to a customer. Validate gift card state before any LOAD or REDEEM activity. On PENDING state error: call giftCards.activities.create() with type=ACTIVATE and the initial balance before retrying.costmediumin prodimmediate exceptionusers seelost transactionvisibilitysilent - giftCards.activities.create · square-gift-card-activities-temporary-errorwarningWhenSquare's internal gift card service returns a transient 503 Service Unavailable during activity creation. Common during peak transaction periods. TEMPORARY_ERROR means the activity status is unknown — it may or may not have been recorded.Throws
SquareError with PAYMENT_METHOD_ERROR and HTTP 503. Code: TEMPORARY_ERROR. Square confirms this is safe to retry with the same idempotency key.Required handlingCaller MUST wrap in try-catch and implement retry logic. Use the same idempotency_key on retry — Square guarantees idempotency for gift card activities. On TEMPORARY_ERROR: wait and retry (exponential backoff). Do NOT show a failure to the customer until all retries are exhausted — the activity may have succeeded.costmediumin prodimmediate exceptionusers seelost transactionvisibilitysilentSources[28] - giftCards.create · square-gift-cards-create-pending-state-traperrorWhengiftCards.create() succeeds but the caller issues the gift card to the customer without first creating an ACTIVATE activity. The gift card is in PENDING state and any LOAD or REDEEM attempt will fail with INVALID_REQUEST_ERROR.Throws
No exception from giftCards.create() — the trap is silent SUCCESS. The error occurs later when the customer attempts to use the gift card, not at creation time.Required handlingCaller MUST wrap in try-catch. After successful giftCards.create(), always call giftCards.activities.create() with type=ACTIVATE and the initial balance BEFORE issuing the gift card to the customer. Do NOT return the gift card GAN to the customer until activation succeeds. If activation fails, the gift card must be re-activated before distribution.costhighin prodsilent failureusers seelost transactionvisibilitysilentSources[29] - giftCards.create · square-gift-cards-create-invalid-ganerrorWhenA custom GAN is provided that fails validation: not 8-20 alphanumeric characters, not unique for this seller, or starts with a major credit card BIN pattern (e.g., 4XXXXXXX for Visa, 5XXXXXXX for Mastercard). Predictable GANs (e.g., sequential numbers) create fraud risk.Throws
SquareError with INVALID_REQUEST_ERROR (400). GAN validation failure prevents gift card creation entirely.Required handlingCaller MUST wrap in try-catch. Validate custom GANs before calling create(): 8-20 alphanumeric, no major BIN patterns, must be unique. Prefer letting Square auto-generate GANs (omit gan field) unless specific GAN format is required. On INVALID_REQUEST_ERROR: fix the GAN and retry with a new idempotency_key.costmediumin prodimmediate exceptionusers seelost transactionvisibilityvisibleSources[29]
Sources
Every postcondition cites at least one of these. Numbered to match the footnotes above.
- [1]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/enums/ErrorCategory
- [2]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/enums/ErrorCode
- [3]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/payments-api/create-payment
- [4]developer.squareup.com/docs/build-basicshttps://developer.squareup.com/docs/build-basics/handling-errors
- [5]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/refunds-api/refund-payment
- [6]developer.squareup.com/docs/payments-apihttps://developer.squareup.com/docs/payments-api/take-payments
- [7]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/payments-api/complete-payment
- [8]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/payments-api/cancel-payment
- [9]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/subscriptions-api/create-subscription
- [10]developer.squareup.com/docs/subscriptions-apihttps://developer.squareup.com/docs/subscriptions-api/manage-subscriptions
- [11]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/subscriptions-api/cancel-subscription
- [12]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/orders-api/create-order
- [13]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/customers-api/create-customer
- [14]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/customers-api/delete-customer
- [15]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/checkout-api/create-payment-link
- [16]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/cards-api/create-card
- [17]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/invoices-api/create-invoice
- [18]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/invoices-api/publish-invoice
- [19]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/orders-api/update-order
- [20]developer.squareup.com/docs/orders-apihttps://developer.squareup.com/docs/orders-api/manage-orders/update-orders
- [21]developer.squareup.com/docs/orders-apihttps://developer.squareup.com/docs/orders-api/pay-for-orders
- [22]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/orders-api/pay-order
- [23]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/catalog-api/batch-upsert-catalog-objects
- [24]developer.squareup.com/docs/build-basicshttps://developer.squareup.com/docs/build-basics/using-rest-api
- [25]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/disputes-api/accept-dispute
- [26]developer.squareup.com/docs/disputes-apihttps://developer.squareup.com/docs/disputes-api/process-disputes
- [27]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/disputes-api/submit-evidence
- [28]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/gift-card-activities-api/create-gift-card-activity
- [29]developer.squareup.com/reference/squarehttps://developer.squareup.com/reference/square/gift-cards-api/create-gift-card
Need a different package?
Request a profile