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

# Accept Stripe SPT Payments

> Receive a Stripe Shared Payment Token from Clink and charge it on your own Stripe account.

A Stripe Shared Payment Token (SPT) lets an Agent using Clink Agent Pay pay for an order on your platform without sending the user to a checkout page. Clink obtains an SPT that only your Stripe account can use, limited to the order amount, and sends it to an endpoint you provide. Your server charges it on your own Stripe account.

## How it works

```mermaid theme={null}
sequenceDiagram
  participant U as User
  participant C as Clink
  participant S as Stripe
  participant M as Your server

  U->>C: Ask the Agent to buy
  C->>M: Create order
  M-->>C: Order ID, final amount, currency
  C->>S: Request SPT (your Profile ID, user's payment method, amount limit)
  S-->>C: spt_xxx
  C->>M: Send the SPT to your endpoint
  M->>S: Create and confirm a PaymentIntent with the SPT
  S-->>M: Payment result
  M-->>C: SUCCEEDED / PROCESSING / FAILED

  opt Result is PROCESSING
    C->>M: Query payment status
    M-->>C: Final status
  end
```

| Party | Responsibility |
| - | - |
| Clink | Requests the SPT from Stripe with your Stripe Profile ID, the user's payment method, and the order amount and currency. Sends the SPT to your endpoint and follows up on payments that are still processing. |
| You | Share your Stripe Profile ID, return the final amount and currency for each order, provide the endpoint that receives the SPT, charge it through Stripe, and report the result. |

## Before you start

