Creem Integration
Credit partners for Creem payments and subscription renewals, and reverse the commission when a payment is refunded or charged back.
Overview
- One-time purchases and subscriptions, renewals included
- Partner code through Creem payment links, checkout metadata, or the partner's discount code
- Refunds reverse the commission in proportion; chargebacks reverse it in full
- Product-specific and partner-specific commission rates
- Live and test mode: a
creem_test_key connects your test store
Step 1: Connect Creem
- In Creem, open Developers → API keys, switch Full access off and create a key with two permissions:
webhooks:readandwebhooks:write. With these the key can't change your products, customers or orders. - In Refgrow, open Integration, choose Creem, paste the key and click Connect.
Refgrow creates a webhook endpoint in your Creem store for checkout.completed, subscription.paid, refund.created, dispute.created and subscription.canceled, and keeps its signing secret. Nothing else in your store changes. Connecting again later reuses the same endpoint. Each subscription.paid event carries the transaction that was just paid, so renewals are credited on what was charged without any other permission.
Disconnecting Creem on the Integration page, or deleting the project, deletes Refgrow's webhook from your Creem store. If Creem can't be reached at that moment, Refgrow tells you which webhook to delete by hand.
Prefer to create the endpoint yourself? Point it at https://refgrow.com/webhook/creem/YOUR_PROJECT_ID with the five events above, then use "Paste its signing secret instead" on the Integration page.
Step 2: Get the partner code to the checkout
Creem hosts checkout on its own domain, so the partner code has to travel with the buyer. Creem copies checkout metadata onto the subscription, so once the code is on the first payment, every renewal is credited to the same partner.
Payment links
Add the Refgrow script to the pages that link to Creem. It adds the partner's code to every creem.io payment link as metadata[referral_code], including links that appear after the page loads.
<script src="https://scripts.refgrowcdn.com/latest.js" data-project-id="YOUR_PROJECT_ID" async defer></script>
<a href="https://www.creem.io/payment/prod_xxxxx">Buy</a>
<!-- becomes .../payment/prod_xxxxx?metadata[referral_code]=PARTNER_CODE for a referred visitor -->Links on your own checkout domain can opt in with the class refgrow-creem-link.
Checkout sessions from your server
Read the code in the browser and send it with your checkout request:
// Browser
const referralCode = window.Refgrow?.getReferralCode?.() ?? null;
await fetch("/api/checkout", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ referralCode }),
});// Server (Creem TypeScript SDK)
const { referralCode } = await request.json();
const checkout = await creem.checkouts.create({
productId: "prod_xxxxx",
...(referralCode && { metadata: { referral_code: referralCode } }),
});
// send the customer to checkout.checkoutUrlThe script adds the code when a link is clicked, not to a URL your code opens with window.open or window.location. Add metadata[referral_code] to those URLs yourself.
Partner discount codes
A sale that used a partner's discount code is credited to that partner, with or without metadata. Create the discount in Creem, then give the same code to the partner in Refgrow. Partners who link straight to Creem, skipping your site, need one: the script never runs for their visitors.
Matching a buyer by email
If people sign up on your site before they pay, report the signup while the partner's code is still in their browser:
// after a successful signup, with the email they signed up with
Refgrow(0, 'signup', 'user@example.com');Refgrow then records the signup under the partner. A later Creem payment with the same email is credited to that partner even when the checkout carries no metadata. Refgrow.identify() and data-project-email feed revenue analytics only; they don't link a buyer to a partner.
How amounts are counted
Percentage commissions use what the customer paid after discounts, minus the tax Creem collected. A partial refund reduces the commission by the same share of the payment; a full refund or a chargeback reverses it. A cancelled subscription keeps the commission already earned and simply stops renewing.
Creem sends no event when you win a dispute, so a commission reversed on dispute.created stays reversed. To give it back, open the partner in Affiliates and use Add a sale manually.
Testing
- Connect a
creem_test_key from Creem's test mode. - Open your site with
?ref=PARTNER_CODEand click a test payment link. - Pay with Creem's test card. The sale appears under the partner within seconds.
- The Integration page shows every webhook Refgrow received and what it did with it.
- Refund the payment in Creem and check that the commission is reversed.
Use a real test payment, not Send test event in Creem: test events carry no metadata, so they can't be credited to a partner.
Troubleshooting
- "Creem rejected the API key": copy the full key again, and use a test key only with test mode.
- "Missing permissions": the key needs webhooks:read and webhooks:write.
- Sales arrive but no partner is credited: check that the payment link carries
metadata[referral_code]for a referred visitor, or that your checkout passes it. Creem drops the code onl.creem.ioshort links and storefront pages, so link to the payment link itself. - Webhooks fail their signature check: each Creem webhook has its own signing secret. If you re-created Refgrow's webhook by hand, or added a second webhook pointing at Refgrow, deliveries signed with the other secret fail. Keep one webhook for Refgrow, then connect again or paste that webhook's secret.