Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In stripe checkout page display Country or region fields how to remove it

image

I am used stripe payment getaway for payment, In stripe checkout page display Country or region field and some country select then Postal code field appear both fields are required so how to remove this fields.

Here is my code:

checkout_session = stripe.checkout.Session.create(
line_items=[
    {
        "price_data": {
            "currency": "usd",
            "product_data": {
                "name": "order",
            },
            "unit_amount_decimal": 5 * 100,
        },
        "quantity": 1,
    },
],
customer_email="[email protected]",
mode="payment",
success_url=success_url,
cancel_url=cancel_url,
like image 780
Mitul Jaganiya Avatar asked Sep 18 '25 19:09

Mitul Jaganiya


2 Answers

Country is a field required by Checkout, and depending on the country selected, the postal code is automatically displayed as a requirement for specific countries. You cannot remove these fields in Checkout.

If you do not want to collect the country and postal code, you can choose to use Payment Element [0] to collect the payment method details instead. You can disable collection of those details by specifying never in the relevant fields [1][2].

[0] https://stripe.com/docs/payments/payment-element
[1] https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-customized_fields-fields-billingDetails-address-country
[2] https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-customized_fields-fields-billingDetails-address-postalCode

like image 182
makoto-stripe Avatar answered Sep 20 '25 10:09

makoto-stripe


Further expounding on makoto's answer as the docs did not fully explain, here is how you would do it in JS:

// Create and mount the Payment Element
var paymentElement = elements.create('payment', {
    fields: {
        billingDetails: {
            address: {
                country: 'never',
                postalCode: 'never'
            }
        }
    }
});

Be warned however: If you leave the zip code, removing only the country, the zip box will be ginormous.

like image 41
flashsplat Avatar answered Sep 20 '25 08:09

flashsplat