* A Stripe account where Stripe offers SPT to sellers. Check availability and terms in the [Stripe SPT documentation](https://docs.stripe.com/agentic-commerce/concepts/shared-payment-tokens?agent-seller=seller).
* A [Stripe profile](https://docs.stripe.com/get-started/account/profile) created in the Stripe Dashboard.
* An order API or MCP tool that Clink can call to create an order on behalf of the user.

## 1. Share your Stripe Profile ID

Send Clink your Stripe Profile ID (`profile_xxx`) for both the sandbox and live environments. Clink uses it to request SPTs that are granted to your Stripe account only.

## 2. Return the final amount and currency

Clink requests each SPT with a limit equal to the order's final payable amount. When Clink creates an order, return:

* The order ID
* The final payable amount, including fees and discounts
* The ISO 4217 currency code, such as `USD`

If you charge more than the amount you returned, Stripe rejects the payment.

## 3. Provide an endpoint that receives the SPT

Expose an HTTPS endpoint that Clink calls after it obtains the SPT. If Clink already reaches your platform through MCP, you can provide an MCP tool instead. The request and response below are a reference. The path, field names, and authentication method are confirmed with Clink during integration.

### Example request

```json theme={null}
{
  "orderId": "order_10001",
  "sharedPaymentToken": "spt_example"
}
```

| Field | Type | Required | Description |
| - | - | - | - |
| `orderId` | string | Yes | The order ID you returned when the order was created. Use the field name from your own order API. |
| `sharedPaymentToken` | string | Yes | The SPT (`spt_xxx`) issued by Stripe. |

The request carries no amount. Always take the amount and currency from your own order record.

### Example response

```json Succeeded theme={null}
{
  "orderId": "order_10001",
  "paymentStatus": "SUCCEEDED",
  "paidAmount": 17.41,
  "currency": "USD"
}
```

```json Processing theme={null}
{
  "orderId": "order_10001",
  "paymentStatus": "PROCESSING"
}
```

```json Failed theme={null}
{
  "orderId": "order_10001",
  "paymentStatus": "FAILED",
  "failureCode": "card_declined",
  "failureMessage": "Your card was declined."
}
```

| Field | Type | Description |
| - | - | - |
| `orderId` | string | The order ID from the request. |
| `paymentStatus` | string | `SUCCEEDED`, `PROCESSING`, or `FAILED`. |
| `paidAmount` | number | The amount charged, in the currency's standard unit, such as `17.41`. Returned when the payment succeeded. |
| `currency` | string | ISO 4217 currency code. Returned when the payment succeeded. |
| `failureCode` | string | Returned when the payment failed. Pass through Stripe's `error.code`, or use your own code for validation failures, such as `ORDER_NOT_FOUND` or `ORDER_ALREADY_PAID`. |
| `failureMessage` | string | A description of the failure. Returned when the payment failed. |

> [!WARNING]
>
> Accept this request only from Clink, and handle the SPT on your server only. Do not write the full token to logs.

## 4. Charge the SPT

Confirm that the order exists and is unpaid, read the amount and currency from your order record, and create and confirm a Stripe `PaymentIntent`:

```bash theme={null}
curl https://api.stripe.com/v1/payment_intents \
  -u "$STRIPE_SECRET_KEY:" \
  -H "Stripe-Version: 2026-09-30.preview" \
  -d amount=1741 \
  -d currency=usd \
  -d "payment_method_data[shared_payment_granted_token]=spt_example" \
  -d "metadata[orderId]=order_10001" \
  -d confirm=true
```

* Stripe takes the amount in the currency's smallest unit and the currency code in lowercase: `17.41 USD` becomes `amount=1741` and `currency=usd`.
* No user is present to follow a redirect. If Stripe asks for a `return_url` when you confirm, add `automatic_payment_methods[enabled]=true` and `automatic_payment_methods[allow_redirects]=never`.
* Writing the order ID to `metadata` lets you match the Stripe payment to your order during reconciliation and in webhooks.
* SPT is a Stripe preview feature. Use the `Stripe-Version` and parameters in the current [Stripe SPT documentation](https://docs.stripe.com/agentic-commerce/concepts/shared-payment-tokens?agent-seller=seller).

### Map the result

| Stripe result | `paymentStatus` | What to do |
| - | - | - |
| `succeeded` | `SUCCEEDED` | Mark the order as paid. Return `paidAmount` and `currency`. |
| `processing` | `PROCESSING` | Keep the order pending and settle it later. |
| `requires_payment_method`, `requires_action`, `canceled`, or an error response | `FAILED` | Return `failureCode` and `failureMessage`. |

No user is present to complete an extra authentication step, so treat `requires_action` as a failure. Cancel a PaymentIntent you report as `FAILED` if it is still open, so that it cannot complete afterwards.

Stripe can return `processing` directly, which means the payment has no final result yet. Return `PROCESSING` in that case, not `FAILED`.

## 5. Settle payments that are processing

When you return `PROCESSING`, Clink queries the payment status until it is final. You need to:

* Bring the order to its final state. Listen for the Stripe webhooks `payment_intent.succeeded` and `payment_intent.payment_failed`, or retrieve the PaymentIntent from Stripe when Clink queries the status.
* Provide a payment status query that takes the order ID and returns the current payment status. An existing order or payment status query can serve this purpose.

## Refunds and reconciliation

Once the PaymentIntent is confirmed, Stripe treats it like any other payment on your account. Refund and reconcile it through your existing Stripe process.

## Test in the sandbox

Stripe provides a test helper that grants your sandbox account an SPT, so you can test the endpoint before joint testing with Clink:

```bash theme={null}
curl https://api.stripe.com/v1/test_helpers/shared_payment/granted_tokens \
  -u "$STRIPE_SECRET_KEY:" \
  -H "Stripe-Version: 2026-09-30.preview" \
  -d payment_method=pm_card_visa \
  -d "usage_limits[currency]=usd" \
  -d "usage_limits[max_amount]=1741" \
  -d "usage_limits[expires_at]=$(($(date +%s) + 3600))"
```

Use your Stripe sandbox secret key, then call your endpoint with the returned `spt_xxx` and confirm that:

* A valid request charges the order once and returns `SUCCEEDED` with the amount and currency.
* A request for an order that is already paid does not charge twice.
* An unknown order returns `FAILED`.
* An order amount above `max_amount`, or an expired token, returns `FAILED` with Stripe's error code.

## Before going live

* Clink has your live Stripe Profile ID.
* The endpoint uses your live Stripe secret key, kept on the server.
* The amount and currency come from your order record.
* Payments returned as `PROCESSING` reach a final state, and Stripe webhook signatures are verified.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.