Files
cfw-autumn/apps/sdk-test/sdk.ts
John Yeo e8366d22ea latest
2026-02-18 16:24:19 +00:00

24 lines
521 B
TypeScript

import { join } from "node:path";
import { config as dotenvConfig } from "dotenv";
dotenvConfig({ path: join(__dirname, ".env") });
import { Autumn } from "autumn-js";
const autumn = new Autumn({
secretKey: process.env.AUTUMN_SECRET_KEY,
});
const customer = await autumn.customers.getOrCreate({
customerId: "123",
});
console.log("Customer:", customer);
const attachResult = await autumn.billing.attach({
customerId: customer.id ?? "",
planId: "pro_plan",
});
console.log("Attach result:", attachResult);