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

# Clone Stripe pricing

> Rebuild Stripe's per-transaction pricing in Lago with product filters per payment type and percentage rates billed in advance on a contract.

This template builds per-transaction pricing like Stripe's with Lago: a percentage of each transaction amount plus a fixed fee per transaction. It suits fintechs and marketplaces that take a fee on the payment volume they process for customers.

Legacy (v1): [Clone Stripe pricing with subscriptions](https://getlago.com/docs/templates/per-transaction/stripe.md).

## Pricing structure

Stripe charges per successful card payment. The rate and the fixed fee depend on the payment method. This template covers card payments.

| Payment method | Percentage of transaction amount | Fixed fee per transaction |
| - | - | - |
| Card payments (online) | 2.9% | \$0.30 |
| Card payments (in-person) | 2.7% | \$0.05 |

## How it maps to Lago

| Pricing element | Lago object |
| - | - |
| Transaction amount | Billable metric `card_transactions` (`sum_agg` on `amount`) with a `type` dimension |
| What you sell | Metered product `card_processing` |
| Online and in-person payments | Product filters `card_online` and `card_in_person` |
| Fee per payment type | One rate card per filter, billed in advance, with a `percentage` rate |
| The offer | Plan `card_processing_plan` |

## Get started

**1. Set up Lago**

```bash cURL theme={"dark"}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
```

Use `https://api.eu.getlago.com` for the EU cluster. API endpoints live under `/api/v2` and require the product catalog to be enabled on your organization.

**2. Create a billable metric**

Sum transaction amounts, with a `type` dimension for the payment method.

```bash cURL highlight={6,8-15} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/billable_metrics" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "billable_metric": {
      "name": "Transaction amount",
      "code": "card_transactions",
      "aggregation_type": "sum_agg",
      "field_name": "amount",
      "recurring": false,
      "filters": [
        {
          "key": "type",
          "values": ["online", "in-person"]
        }
      ]
    }
  }'
```

Refer to the [API reference](https://getlago.com/docs/v2/api-reference/billable-metrics/create.md) and the [billable metrics guide](https://getlago.com/docs/v2/guide/billable-metrics/create-billable-metrics.md).

**3. Create a metered product and its filters**

```bash cURL highlight={7-8} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/products" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "product": {
      "name": "Card processing",
      "code": "card_processing",
      "product_type": "metered",
      "billable_metric_code": "card_transactions"
    }
  }'
```

Create one filter per payment type:

```bash cURL highlight={6,8-10} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/products/card_processing/filters" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "filter": {
      "name": "Online card payment",
      "code": "card_online",
      "values": [
        { "key": "type", "value": "online" }
      ]
    }
  }'
```

Create `card_in_person` the same way with `"value": "in-person"`. Refer to the [product filters guide](https://getlago.com/docs/v2/guide/product-catalog/product-filters.md).

**4. Create a rate card per filter**

Set `billing_timing` to `advance` so fees are charged as transactions arrive. The `percentage` rate takes `rate` (the percentage) and `fixed_amount` (the per-transaction fee).

```bash cURL highlight={9-11,15-20} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/rate_cards" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "rate_card": {
      "name": "Online card payment USD",
      "code": "card_online_usd",
      "product_code": "card_processing",
      "product_filter_code": "card_online",
      "currency": "USD",
      "billing_timing": "advance",
      "proration": false,
      "rates": [
        {
          "code": "card_online_standard",
          "effective_from": "2027-01-01T00:00:00Z",
          "rate_model": "percentage",
          "rate_properties": {
            "rate": "2.9",
            "fixed_amount": "0.30"
          },
          "billing_interval_count": 1,
          "billing_interval_unit": "month"
        }
      ]
    }
  }'
```

Repeat for in-person payments:

| Rate card `code` | `product_filter_code` | `rate` | `fixed_amount` |
| - | - | - | - |
| `card_online_usd` | `card_online` | `"2.9"` | `"0.30"` |
| `card_in_person_usd` | `card_in_person` | `"2.7"` | `"0.05"` |

Spending minimums (`min_amount_cents`) are not available with advance billing. Refer to the [API reference](https://getlago.com/docs/v2/api-reference/rate-cards/create.md) and the [percentage model](https://getlago.com/docs/v2/guide/rate-cards/pricing-models/percentage.md).

**5. Create a plan and apply the rate cards**

```bash cURL highlight={6-7} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/plans" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "plan": {
      "name": "Card processing",
      "code": "card_processing_plan",
      "currency": "USD"
    }
  }'
```

Apply `card_online_usd` and `card_in_person_usd`:

```bash cURL highlight={6} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/plans/card_processing_plan/applied_rate_cards" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "applied_rate_card": {
      "rate_card_code": "card_online_usd"
    }
  }'
```

Refer to the [API reference](https://getlago.com/docs/v2/api-reference/plan-applied-rate-cards/create.md) and the [plans guide](https://getlago.com/docs/v2/guide/plans/overview.md).

**6. Create a customer**

```bash cURL highlight={6} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/customers" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "customer": {
      "external_id": "customer_example",
      "name": "Acme Corp",
      "email": "billing@example.com",
      "currency": "USD"
    }
  }'
```

An existing `external_id` returns `422` instead of updating the customer. Refer to the [API reference](https://getlago.com/docs/v2/api-reference/customers/create.md) to create a customer.

**7. Create a contract**

Replace `__PLAN_CODE__` with `card_processing_plan`.

```bash cURL highlight={6-10} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/contracts" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "contract": {
      "external_id": "contract_example",
      "external_customer_id": "customer_example",
      "plan_code": "__PLAN_CODE__",
      "started_at": "2027-01-01T00:00:00Z",
      "billing_anchor_date": "2027-02-01"
    }
  }'
```

The plan supplies the contract's initial applied rate cards. A future `started_at` creates a `pending` contract that becomes `active` on that date. Only one pending or active contract can use a given `external_id` at a time. Refer to the [API reference](https://getlago.com/docs/v2/api-reference/contracts/create.md) to create a contract.

> [!NOTE]
>
> The example dates are in the future. To test right away, set each rate's `effective_from` to today and omit `started_at`, which defaults to now.

**8. Ingest transactions via events**

Send one event per transaction with its `amount` and `type`.

```bash cURL highlight={7-11} theme={"dark"}
curl --location --request POST "$LAGO_URL/api/v2/events" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "event": {
      "transaction_id": "__TRANSACTION_ID__",
      "code": "card_transactions",
      "external_contract_id": "contract_example",
      "properties": {
        "amount": 200,
        "type": "online"
      }
    }
  }'
```

Refer to the [API reference](https://getlago.com/docs/v2/api-reference/events/create.md) and the [usage ingestion guide](https://getlago.com/docs/v2/guide/events/ingesting-usage.md).

**9. Monitor current usage**

Track usage across the contract's open billing periods.

```bash cURL highlight={1} theme={"dark"}
curl --location --request GET "$LAGO_URL/api/v2/contracts/contract_example/current_usage" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json'
```

The response returns `amount_cents`, `taxes_amount_cents`, `total_amount_cents` and a `rate_cards` array with usage per applied rate card. Pending contracts have no usage. Totals can span several invoices, so this is not a preview of one invoice. Filter with `rate_card_code`, `product_code`, `product_filter_code` or `product_type`. Refer to the [API reference](https://getlago.com/docs/v2/api-reference/contracts/retrieve-current-usage.md) to get current usage.

## Worked example

One online card payment of \$200:

| Component | Calculation | Amount |
| - | - | - |
| Percentage | 2.9% × \$200 | \$5.80 |
| Fixed fee | 1 transaction × \$0.30 | \$0.30 |
| **Fee before tax** | | **\$6.10** |

## What changed from v1

* The v1 template set `invoiceable: false` on the charge. v2 rate cards have `display_on_invoice` and `regroup_paid_fees`, which control how advance fees appear on invoices. They are not a one-to-one replacement, so this template keeps the defaults.
* The v1 template estimated fees with `POST /events/estimate_fees`. The v2 API does not document an equivalent, so this template omits fee estimation.
* Events target `external_contract_id` instead of `external_subscription_id`.

> [card] [Percentage model](https://getlago.com/docs/v2/guide/rate-cards/pricing-models/percentage.md)
>
> Calculate a fee from a measured monetary base.

> [card] [Rate cards](https://getlago.com/docs/v2/guide/rate-cards/overview.md)
>
> Currency, billing timing and proration per product or filter.

> [card] [Contracts](https://getlago.com/docs/v2/guide/contracts/overview.md)
>
> Apply a plan to a customer.

> [card] [Create a product filter (API)](https://getlago.com/docs/v2/api-reference/product-filters/create.md)
>
> `POST /api/v2/products/{product_code}/filters`


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