# Respond to chargebacks

Connect your Stripe account or Shopify shop so Provenance adds your approval record to chargebacks on agent orders it checked, stages it at once and submits it before the deadline.

*Available on Pro, Growth and Enterprise.*

Connect your Stripe account and Provenance answers chargebacks on the agent orders it checked. When a dispute arrives, we match it to your decision, build a PDF from the [evidence pack](https://provenanceauth.com/docs/authorize/guides/chargeback-evidence.md), and write it into the dispute's own evidence fields with a short text and a dated activity log. Your own text and files stay as they are: ours goes after yours.

**Before you begin:** you need Pro or above, a Stripe account, and agent orders checked with [cart approvals](https://provenanceauth.com/docs/authorize/guides/ask-your-own-customer.md) or [assessments](https://provenanceauth.com/docs/authorize/guides/assess-checkouts.md). Provenance never moves money, never accepts or closes a dispute, and never touches shipping, customer or policy fields.

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
```

## 1. Connect Stripe

There are two ways in. Where the console offers **The Provenance Stripe App**, install it: no key to create or paste. Otherwise, or if you prefer, connect with a restricted key (steps 1a and 2).

### The Provenance Stripe App

In the console, open **Authorize → Stores → Connect Stripe**, choose **The Provenance Stripe App**, pick the response mode (acknowledge the notice for automatic responses) and select **Continue to Stripe**. Stripe asks you to install the app on your account and sends you back to Stores, connected. Provenance keeps only your Stripe account ID; calls run with Provenance's app key on your account, so no key of yours is stored. The connection reads `mode: app`.

To stop, select **Disconnect** on Stores and remove the app in Stripe (**Settings → Installed apps**). Removing it in Stripe disconnects it here too.

### 1a. Create a restricted key in Stripe

In the Stripe Dashboard, open **Developers → API keys → Create restricted key** and give it exactly these permissions:

| Resource | Permission |
| --- | --- |
| Disputes | Write |
| Files | Write |
| Charges | Read |
| PaymentIntents | Read |
| Webhook Endpoints | Write |

Optionally, also give it read access to shared payment tokens. With it, a shared payment token you name on a [checkout assessment](https://provenanceauth.com/docs/authorize/guides/assess-checkouts.md#card-network-agents-and-shared-payment-tokens) is checked on your account; without it, the token facts stay as reported, and the Approval Guarantee and these automatic responses leave token-paid orders out. Stripe's name for this resource may differ in your Dashboard: when a read is refused, the connection lists it in `permissions_missing` and stays connected.

Use a test-mode key (`rk_test_…`) with your sandbox account and a live key (`rk_live_…`) with your live account. The other mode is refused.

## 2. Connect it

Paste the key in the console (**Authorize → Stores → Connect Stripe**), or send it to `POST /v1/authorize/payment_connections/stripe/connect`. We check the key, create a webhook endpoint on your Stripe account for the dispute events, and keep the key sealed; it never comes back.

New connections respond automatically. Before that is on, you acknowledge one notice: submitting a response in Stripe starts Stripe's countered fee, returned if you win, and a response can be sent only once.

**curl**

```bash norun
curl -s -X POST $PROVENANCE_API/v1/authorize/payment_connections/stripe/connect \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "restricted_key": "rk_test_51Hq2vN8xK4tB7mW3sYd9cFjLh6gAe1pR5x", "fee_notice_acknowledged": true }'
```

**Node**

```ts
const res = await fetch(`${process.env.PROVENANCE_API}/v1/authorize/payment_connections/stripe/connect`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ restricted_key: process.env.STRIPE_RESTRICTED_KEY, fee_notice_acknowledged: true }),
});
```

**Python**

```python
import os, httpx

