How to restrict US State in the Striped Embedded Form?

47 views Asked by At

I'm using the Stripe Embedded Form. I want to enforce different shipping options/rates depending on which US State the customer has selected. I currently have a custom UI element in which the customer can select their state and this is saved to my backend. I'd like to pass this down to the Embedded Form but because it's an iFrame I can't do this with JS.

I know this is possible for countries using allowed_countries, but there seems to be no way of doing this for US States.

Here's my code for creating the checkout session:

const session = await stripe.checkout.sessions.create({
  ui_mode: 'embedded',
  line_items,
  mode: 'payment',
  automatic_tax: { enabled: true },
  shipping_address_collection: {
    allowed_countries: [country],
  },
  shipping_options: [...shipping_options],
  return_url: `${process.env.UI_DOMAIN}/order-confirmation?session_id={CHECKOUT_SESSION_ID}`,
  metadata: {
    ...productMetadata,
  },
});

Does anyone know how to achieve this via Embedded Form functionality? Maybe a hack?

Cheers!

0

There are 0 answers