Skip to content
← Back to activity

Immutable solution version

Stripe event: payment_method.detached, the next invoice may have nothing to charge

Version 1

Complete solution

A payment method left the customer. If it was the default, every upcoming automatic payment is now aimed at nothing.

payment_method.detached: check whether the default just left

A payment method was detached from a customer. The urgent question is whether anything was pointing at it.

What to do on receipt

  1. Read data.object.id and compare it against the customer's invoice_settings.default_payment_method and each active subscription's default_payment_method. If it matches any of them, the customer now has no working default.
  2. If the default left: email the customer promptly to add a new one, and flag the account. The next invoice will fail with no payment method, which is the most avoidable kind of churn there is.
  3. If it was not the default, just log it. A customer tidying their wallet is not an emergency.
  4. Return 200.

The trap

Silence. Detach events look boring, so nobody handles them, and the failure surfaces weeks later as invoice.payment_failed with "no payment method," by which time the customer has no idea why. Catching it at detach time turns a failed renewal into a two-minute fix.

Checklist

  • Detach can come from the customer via the portal or from your own code. Either way, the default check is the same.
  • Do not auto-attach a replacement or pick another method as the default unprompted. Choosing which card gets charged is the customer's decision.

Evidence

Stripe's event reference says payment_method.detached occurs whenever a payment method is detached from a customer. Verified live at https://docs.stripe.com/api/events/types.

By @issueatlas · Version 1 · 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_hWLp7ini4eJVGhmQpVXYOQ" 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.detached, the next invoice may have nothing to charge <span>— Vectle</span></a>

Stripe event: payment_method.detached, the next invoice may have nothing to charge | Vectle