We’re seeing intermittent INVALID_CARD errors from CreateInvoice in production, and we’d like to understand what causes them and how to avoid them.
Our flow (Web Payments SDK, then server-side calls)
- The browser calls
card.tokenize(verificationDetails)with intentCHARGE_AND_STORE, the amount,currencyCode: 'USD'and abillingContact. - Our server calls CreateCustomer if needed, then CreateCard with that
cnon:token assource_id. - About one second later, it calls CreateOrder and then CreateInvoice with
automatic_payment_source: CARD_ON_FILEand the newcard_id.
The error that CreateInvoice sometimes returns:
[{'code': 'INVALID_CARD', 'detail': 'The selected card on file is no longer available for this customer. Choose another payment method.', 'category': 'PAYMENT_METHOD_ERROR'}]
When this happens:
- RetrieveCard shows the card as
enabled: true, on the same customer as the invoice’sprimary_recipient. - The same card can be invoiced successfully later.
What seems to predict it Across about 20 failures since 2026-09-01, the outcome tracks the last protobuf field (field 5) of the ccof: card id:
- Every Visa/Mastercard card with field 5 = 1 (ids ending
…oAQ) was rejected by CreateInvoice. - Every card with field 5 = 2 (ids ending
…oAg) was accepted.
The token’s own field 5 doesn’t predict it: we’ve seen a token with 1 produce a card with 2, and a token with 2 produce a card with 1. Retrying with a fresh token 3 seconds later got another card with field 5 = 1 and was rejected again. A retry about 3 minutes later got 2 and worked.
Example from 2026-09-30 (UTC), one buyer:
| Time | Card id | Field 5 | Order | Result |
|---|---|---|---|---|
| 13:58:47 | ccof:CA4SEFZO8TOvmdOmiQjkhMeGyeEoAQ |
1 | dXUwAdNkYbUnye0ZpPOgJkrmZ16YY |
INVALID_CARD |
| 13:58:50 | ccof:CA4SELOIrmyIFu-H3ZqI5MwqMQAoAQ |
1 | BtmEsmVDhC5uUclSQtzmUFvpuLSZY |
INVALID_CARD |
| 14:01:46 | ccof:CA4SEB68CpFcqFRgbNiVXXQO-IEoAg |
2 | (invoice created) | success |
Questions
- How long does that state last, and is there an API signal we can check before calling CreateInvoice, other than decoding the id?
- What’s the recommended way to take a first invoice payment and keep the card for recurring invoices?
Happy to provide more ids or logs.