Update error handling and function calls in billing services
Minor modifications made to the billing service handlers to improve data interpretation and error processing. The 'getLineItemTypeById' function now uses 'item.variant' for more accurate line item type identification. Unnecessary 'Crypto' object instantiation has been removed in 'createHmac', while improved formatting applied to the error logging within the billing webhook.
This commit is contained in:
@@ -36,7 +36,7 @@ export const POST = enhanceRouteHandler(
|
||||
|
||||
return new Response('OK', { status: 200 });
|
||||
} catch (error) {
|
||||
logger.error(ctx, `Failed to process billing webhook`, error);
|
||||
logger.error({ ...ctx, error }, `Failed to process billing webhook`);
|
||||
|
||||
return new Response('Failed to process billing webhook', {
|
||||
status: 500,
|
||||
|
||||
@@ -345,7 +345,7 @@ export class LemonSqueezyWebhookHandlerService
|
||||
product_id: item.product,
|
||||
variant_id: item.variant,
|
||||
price_amount: item.priceAmount,
|
||||
type: getLineItemTypeById(this.config, item.id),
|
||||
type: getLineItemTypeById(this.config, item.variant),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ function bufferToHex(buffer: ArrayBuffer) {
|
||||
|
||||
export async function createHmac({ key, data }: { key: string; data: string }) {
|
||||
const encoder = new TextEncoder();
|
||||
const crypto = new Crypto();
|
||||
const encodedKey = encoder.encode(key);
|
||||
const encodedData = encoder.encode(data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user