Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-07-12 13:32:05 +00:00
parent 75bc5f1140
commit b1f5efcaad
+10 -15
View File
@@ -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",