1. Create Customer
- Next.js (App Router)
- cURL
2. Create Subscription
Take theid from the previous response (e.g., cus_12345) and use it to create a subscription.
- Next.js (App Router)
- cURL
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Integration using standard HTTP requests
// app/api/customers/route.ts
import { NextResponse } from "next/server";
export async function POST(request: Request) {
const body = await request.json();
const res = await fetch(
"https://giant-goldfish-922.convex.site/api/customers",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CREDIBILL_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
return NextResponse.json(await res.json(), { status: res.status });
}
curl -X POST https://giant-goldfish-922.convex.site/api/customers \
-H "Authorization: Bearer cb_test_..." \
-H "Content-Type: application/json" \
-d '{"email":"customer@example.com","name":"Startup Inc","paymentMethod":"mobile_money_mtn"}'
{
"id": "cus_12345",
"email": "customer@example.com",
"name": "Startup Inc",
"created": 1678900000
}
id from the previous response (e.g., cus_12345) and use it to create a subscription.
// app/api/subscriptions/route.ts
import { NextResponse } from "next/server";
export async function POST(request: Request) {
const body = await request.json();
const res = await fetch(
"https://giant-goldfish-922.convex.site/api/subscriptions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CREDIBILL_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
}
);
return NextResponse.json(await res.json(), { status: res.status });
}
curl -X POST https://giant-goldfish-922.convex.site/api/subscriptions \
-H "Authorization: Bearer cb_test_..." \
-H "Content-Type: application/json" \
-d '{"customerId":"cus_12345","planId":"plan_starter_monthly"}'
{
"id": "sub_67890",
"status": "active",
"current_period_end": 1681578400,
"customer": "cus_12345",
"plan": {
"id": "plan_starter_monthly",
"amount": 2900
}
}