> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upstackdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# payment_failed Event

> Track when a payment attempt fails.

Fires when a payment attempt fails. Use this event to trigger dunning workflows and identify at-risk subscriptions.

## JavaScript

```javascript theme={null}
window._upstack('track', 'payment_failed', {
  accountId: 'acct_abc123',
  invoiceId: 'inv_ghi012',
  subscriptionId: 'sub_def456',
  amount: 9900,
  failureReason: 'card_declined',
  failureCode: 'insufficient_funds',
  currency: 'USD'
});
```

## Properties

| Property       | Type   | Required | Description                    |
| -------------- | ------ | -------- | ------------------------------ |
| accountId      | string | Yes      | Account identifier             |
| amount         | number | Yes      | Failed payment amount in cents |
| invoiceId      | string | No       | Invoice identifier             |
| subscriptionId | string | No       | Subscription identifier        |
| failureReason  | string | No       | Failure reason code            |
| failureCode    | string | No       | Detailed failure code          |
| currency       | string | No       | ISO 4217 currency code         |

## When to Fire

* When card is declined
* When insufficient funds error occurs
* When Stripe `invoice.payment_failed` webhook fires

## Stripe Webhook

Maps to `invoice.payment_failed`.

<Warning>
  Track payment failures to identify at-risk customers and trigger dunning workflows.
</Warning>
