Breaking fix: line_items shape now consistent across the SDK and API
Breaking fix: line_items shape now consistent across the SDK and API
Version: 1.0.105
We've resolved a spec drift in Calmony Pay where the SDK's line_items type did not match the shape required by the POST /v1/checkout/sessions REST endpoint. If you use the SDK to create checkout sessions, you will need to update your line_items usage.
What was the problem?
The SDK's CreateCheckoutSessionParams type defined line_items items with a flat structure:
// ❌ Old (incorrect) SDK shape
{
price_id?: string;
amount?: number;
currency?: string;
quantity?: number;
description?: string;
}
At the same time, the REST API (POST /v1/checkout/sessions) required a Stripe-compatible nested structure:
// ✅ Required API shape
{
price_data: {
currency: string;
unit_amount: number;
product_data: {
name: string; // required
description?: string; // optional
};
};
quantity: number;
}
Because the SDK was not wrapping fields in price_data / product_data, every line_items entry sent to the API failed validation. Checkout sessions could not be created through the SDK.
What changed?
The SDK's CreateCheckoutSessionParams.line_items type has been updated to require the Stripe-style nested shape. The SDK will now serialise line_items correctly when calling the REST API.
The two affected files are:
src/lib/calmony-pay/client.ts— SDK type definition and request serialisationsrc/app/api/v1/checkout/sessions/route.ts— REST API validation schema
Migrating your code
Update any call site that passes line_items to checkout.sessions.create().
Before (broken)
await pay.checkout.sessions.create({
line_items: [
{
amount: 2500,
currency: 'gbp',
description: 'Pro Plan',
quantity: 1,
},
],
});
After (correct)
await pay.checkout.sessions.create({
line_items: [
{
price_data: {
currency: 'gbp',
unit_amount: 2500, // in minor units, e.g. pence for GBP
product_data: {
name: 'Pro Plan', // required
description: 'Monthly subscription', // optional
},
},
quantity: 1,
},
],
});
Key field reference
| Field | Type | Required | Notes |
|---|---|---|---|
price_data | object | ✅ | Wrapper for pricing information |
price_data.currency | string | ✅ | ISO 4217 currency code, e.g. gbp |
price_data.unit_amount | number | ✅ | Amount in minor units (e.g. pence) |
price_data.product_data | object | ✅ | Wrapper for product information |
price_data.product_data.name | string | ✅ | Display name for the line item |
price_data.product_data.description | string | ❌ | Optional description |
quantity | number | ✅ | Number of units |
Why the nested shape?
Calmony Pay's API is designed to be Stripe-compatible. The nested price_data / product_data shape mirrors the Stripe Checkout Sessions API, making it straightforward to migrate between Stripe and Calmony Pay, and to reuse existing Stripe integration code with minimal changes.