Fix: currency now defaults to GBP on payment intent creation
Fix: currency now defaults to GBP on payment intent creation
Release: v1.0.111
What changed
As of v1.0.111, the currency field is optional when creating a payment intent via POST /v1/payment_intents. When omitted, it defaults to "gbp" — matching the Calmony Pay REST API Contract and the behaviour described in the TypeScript SDK's CreatePaymentIntentParams interface.
Background
The Calmony Pay REST API Contract specifies currency as an optional field that defaults to GBP, in keeping with Stripe API compatibility. The SDK's CreatePaymentIntentParams type correctly reflected this:
interface CreatePaymentIntentParams {
amount: number;
currency?: "gbp" | "GBP"; // optional, defaults to gbp
// ...
}
However, the underlying REST API route defined currency as a required field in its Zod validation schema. Any request that omitted currency received a 400 Bad Request validation error instead of proceeding with the GBP default.
The fix
The createPaymentIntentSchema in src/app/api/v1/payment_intents/route.ts has been updated so currency is optional and defaults to "gbp":
// Before
currency: z.literal("gbp"),
// After
currency: z.enum(["gbp", "GBP"]).optional().default("gbp"),
What this means for you
- Existing requests that include
currencyare unaffected. - Requests that omit
currencynow succeed and default togbp, rather than returning a400error. - This aligns the REST API, the TypeScript SDK, and the pinned API contract.
Example
The following request body is now valid without specifying currency:
{
"amount": 2500
}
The created payment intent will have currency: "gbp" applied automatically.