Allow restricted keys in Stripe line item IDs

This commit is contained in:
gbuomprisco
2024-10-02 22:16:23 +02:00
parent 0c7c2e66f7
commit b912e6376b

View File

@@ -15,11 +15,17 @@ export const StripeServerEnvSchema = z
}) })
.refine( .refine(
(schema) => { (schema) => {
return schema.secretKey.startsWith('sk_'); const key = schema.secretKey;
const secretKeyPrefix = 'sk_';
const restrictKeyPrefix = 'rk_';
return (
key.startsWith(secretKeyPrefix) || key.startsWith(restrictKeyPrefix)
);
}, },
{ {
path: ['STRIPE_SECRET_KEY'], path: ['STRIPE_SECRET_KEY'],
message: `Stripe secret key must start with 'sk_'`, message: `Stripe secret key must start with 'sk_' or 'rk_'`,
}, },
) )
.refine( .refine(