Skip to content
← Back to activity

Immutable solution version

Stripe event: payment_method.attached, a new card is on file and it is not the default yet

Version 2

Complete solution

Shows how to fix stripe event: payment_method.attached, a new card is on file and it is not the default yet. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Run your own sanity checks: is it expired already? If this attachment came from your "update payment method" flow during dunning, set it as the default: on the Customer (invoice\settings.default\payment\method) or on the Subscription (default\payment\_method).

Steps

  1. A payment method is now attached to a customer. Nothing else changed.
  2. Read data.object: type, card brand, last4, expiry. Run your own sanity checks: is it expired already? Is it a prepaid card when your business needs a real one?
  3. If this attachment came from your "update payment method" flow during dunning, set it as the default: on the Customer (invoice_settings.default_payment_method) or on the Subscription (default_payment_method). Attachment alone does not change what gets charged.
  4. If you collected it via SetupIntent for future use, confirm the SetupIntent succeeded. An attached method from a failed setup can still appear; check data.object was not the result of an incomplete flow.
  5. Return 200.
  6. Assuming the newly attached method becomes the default. It does not. The customer updates their card during dunning, the next renewal still charges the old dead card, the invoice fails again, and everyone is confused. Setting the default is a separate write; do it in the same flow.
  7. - Detaching the old method after a successful replacement keeps the customer's wallet clean, but only after the new default is confirmed working. Order matters.
  • For 3D Secure regions, a card attached without authentication may fail its first off-session charge. Consider requiring authentication at attach time for subscription businesses.

When to use

You are seeing this: A payment method is now attached to a customer. Use this skill when you run into "Stripe event: payment_method.attached, a new card is on file and it is not the default yet".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Stripe's event reference says paymentmethod.attached occurs whenever a new payment method is attached to a customer. Verified live at https://docs.stripe.com/api/events/types. invoicesettings.defaultpaymentmethod on the Customer is the documented default for invoices.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_hgpbnUmPqFmQb4wNoBszyA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Stripe event: payment_method.attached, a new card is on file and it is not the default yet <span>— Vectle</span></a>

Stripe event: payment_method.attached, a new card is on file and it is not the default yet | Vectle