# Other Stripe payment methods

> Attribute Stripe invoices, customer-level payments and other flows, and see exactly which fields MetricRaven reads.

Source: https://metricraven.com/docs/stripe-other-methods  
Markdown: https://metricraven.com/docs/stripe-other-methods.md  
Section: Revenue

Every Stripe payment is imported once Stripe is connected. Attribution comes from a few metadata keys, wherever in Stripe you set them.

## Where MetricRaven looks

For each successful live charge, MetricRaven reads these keys from, in increasing priority:

1. the Customer's metadata,
2. the PaymentIntent's metadata,
3. the Checkout Session's metadata, only when the Customer and PaymentIntent carry neither a visitor ID nor a user ID,
4. for invoice payments, the subscription's metadata (as copied to the invoice) and the invoice's,
5. the Charge's own metadata.

| Metadata key | What it does |
| --- | --- |
| metricraven_visitor_id | The value of `window.analytics.getVisitorId()` in the buyer's browser. Links the payment to that visit and its traffic source. Anything that isn't a MetricRaven visitor ID is ignored. |
| metricraven_user_id | Your own user ID. If you call [Identify](https://metricraven.com/docs/identify-users) with the same ID, the payment joins that user's visits even without a visitor ID. |
| metricraven_plan | Optional plan name shown with the payment. Subscription invoices fall back to the price ID. |
| metricraven_renewal | Optional `"true"` for a repeat payment. Ignored for subscription invoices, where Stripe's billing reason decides. |

## Customer metadata: one place for every payment

If you create a Stripe Customer per user, set the keys there once. Invoices, the customer portal, upgrades and charges you make later all inherit it, however they're paid.

```javascript title="Server"
// When you create the Stripe customer (for example at signup).
const customer = await stripe.customers.create({
  email: authenticatedUser.email,
  metadata: {
    metricraven_user_id: authenticatedUser.id,
    metricraven_visitor_id: visitorId || "",
  },
});
```

## By payment method

| How you charge | Where to put the keys |
| --- | --- |
| Checkout Sessions | Session and PaymentIntent or subscription metadata; see [Stripe Checkout](https://metricraven.com/docs/stripe-checkout). |
| Payment Element / PaymentIntents | PaymentIntent or subscription metadata; see [Stripe PaymentIntents](https://metricraven.com/docs/stripe-payment-intents). |
| Payment Links, pricing tables, buy buttons | Needs a webhook; see [Stripe Payment Links](https://metricraven.com/docs/stripe-payment-links). |
| Subscriptions via the API | Subscription metadata, or the Customer's. |
| Invoices (Stripe Invoicing) | Invoice metadata, or the Customer's. |
| Dashboard charges and manual invoices | The Customer's metadata. Set it once in the Dashboard. |
| Platforms that charge through your Stripe account (Kajabi, Podia and similar) | Usually none you can set, so their payments import without a visit link. |

```javascript title="Server"
// Invoices you send yourself.
const invoice = await stripe.invoices.create({
  customer: customerId,
  metadata: { metricraven_user_id: authenticatedUser.id, metricraven_plan: "consulting" },
});
```

## Not on Stripe?

Send payments from your backend with the [Payments API](https://metricraven.com/docs/payments-api), or connect [RevenueCat](https://metricraven.com/docs/revenuecat) for app stores. Don't also send Stripe payments through the Payments API, or they're counted twice.

## Details

- Signed-in buyers can be linked by `metricraven_user_id` alone when you call [Identify](https://metricraven.com/docs/identify-users) with the same user ID.
- Metadata is read when MetricRaven imports the charge, usually within a minute or two of the payment. Set it when you create the object; adding it after the import doesn't change that payment.
- Once one payment from a Stripe customer is linked, that customer's later payments (renewals, upgrades) are linked to the same visitor and user, and their earlier unlinked payments are filled in.
- MetricRaven does not read `client_reference_id`, the customer's email, custom checkout fields or UTM parameters on Stripe links. Only the metadata keys above link a payment to a visit.
- Only live-mode payments are imported. Test-mode payments never appear in MetricRaven.
