capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
https://capacitor-community-stripe.netlify.app/
MIT License
192 stars 77 forks source link

Dinamic Stripe Key for Android #361

Open lsantaniello opened 3 months ago

lsantaniello commented 3 months ago

I read that it is necessary to define the stripe key in the android/app/src/main/res/values/strings.xml file.

In my app I invoke the backend to retrieve the key. I have multiple payment accounts and the account depends on some conditions.

Manifest.xml

<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />
        <meta-data android:name="com.getcapacitor.community.stripe.enable_google_pay" android:value="@bool/enable_google_pay"/>
        <meta-data android:name="com.getcapacitor.community.stripe.publishable_key" android:value="@string/publishable_key"/>
        <meta-data android:name="com.getcapacitor.community.stripe.country_code" android:value="@string/country_code"/>
        <meta-data android:name="com.getcapacitor.community.stripe.merchant_display_name" android:value="@string/merchant_display_name"/>
        <meta-data android:name="com.getcapacitor.community.stripe.google_pay_is_testing" android:value="@bool/google_pay_is_testing"/>
        <meta-data android:name="com.getcapacitor.community.stripe.google_pay_existing_payment_method_required" android:value="@bool/google_pay_existing_payment_method_required"/>

android/app/src/main/res/values/strings.xml

    <string name="publishable_key">pk_test_YssveZBA1kucfaTfZbeDwauN</string>
    <bool name="enable_google_pay">true</bool>
    <string name="country_code">US</string>
    <string name="merchant_display_name">Widget Store</string>
    <bool name="google_pay_is_testing">true</bool>
    <bool name="google_pay_existing_payment_method_required">false</bool>

How can I avoid setting the value statically in the string.xml file and set it dynamically at runtime?

ipehimanshu commented 2 months ago

Hello

i have also same question

we have multi location application where every location should have separate stripe account

so how to use gpay for that case ?

does any one help me to solve this case ?

Thank you

rdlabo commented 1 month ago

Unfortunately, it is not possible to dynamically set up Google Pay on WevView because it is initialized earlier than WebView.

I have looked and could not find a mechanism for such a replacement, so I would be happy to ask the question at https://github.com/stripe/stripe-android/issues. This plugin is just a wrapper and cannot implement features that are not in the original.

Thanks.