res = httpx.post(
    f"{os.environ['PROVENANCE_API']}/v1/authorize/payment_connections/stripe/connect",
    headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"},
    json={"restricted_key": os.environ["STRIPE_RESTRICTED_KEY"], "fee_notice_acknowledged": True},
)
```

```json
{
  "id": "pyc_01M7ZC3V8N2Q5S7U9W1Y3A5C7E",
  "object": "payment_connection",
  "platform": "stripe",
  "mode": "restricted_key",
  "status": "active",
  "key_hint": "pR5x",
  "chargeback_response": { "mode": "auto", "reasons": "fraud", "submit_lead_hours": 48, "smart_disputes": "step_aside" }
}
```

## 3. Name the payment on each order

So a dispute finds the right decision, name your Provenance decision on the payment. Set the metadata when you create the PaymentIntent, with the SDKs' `paymentMetadata` helper:

**Node**

```ts
import { paymentMetadata } from "@provenanceauth/sdk";

const assessment = await prov.authorize.assessments.create({ cart });
await stripe.paymentIntents.create({ amount: cart.total, currency: "usd", metadata: paymentMetadata(assessment) });
```

**Python**

```python
from provenanceauth import payment_metadata

assessment = prov.authorize.assessments.create(cart=cart)
stripe.PaymentIntent.create(amount=cart["total"], currency="usd", metadata=payment_metadata(assessment))
```

If you create the payment first, send its ID as `payment_reference` when you create the assessment or the cart approval instead. Without either, a PaymentIntent whose `order_id` metadata equals exactly one order reference of yours also matches. Anything else stays unmatched: we never guess.

## 4. What happens on a dispute

1. **Received.** Stripe sends the dispute; you get `authorize.chargeback.received`.
2. **Checked.** We answer chargebacks and inquiries that still need a response, for fraud and unrecognized disputes by default. Set `reasons` to `fraud_and_consumer` to add the customer reasons (not received, not as described). Compliance cases are never answered.
3. **Staged at once.** Our PDF goes in the file slot when it's free, and our text goes after yours. When the order had a [bank check](https://provenanceauth.com/docs/authorize/guides/bank-check.md), both state its 3-D Secure outcome. The response waits in Stripe, not sent, so you can add your own files. You get `authorize.chargeback.responded`.
4. **Submitted before the deadline.** 48 hours before the deadline (`submit_lead_hours`, 24 to 120) we read the dispute again, merge once more and submit, unless you or Stripe already did.
5. **Closed.** The outcome lands on the chargeback, responded or not, with `authorize.chargeback.closed`.

We submit automatically only for orders the person approved with a passkey for that exact order. These go to your review instead, staged with the facts stated, and we email your owners and admins:

| Order | What we do |
| --- | --- |
| Approved under a standing permission or a token the agent presented | Stage; you submit (`review_reason: standing_permission`) |
| The person reported it to Provenance as not recognized | Stage, with the report's date; you submit (`not_me_reported`) |
| Your connection is set to `mode: review` | Stage; you submit (`setting`) |
| Stripe Smart Disputes handles the dispute | Stage; Smart Disputes submits (`response_mode: stage_only`), unless you set `smart_disputes: submit_ourselves` |

Submit a staged response from Stripe, or with [`POST /v1/authorize/chargebacks/{id}/respond`](https://provenanceauth.com/docs/api/chargebacks.md#post-v1-authorize-chargebacks-id-respond). To leave a dispute alone, call [`POST /v1/authorize/chargebacks/{id}/dismiss`](https://provenanceauth.com/docs/api/chargebacks.md#post-v1-authorize-chargebacks-id-dismiss).

## 5. The Chargebacks page

**Authorize → Chargebacks** lists every chargeback, one line each: its status, the order, the reason, the amount and when a response is due. The tabs are **Needs response**, **Submitted**, **Closed** and **All**, and the list opens with the soonest due date first. Open one for the platform's status, the evidence we hold and when we wrote it, and the order it matched.

From there: **Send response now** (a response staged on Stripe and not yet sent), **Download evidence**, **Don't respond**, **Copy our text**, and **Open in Stripe** or **Open in Shopify**. A chargeback that matched nothing points to Orders.

Tick several rows to act once: **Send responses now**, **Download evidence** (one zip, a folder per order) and **Don't respond**. Each asks first and names the rows. If a response can't be sent, the bar says which one and keeps it selected; the others are sent. The same actions are [`POST /v1/authorize/chargeback_batches`](https://provenanceauth.com/docs/api/chargebacks.md#post-v1-authorize-chargeback-batches) with `{ "action": "respond" | "dismiss", "ids": [...] }` for up to 100 chargebacks, which answers once per ID:

```json
{
  "object": "chargeback_batch",
  "succeeded": 1,
  "failed": 1,
  "results": [
    { "id": "chb_01M7ZC4K2R8T5W1Y3B6D9F0H2J", "status": "ok", "state": "submitted" },
    { "id": "chb_01M7ZC4K9P3V6X8Z0B2D4F6H8K", "status": "failed", "error": { "type": "invalid_request_error", "code": "chargeback_state_invalid", "message": "This chargeback is submitted, so there is nothing to respond to." } }
  ]
}
```

## 6. Read a chargeback

[`GET /v1/authorize/chargebacks`](https://provenanceauth.com/docs/api/chargebacks.md#get-v1-authorize-chargebacks) lists them, newest first, or in the order you name with `sort`: due date, amount or created time, with `-` in front for descending (`sort=-amount`). Each one says what we wrote (the field names and hashes, never the text) and links the evidence pack behind it:

**curl**

```bash norun
curl -s "$PROVENANCE_API/v1/authorize/chargebacks?state=staged" -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const { data } = await prov.authorize.chargebacks.list({ state: "staged" });
```

**Python**

```python
page = prov.authorize.chargebacks.list(state="staged")
```

To answer a dispute yourself, in any platform's form, read the text we would write with [`GET /v1/authorize/chargebacks/{id}/dispute_text`](https://provenanceauth.com/docs/api/chargebacks.md#get-v1-authorize-chargebacks-id-dispute-text): the paragraph, the activity log and the evidence pack whose PDF you can attach. It works for any chargeback matched to one of your decisions and costs nothing.

**curl**

```bash norun
curl -s "$PROVENANCE_API/v1/authorize/chargebacks/chb_01M7ZC4K2R8T5W1Y3B6D9F0H2J/dispute_text" -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const text = await prov.authorize.chargebacks.disputeText("chb_01M7ZC4K2R8T5W1Y3B6D9F0H2J");
```

**Python**

```python
text = prov.authorize.chargebacks.dispute_text("chb_01M7ZC4K2R8T5W1Y3B6D9F0H2J")
```

For a customer-reason dispute, add your own references (tracking, a delivery photo note) with [`POST /v1/authorize/chargebacks/{id}/references`](https://provenanceauth.com/docs/api/chargebacks.md#post-v1-authorize-chargebacks-id-references). They appear on the PDF's last page, labelled as yours.

## 7. Chargeback protection

**Authorize › Chargeback protection** lists your own Chargeback protection records, beside **Chargebacks**. The head shows the protection limit used over the last 6 months ("Protection used", then the amount used of the limit) with a meter, and three facts: orders protected, disputed, and proof sent of disputes.

The tabs are **Protected**, **Disputed** and **Not protected**. Each row shows its status (a decided dispute reads "Disputed › Won" or "Disputed › Lost"), the order, why it is or isn't protected ("Approved with a passkey", "Within a mandate", or the reason it doesn't qualify), the amount and the date. A row opens the order with its trail: order approved, dispute opened, proof sent, bank decided.

An account without a program sees "Chargeback protection isn't on for this account." and opens on **Not protected**, which lists its own agent orders that would not qualify and why: no passkey approval on the order, paid under a standing permission, approved outside Provenance, or over the default order limit. It never shows sample rows.

The same data is in the API: `GET /v1/authorize/chargeback_protection` for the head and `GET /v1/authorize/chargeback_protection/orders?tab=disputed` for a tab (see the [API reference](https://provenanceauth.com/docs/api.md)). To show it in your own admin tool, use [`<provenance-chargeback-protection>`](https://provenanceauth.com/docs/embeds/chargeback-protection.md).

The view shows records only. It doesn't state the program's terms, and nothing in it promises a payment.

## Shopify Payments

On a [connected Shopify shop](https://provenanceauth.com/docs/authorize/guides/shopify.md), chargebacks work the same way, with three differences:

- The shop grants Shopify Payments' dispute access to the Provenance app. When the shop's Chargebacks rows on Stores show **Grant dispute access** (`dispute_access_grantable: true`), select it: Shopify asks you to approve the new access and sends you back.
- Disputes match through the shop's own orders.
- Shopify's API can't submit or upload a file, so we stage our text and activity log after yours. Shopify sends the evidence on the due date, or when you submit it earlier in the Shopify admin.

Set the mode and reasons with `chargeback_response` on [`PATCH /v1/authorize/store_connections/{id}`](https://provenanceauth.com/docs/api/store-integrations.md#patch-v1-authorize-store-connections-id), or on the shop's Chargebacks rows.

`dispute_access` says what we can do on the shop's disputes:

| `dispute_access` | What happens |
| --- | --- |
| `granted` | We stage our text in the dispute; Shopify sends it. |
| `read_only` | We match the dispute and prepare our text, but can't write it. The chargeback reads `response_mode: paste`: copy the text from the Chargebacks page (or the Provenance app in Shopify's admin, or `GET …/dispute_text`) into the dispute's evidence in Shopify, and attach the evidence pack's PDF if you like. We email your owners and admins when one arrives. |
| `not_granted` | The shop was connected before dispute access was asked for. Grant dispute access. |
| `off` | Dispute access isn't offered yet. Make an [evidence pack](https://provenanceauth.com/docs/authorize/guides/chargeback-evidence.md): its `dispute_text` holds the same paragraph and activity log to paste into the dispute form. |

The Provenance app inside Shopify's admin has a Chargebacks card with the same rows and **Copy our text**.

## Pricing

On Pro and above, a won dispute where our evidence was part of the response bills 10% of the amount won (`chargeback_success_fee` on your [usage](https://provenanceauth.com/docs/account/plans-and-usage.md)). Nothing is billed on a loss, on a dispute we didn't answer, or for staging. The success fee is billed on USD disputes. A dispute you answered by pasting our text (`response_mode: paste`) is never billed: we can't see what was sent. Connecting with the Stripe App or a restricted key costs the same.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `payment_connection_key_invalid` (400) | Not a restricted key, a key for the other mode, refused by Stripe, or missing a permission (named in the message) | Create the key with the five permissions above and paste it again. |
| `parameter_invalid` (400) on `fee_notice_acknowledged` | Automatic responses need the notice acknowledged | Send `fee_notice_acknowledged: true`, or set `mode: review`. |
| `payment_connection_exists` (409) | The account already has a Stripe connection, or the Stripe account is connected to another Provenance account | Disconnect it first, or change its settings. |
| `payment_connection_state_invalid` (400) | Stripe sent you back after the app's install with an expired link, or to another browser session | Start again from **Connect Stripe** in the same browser. |
| `payment_connection_unconfigured` (503) | This deployment doesn't offer that way in (the Stripe App or the restricted key) | Use the other way, or make an evidence pack by hand. |
| `chargeback_state_invalid` (409) | Submit now needs a response staged and not yet sent | Read the chargeback's `state`. |
| A chargeback reads `unmatched` | The payment names no decision of yours (`state_reason`: `chargeback_no_reference`, `chargeback_not_found`, `chargeback_ambiguous`, `chargeback_amount_mismatch`) | Build a pack by hand with [chargeback evidence](https://provenanceauth.com/docs/authorize/guides/chargeback-evidence.md), and name the payment on future orders. |
| A chargeback reads `failed` | Stripe refused a call (`last_error_code`), or the key was revoked | Check the connection's `status`; connect again with a new key if it reads `failing`. |

## See also

- [Chargeback evidence](https://provenanceauth.com/docs/authorize/guides/chargeback-evidence.md)
- [Assess checkouts](https://provenanceauth.com/docs/authorize/guides/assess-checkouts.md)
- [Webhook events](https://provenanceauth.com/docs/reference/webhook-events.md)
