#Fire

1 messages · Page 1 of 1 (latest)

rigid cedarBOT
unborn ruin
median python
#

usually my products are saved on my database, and only use stripe to issue the payments

unborn ruin
#

That's typically how it works, yes, you would define your product catalog using Products and Prices in Stripe.

#

If you don't want to do that you can specify ad-hoc Product and Price data for each payment.

median python
#

How I want it to work is:

Create an intent with an amount of 200$ for example, and have stripe automatically calculate the taxes depending on the user's country

#
exports.createStripePayment = async (req, res) => {
  try {
    const {
      items,
      email,
      name,
      phoneNumber,
      country,
      city,
      line1,
      line2,
      state,
      postal_code,
    } = req.body;
    // const amount = await calculateOrderAmount(items);
    const amount = 200;
    const intent = await stripe.paymentIntents.create({
      amount: amount,
      metadata: { items: JSON.stringify(items) },
      currency: "usd",
      automatic_payment_methods: {
        enabled: true,
      },
      receipt_email: email,
      shipping: {
        name: name,
        phone: phoneNumber,
        address: {
          country: country,
          city: city,
          line1: line1,
          line2: line2,
          state: state,
          postal_code: postal_code,
        },
      },
    });

    return Response.success(res, {
      clientSecret: intent.client_secret,
    });
  } catch (err) {
    console.log(err);
    return Response.serverError(res, err.message);
  }
};
#

this is my function if it helps, the amount is usually calculated depending on the items but for now im just testing

unborn ruin
#

Stripe Tax is not compatible with creating Payment Intents directly.

#

Payment Intents are low-level objects that take a single amount, they are not tax-aware.

#

In order to use Stripe Tax you need to use something like Invoices or Checkout.

median python
#

So I will need to duplicate my database of products and update it on both my dashboard and database in order to implement the automated taxes?

unborn ruin