#mboras_api

1 messages ¡ Page 1 of 1 (latest)

dull pantherBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1365304703436718122

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

charred ether
#

Hi, let me help you with this.

teal stone
#

to give you full context

#

const { data: user } = await supabaseAdmin.auth.admin.getUserById(user_id);
console.log({ user });
const customer = await stripe.customers.retrieve(
user?.user?.user_metadata?.stripe_customer_id || ""
);
console.log({ customer });
const isEuropeanUnionUser = EU_COUNTRIES.includes(country || "");
console.log({ isEuropeanUnionUser });

const lineItems = [
  {
    quantity: 1,
    price_data: data,
    // Only include tax_rates for non-EU users
    ...(isEuropeanUnionUser
      ? {}
      : { tax_rates: [process.env.STRIPE_CROATIA_TAX_RATE || ""] }),
  },
];
console.log(JSON.stringify(lineItems, null, 2));

const session = await stripe.checkout.sessions.create({
  line_items: lineItems,
  success_url: `${currentDomain}/payment-success`,
  cancel_url: `${currentDomain}/payment-failure`,
  mode: "payment",
  metadata,
  allow_promotion_codes: true,
  currency: "eur",
  customer: customer.id,
  customer_update: {
    name: "auto" as const,
    address: "never" as const,
  },
  billing_address_collection: "auto",
  automatic_tax: {
    enabled: isEuropeanUnionUser,
  },
  invoice_creation: {
    enabled: true,
  },
});
#

I need to have automatic tax for EU countries

#

and for non eu countries I need to lock my tax (Croatia)

#

this code above works fine, but users right now can change country in checkout

charred ether
#

Unfortunately, it seems like it's not possible to pre-fill country on Stripe Checkout, for example from the Customer's info. Customers will still be able to change the billing country.