Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] EphemeralKeyProvider called 4 times #135

Open
kefahB opened this issue Aug 19, 2022 · 3 comments
Open

[android] EphemeralKeyProvider called 4 times #135

kefahB opened this issue Aug 19, 2022 · 3 comments

Comments

@kefahB
Copy link
Contributor

kefahB commented Aug 19, 2022

Hi @triniwiz @NathanWalker

Sorry for reporting 3 separated issues but I discover then as i go!

I've seen 4 call to get the Ephemeral key! the problem come from com.stripe.android.CustomerSession.initCustomerSession that accept a 3rd attribute to avoid sending other request when PaymentSession is initialized. see here

We can expose an attribute at the constructor as below but strangely enough setting shouldPrefetchCustomer to false this does prevent the prefetech call but doesn't resolve the problem !! I'll investigate that more, I yhink the problem come from the PaymentSession !

Also Application.android.contextis deprecated for Utils.android.getApplicationContext()

export class StripeStandardCustomerSession {
    constructor(shouldPrefetchEphemeralKey: boolean = false) {
        StripeStandardConfig.shared.initPaymentConfiguration();
        com.stripe.android.CustomerSession.initCustomerSession(StripeStandardCustomerSession.context, createKeyProvider(), shouldPrefetchEphemeralKey);
        this.native = com.stripe.android.CustomerSession.getInstance();
    }
    static get context() {
        return Utils.android.getApplicationContext();
    }
}
@triniwiz
Copy link
Owner

Thanks I'll check it out soon 😄

@kefahB kefahB mentioned this issue Sep 14, 2022
triniwiz pushed a commit that referenced this issue Sep 14, 2022
* Fixe payment result handler

* Fixe getting top view controller

* fixe android #135

Co-authored-by: Kefah BADER <[email protected]>
@kefahB
Copy link
Contributor Author

kefahB commented May 20, 2023

Hi @triniwiz

This issue still on android even with the latest change to add shouldPrefetchEphemeralKey = false to com.stripe.android.CustomerSession.initCustomerSession(StripeStandardCustomerSession.context, createKeyProvider(), shouldPrefetchEphemeralKey); with this change it make 3 calls instead of 4!! and now I did a quick look to the SDK and it seems that we can reduce the number to 2 calls by setShouldPrefetchCustomer(false) to this line.

Now why still did 2 call I don't know but it is most likely from the Stripe SDK! I did explain this in new issue at the repo of Stripe android SDK

The problem is with all those call isReadyToCharge most of the time it return false, we should return backward and try again!!

Now setShouldPrefetchCustomer(false) does not request the auto filling the card info, the user should click show payment method to select the card!

@kefahB
Copy link
Contributor Author

kefahB commented Jan 14, 2024

@triniwiz,

I was wondering if we can change StripeStandardCustomerSession to private and call it internally directly from here.

This issue come mainly from the 'createKeyProvider` because it is asynchrone, all the initialisations begin before the return of the ephemeral object .. but not only, we should ensure a synchronous calls on the initialisations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants