BIS Tech
BIS Tech

Reputation: 19444

Is it possible to set by default country to stripe payment sheet?

I want to set by default country as UAE. is it possible to set it? and also is it possible to set it server-side?

All the time it's set United State. But this problem is only on Android and Ios SDK. It's automatically set UAE on web.

check this country and religion section in this screenshot

Upvotes: 4

Views: 4005

Answers (5)

BIS Tech
BIS Tech

Reputation: 19444

To set the country in the Stripe Payment Sheet using the Flutter SDK, you have two options:

1. Set the Country Code

You can specify the country code directly. Note that for Dubai, the country code 'UAE' might not work as expected. Instead, use 'AE':

billingDetails: BillingDetails(
  address: Address(
    country: 'AE', 
    city: 'Dubai', 
    line1: '', 
    line2: '', 
    postalCode: '', 
    state: ''
  )
),

2. Completely Remove Country Selection

You can also configure the billing details to never prompt for a country:

billingDetailsCollectionConfiguration: BillingDetailsCollectionConfiguration(
  address: AddressCollectionMode.never
),

This should help you set the country correctly or remove the country selection in the Stripe Payment Sheet.

Upvotes: 0

Sayan Dey
Sayan Dey

Reputation: 472

In React Native CardForm

    If want to change the country code then
    defaultValues={{countryCode:'IN'}}

OR,

<CardForm
  defaultValues={{countryCode:'none'}}
    onFormComplete={cardDetails => {
      console.log('card details', cardDetails);
      setCard(cardDetails);
    }}
    
    postalCodeEnabled={true}
    placeholder={{
      number: '4242 4242 4242 4242',
    }}
    cardStyle={{
      backgroundColor: '#000001',
      textColor: '#f2f2f2f2',
      borderRadius: 8,
      borderWidth: 1,
      textErrorColor: 'red',
      placeholderColor: 'grey',
      borderColor: '#ffffff',
    }}
    autofocus={false}
    style={{
      width: windowWidth-8,
      height: windowHeight / 2,
      alignItems: 'center',
      marginHorizontal: 4,


    }}
  />

Upvotes: 1

rayhk6
rayhk6

Reputation: 11

For React Native, please provide the defaultBillingDetails when initPaymentSheet

You can refer below example

  const {error} = await initPaymentSheet(  
   {
     defaultBillingDetails: {
       address: {
        country: 'HK',
       },
     }
   }
  );

Upvotes: 1

Livin
Livin

Reputation: 326

Follow this: https://github.com/stripe/stripe-android/issues/4845 Increase your stripe lib version into

Gradle (implementation 'com.stripe:stripe-android:20.2.1')

Upvotes: 0

mohsen
mohsen

Reputation: 5078

Specify default values for billing details collected in the payment sheet by setting defaultBillingDetails. PaymentSheet pre-populates its fields with the values provided.

for iOS Swift

var configuration = PaymentSheet.Configuration()
configuration.defaultBillingDetails.address.country = "US"
configuration.defaultBillingDetails.email = "[email protected]"

for Android Kotlin:

var configuration = PaymentSheet.Configuration(...)
configuration.defaultBillingDetails.address.country = "US"
configuration.defaultBillingDetails.email = "[email protected]"

Upvotes: 4

Related Questions