mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-15 20:13:50 +00:00
feat(#29): Handle upserting new fields for products and prices
This commit is contained in:
@@ -31,8 +31,11 @@ const upsertProductRecord = async (product: stripe.Product) => {
|
|||||||
active: product.active,
|
active: product.active,
|
||||||
name: product.name,
|
name: product.name,
|
||||||
description: product.description ?? null,
|
description: product.description ?? null,
|
||||||
image: product.images?.[0] ?? null,
|
features: product.marketing_features.map(({ name }) => name || '').filter((name) => !!name),
|
||||||
metadata: product.metadata
|
images: product.images ?? null,
|
||||||
|
metadata: product.metadata,
|
||||||
|
created: new Date(product.created * 1000).toISOString(),
|
||||||
|
updated: new Date(product.updated * 1000).toISOString()
|
||||||
};
|
};
|
||||||
|
|
||||||
const { error: upsertError } = await supabaseAdmin.from('products').upsert([productData]);
|
const { error: upsertError } = await supabaseAdmin.from('products').upsert([productData]);
|
||||||
@@ -46,6 +49,8 @@ const upsertPriceRecord = async (price: stripe.Price, retryCount = 0, maxRetries
|
|||||||
product_id: typeof price.product === 'string' ? price.product : '',
|
product_id: typeof price.product === 'string' ? price.product : '',
|
||||||
active: price.active,
|
active: price.active,
|
||||||
currency: price.currency,
|
currency: price.currency,
|
||||||
|
description: price.nickname ?? null,
|
||||||
|
metadata: price.metadata,
|
||||||
type: price.type,
|
type: price.type,
|
||||||
unit_amount: price.unit_amount ?? null,
|
unit_amount: price.unit_amount ?? null,
|
||||||
interval: price.recurring?.interval ?? null,
|
interval: price.recurring?.interval ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user