Såg till och testade live-utgåvan
X-Lovable-Edit-ID: edt-d4addf3d-6ec1-4ad7-8720-479c03c6ec92 Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com>
This commit is contained in:
@@ -144,19 +144,6 @@ Deno.serve(async (req) => {
|
|||||||
// Monthly amount in öre = kg × 4 veckor × 325 kr
|
// Monthly amount in öre = kg × 4 veckor × 325 kr
|
||||||
const monthlyAmountOre = Math.round(b.kg_per_week * WEEKS_PER_MONTH * PRICE_PER_KG_ORE);
|
const monthlyAmountOre = Math.round(b.kg_per_week * WEEKS_PER_MONTH * PRICE_PER_KG_ORE);
|
||||||
|
|
||||||
// Resolve product via existing price lookup_key
|
|
||||||
const prices = await stripe.prices.list({ lookup_keys: ["kakabonnemang_dynamic"], limit: 1 });
|
|
||||||
if (!prices.data.length) {
|
|
||||||
return new Response(JSON.stringify({ error: "Produkt inte konfigurerad" }), {
|
|
||||||
status: 500,
|
|
||||||
headers: { ...corsHeaders, "Content-Type": "application/json" },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const productId =
|
|
||||||
typeof prices.data[0].product === "string"
|
|
||||||
? prices.data[0].product
|
|
||||||
: prices.data[0].product.id;
|
|
||||||
|
|
||||||
// Find or create customer
|
// Find or create customer
|
||||||
const existing = await stripe.customers.list({ email: b.email, limit: 1 });
|
const existing = await stripe.customers.list({ email: b.email, limit: 1 });
|
||||||
const customer =
|
const customer =
|
||||||
@@ -193,7 +180,11 @@ Deno.serve(async (req) => {
|
|||||||
quantity: 1,
|
quantity: 1,
|
||||||
price_data: {
|
price_data: {
|
||||||
currency: "sek",
|
currency: "sek",
|
||||||
product: productId,
|
product_data: {
|
||||||
|
name: "Kakabonnemang",
|
||||||
|
description: "Månatligt kakabonnemang för företag inom Storstockholm.",
|
||||||
|
tax_code: "txcd_40060003",
|
||||||
|
},
|
||||||
recurring: { interval: "month" },
|
recurring: { interval: "month" },
|
||||||
unit_amount: monthlyAmountOre,
|
unit_amount: monthlyAmountOre,
|
||||||
} as any,
|
} as any,
|
||||||
@@ -242,7 +233,11 @@ Deno.serve(async (req) => {
|
|||||||
{
|
{
|
||||||
price_data: {
|
price_data: {
|
||||||
currency: "sek",
|
currency: "sek",
|
||||||
product: productId,
|
product_data: {
|
||||||
|
name: "Kakabonnemang",
|
||||||
|
description: "Månatligt kakabonnemang för företag inom Storstockholm.",
|
||||||
|
tax_code: "txcd_40060003",
|
||||||
|
},
|
||||||
recurring: { interval: "month" },
|
recurring: { interval: "month" },
|
||||||
unit_amount: monthlyAmountOre,
|
unit_amount: monthlyAmountOre,
|
||||||
tax_behavior: "exclusive",
|
tax_behavior: "exclusive",
|
||||||
|
|||||||
Reference in New Issue
Block a user