# Creem setup guide: price tests with custom_price and verified orders

Source: https://leverprice.com/integrations/creem
Updated: 2026-11-18

> Leverprice tests prices on Creem. Your server passes each visitor's assigned price as custom_price on a one-time product's checkout, and an order counts only after Creem's signed checkout.completed webhook confirms it. You connect the webhook secret, never an API key. One-time payments and a subscription's first payment are verified; renewals never count.

Creem can charge a different price on every checkout of a one-time product: `custom_price` on `POST /v1/checkouts` overrides the product's price for that session ([API reference](https://docs.creem.io/api-reference/endpoint/create-checkout)). That is the field Leverprice tests prices with. Your server passes each visitor's assigned price, and Creem's signed `checkout.completed` webhook reports the order back. An order counts toward the test only after Leverprice has checked the signature, so the revenue in your results is revenue Creem recorded.

The connection uses the endpoint's webhook secret, which confirms that an event came from Creem and can't call Creem's API. Creem is the merchant of record and collects tax, so Leverprice counts every order before tax: a buyer's VAT rate never makes one price look better than another.

This is the step-by-step setup. For what it does on Creem, see [price testing for Creem](https://leverprice.com/price-testing/creem) and [PPP pricing for Creem](https://leverprice.com/ppp-pricing/creem).

## How does price testing work on Creem?

1. In Leverprice, you add a product in the same currency as your Creem product, USD or EUR, with the price range you'd accept, for example $19 to $49, and start a test. Your current price stays the fallback.
2. Where the price is shown, your server calls `getPrice()` and renders `quote.price`. A signed first-party cookie keeps each visitor on one price.
3. Where the checkout is created, it asks again and creates a Creem checkout with `quote.price` as the custom price and `quote.metadata` as the metadata.
4. Creem sends `checkout.completed`. Leverprice checks the signature, credits the order to the price the visitor saw and moves traffic toward the price that earns the most per visitor.

Creem accepts a `custom_price` from 100 (one whole unit of the currency) to 99,999,999 ([API reference](https://docs.creem.io/api-reference/endpoint/create-checkout)). Inside those limits, the product's price range in Leverprice is your bound: the SDK never returns a price outside it. If Leverprice is slow or down, `getPrice()` returns your fallback price within 500 ms.

## How do I connect Creem webhooks to Leverprice?

1. In Leverprice, open **Setup** and pick Creem in the **Connect payments** step for test mode, or in **Go live** for live payments. Leverprice generates a webhook URL.
2. In Creem, switch the dashboard to the same mode with the **Test Mode** toggle at the bottom of the sidebar ([Creem docs](https://docs.creem.io/getting-started/test-mode)), go to **Developers → Webhooks** and add an endpoint with the Leverprice URL.
3. Select `checkout.completed` and `refund.created`.
4. Copy the endpoint's secret and paste it into Leverprice as Creem shows it, `whsec_` prefix included.

| Event | What Leverprice does with it |
|---|---|
| `checkout.completed` | Counts paid orders: one-time payments and a subscription's first payment |
| `refund.created` | Takes each refund off that price's revenue, before tax |

Creem signs each delivery in the `creem-signature` header: a hex HMAC-SHA256 of the raw request body, keyed with the webhook secret ([Creem docs](https://docs.creem.io/code/webhooks)). That scheme carries no timestamp, so there is no replay window to check. Leverprice records each order and each refund once, so a replayed delivery changes nothing.

*Figure: An order moves from your checkout to Creem, then as a signed webhook to Leverprice, which records a verified purchase. Leverprice is one more webhook endpoint in Creem. Any endpoint you already use keeps receiving the same events.*

## How do I charge the tested price in a Creem checkout?

Pass `quote.price` as `customPrice` when you create the checkout. Creem reads it in cents, in the product's currency, and supports it on one-time payment products only ([API reference](https://docs.creem.io/api-reference/endpoint/create-checkout)). The checkout's `metadata` comes back on `checkout.completed` ([Creem docs](https://docs.creem.io/code/webhooks)), which is where Leverprice reads the attribution.

Create the Leverprice client once ([setup details](https://leverprice.com/docs)):

```ts title="lib/leverprice.ts"
import { Leverprice } from "@leverprice/sdk";

export const leverprice = new Leverprice({
  secretKey: process.env.LEVERPRICE_SECRET_KEY, // server only
  products: {
    // Prices outside the product's range in Leverprice are never returned.
    pro: { currency: "usd", fallbackPrice: 2900 },
  },
});
```

The checkout route uses Creem's TypeScript SDK:

```ts title="app/api/checkout/route.ts"
import { Creem } from "creem";
import { leverprice } from "@/lib/leverprice";

const creem = new Creem({
  apiKey: process.env.CREEM_API_KEY!,
  server: process.env.CREEM_TEST_MODE === "1" ? "test" : undefined, // undefined = live
});

export async function POST(request: Request) {
  // Ask again here. Never trust a price sent by the browser.
  const quote = await leverprice.getPrice("pro", { request });

  const checkout = await creem.checkouts.create({
    productId: process.env.CREEM_PRODUCT_ID!, // a one-time product
    customPrice: quote.price, // cents: 2900 = $29.00
    metadata: quote.metadata, // signed attribution: pass it whole
    successUrl: "https://example.com/thanks",
  });

  const headers = new Headers({ Location: checkout.checkoutUrl! });
  for (const cookie of quote.setCookie) headers.append("Set-Cookie", cookie);
  return new Response(null, { status: 303, headers });
}
```

`quote.metadata` carries four signed values (`pp_exp`, `pp_var`, `pp_vid` and `pp_sig`), and Leverprice drops attribution whose signature doesn't match, so pass the object whole. Before you send live traffic, make one test-mode purchase and check that it lands under its price in Leverprice.

From each order, Leverprice counts `amount_paid` minus `tax_amount`. Creem defines `amount_paid` as what the customer was charged, after any discount ([Creem docs](https://docs.creem.io/code/webhooks)), so the result is the amount after discounts and before tax. The [Next.js guide](https://leverprice.com/guides/nextjs) shows the pricing page and this route together.

## Can I test subscription prices on Creem?

Yes, with one Creem product per test price. `custom_price` works on one-time products only ([API reference](https://docs.creem.io/api-reference/endpoint/create-checkout)), so create a subscription product for each price in the test and pick the product ID from `quote.price` on your server:

```ts title="app/api/checkout/route.ts"
// One Creem subscription product per price in the test, fallback price included.
const PRODUCTS: Record<number, string> = {
  1900: "prod_…",
  2900: "prod_…",
  3900: "prod_…",
};

const productId = PRODUCTS[quote.price];
if (!productId) return new Response("No Creem product for this price", { status: 500 });

const checkout = await creem.checkouts.create({
  productId,
  metadata: quote.metadata, // still pass it whole
  successUrl: "https://example.com/thanks",
});
```

Prices by country come out at amounts a map like this doesn't list, so keep regional prices off for a product you test this way. Leverprice verifies the first payment through `checkout.completed`. Renewals arrive as `subscription.paid` ([Creem docs](https://docs.creem.io/code/webhooks)), which the Leverprice endpoint doesn't subscribe to, so they never count: each price is judged on first payments minus refunds.

Leave trials off test products. Creem offers free and paid trials, and with either one the regular price, the one you're testing, is charged after the trial ends ([Creem docs](https://docs.creem.io/features/trials)). Leverprice skips checkouts that start a trial.

## What happens when I refund a Creem order?

Creem sends `refund.created` once a refund has succeeded ([Creem docs](https://docs.creem.io/code/webhooks)), and Leverprice matches it to the order through the transaction ID. A refund of a later renewal has its own transaction, so it never touches the first payment.

Creem reports the refunded amount including tax, while the order was recorded before tax, so Leverprice takes off the refund's pre-tax share. Example: an order of $29.00 plus 21% VAT is paid as $35.09. A full refund takes the whole $29.00 off and turns the sale into a refunded purchase. A $10.00 partial refund comes off as $10.00 × 29.00 / 35.09 = $8.26.

## Can I try it in Creem test mode first?

Yes. Creem's test mode keeps API calls, payments, webhooks and data apart from production, with its own API keys and its API at test-api.creem.io ([Creem docs](https://docs.creem.io/getting-started/test-mode)). Add the endpoint in test mode and connect it in Leverprice as Test, then add a second endpoint in live mode and connect it as Live. Each endpoint has its own secret.

Every Creem payload carries a `mode`, and Leverprice treats `prod` as live and keeps test purchases out of live results. Run your app with your `pp_sk_test_…` key and `server: "test"` in the Creem SDK, and pay with Creem's test card 4111 1111 1111 1111 ([Creem docs](https://docs.creem.io/getting-started/test-mode)).

## What if a customer pays in another currency?

Creem prices products in USD or EUR ([Creem FAQ](https://docs.creem.io/guides/faq)), and `custom_price` is charged in the product's currency ([API reference](https://docs.creem.io/api-reference/endpoint/create-checkout)). If that currency differs from the experiment's, Leverprice converts the order back at daily reference exchange rates, so it still counts for the price the visitor was assigned.

For prices by country ([regional prices](https://leverprice.com/blog/regional-pricing), on Pro and Lifetime), keep **Charge in** set to your product's currency in Leverprice and leave `localCurrencies` off in the client, because `custom_price` carries no currency of its own. Visitors whose price would be in another currency then get your standard price.

## What does Leverprice verify on Creem?

| Creem order | Counts toward the test |
|---|---|
| One-time payment with `custom_price` | Yes, at amount paid minus tax |
| Subscription's first payment | Yes |
| Checkout that starts a free or paid trial | No |
| Renewal (`subscription.paid`) | No |
| $0 order, such as a 100% discount | No |
| Refund, full or partial | Yes, at its pre-tax share |

## Frequently asked questions

### Does Leverprice need my Creem API key?

No. Your server keeps its API key and creates every checkout. Leverprice stores only the webhook secret, encrypted, and that secret can't call Creem's API.

### Why does a subscription test on Creem need a product per price?

Because `custom_price` is how a server sets the price of one checkout on Creem, and Creem supports it on one-time products only. A subscription product always charges its own price, so each test price needs its own product.

### What happens if Leverprice misses a webhook?

Creem retries a failed delivery after 30 seconds, 5 minutes, 30 minutes and 6 hours, and stops after 24 hours ([Creem docs](https://docs.creem.io/code/webhooks)). On the checkout side, `getPrice()` returns your fallback price within 500 ms, so a buyer always sees your normal price if Leverprice is down.

### How do Creem's fees affect the result?

With the profit goal, Leverprice compares prices after the provider fee and your unit cost, both set on the product through the API or an AI agent over MCP. As of November 2026, Creem charges 3.9% + 40¢ per transaction ([Creem pricing](https://www.creem.io/pricing)); the [merchant of record comparison](https://leverprice.com/blog/merchant-of-record-comparison) sets that next to the other providers.

### How long does a price test on Creem take?

It depends mostly on sales volume. In our simulations of the production engine, a price that earned 10% more per visitor took a median of 14 days to find at 1,000 sales a month and 113 days at 100 ([full table](https://leverprice.com/blog/how-long-should-a-price-test-run)).
