mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-06 09:59:00 +02:00
🐛 Fix licensing checkout and webhook (#1731)
This commit is contained in:
parent
518b66aa9a
commit
3ae7f7e021
7 changed files with 30 additions and 31 deletions
|
@ -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.");
|
||||
|
|
|
@ -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<
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue