Framework Integration & Sample App
Minimal Vanilla JS / Node.js backend integration examples, plus a real sample shop actually running against ReBate Pay.
There is currently no published
@rebatepay/node package (or any language's official package) on any registry. The Node.js example below uses native fetch and needs no ReBate Pay-specific install; if you're developing inside this repo, you can also use the internal TypeScript client below.Vanilla JS / fetch (works from any backend)
const BASE = process.env.REBATE_PAY_BASE_URL;
const KEY = process.env.REBATE_PAY_API_KEY;
async function rebatePay(method, path, body) {
const res = await fetch(`${BASE}/api${path}`, {
method,
headers: {
Authorization: `Bearer ${KEY}`,
"Content-Type": "application/json",
...(body ? { "Idempotency-Key": crypto.randomUUID() } : {}),
},
body: body ? JSON.stringify(body) : undefined,
});
const json = await res.json();
if (json.error) throw new Error(`${json.error.code}: ${json.error.message}`);
return json.data;
}
const link = await rebatePay("POST", "/PaymentLink", { name: "Order #1", priceId: "price_..." });Internal TypeScript client (source-only, not published)
This repo contains a real, complete TypeScript client (packages/rebatepay-sdk): automatic Idempotency-Keys, safe retries (only retries GETs or genuinely idempotent writes, never blindly retries an unknown payment), cursor paginate(), and verifyWebhookSignature(). It's source-only — not published as an npm package, so it's imported by relative path.
import { RebatePay, verifyWebhookSignature } from "../packages/rebatepay-sdk/src/index";
const client = new RebatePay({ apiKey: process.env.REBATE_PAY_API_KEY!, baseUrl: process.env.REBATE_PAY_BASE_URL! });
const link = await client.createPaymentLink({ name: "Order #1", priceId: "price_..." });
for await (const product of client.paginate((cursor) => client.listProducts({ startingAfter: cursor }))) {
console.log(product.id);
}
ReBate Pay Docs