🐛 Fix licensing checkout and webhook (#1731)

This commit is contained in:
Luke Vella 2025-05-26 19:07:17 +01:00 committed by GitHub
parent 518b66aa9a
commit 3ae7f7e021
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 31 deletions

View file

@ -10,7 +10,7 @@ export class LicensingClient {
authToken?: string;
constructor({
apiUrl = "https://licensing.rallly.co",
apiUrl = "https://licensing.rallly.co/api/licensing/v1",
authToken,
}: {
apiUrl?: string;
@ -24,7 +24,7 @@ export class LicensingClient {
throw new Error("Licensing API auth token is not configured.");
}
const res = await fetch(`${this.apiUrl}/api/v1/licenses`, {
const res = await fetch(`${this.apiUrl}/licenses`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@ -39,16 +39,13 @@ export class LicensingClient {
return createLicenseResponseSchema.parse(await res.json());
}
async validateLicenseKey(input: ValidateLicenseInputKeySchema) {
const res = await fetch(
`${this.apiUrl}/api/v1/licenses/actions/validate-key`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(input),
const res = await fetch(`${this.apiUrl}/licenses/actions/validate-key`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
);
body: JSON.stringify(input),
});
if (!res.ok) {
throw new Error("Failed to validate license key.");

View file

@ -31,12 +31,11 @@ export type ApiResponse<T> = {
export const createLicenseInputSchema = z.object({
type: licenseTypeSchema,
seats: z.number().optional(),
expiresAt: z.date().optional(),
seats: z.coerce.number().optional(),
expiresAt: z.coerce.date().optional(),
licenseeEmail: z.string().optional(),
licenseeName: z.string().optional(),
version: z.number().optional(),
stripeCustomerId: z.string().optional(),
version: z.coerce.number().optional(),
});
export type CreateLicenseInput = z.infer<typeof createLicenseInputSchema>;
@ -80,7 +79,8 @@ export type ValidateLicenseKeyResponse = z.infer<
export const licenseCheckoutMetadataSchema = z.object({
licenseType: licenseTypeSchema,
seats: z.number(),
version: z.coerce.number(),
seats: z.coerce.number(),
});
export type LicenseCheckoutMetadata = z.infer<