android-checkout icon indicating copy to clipboard operation
android-checkout copied to clipboard

Possible purchase abort due to activity recreation

Open rpattabi opened this issue 4 years ago • 1 comments

During the purchase, there are payment methods for which the user has to open another app for payment confirmation. As we know when opening another app, android may decide to kill the activity (or app?). This means checkout object (created through Checkout.forActivity()) which is tied to the lifecycle of the activity will also be killed. This will result in the purchase to be aborted by Google Play even though user just approved the payment.

I presume, this will be the case with Checkout.forFragment() as well. @serso Should we rely on Checkout.forApplication() to avoid such purchase aborts? Also not sure if checkout start and stop be based on activity lifecycle. I'm also not sure if keeping checkout in start state throughout the application lifecycle as it could be wasteful.

rpattabi avatar Jun 26 '20 11:06 rpattabi

Checkout.forApplication() cannot be used to start purchase flow. So solution to this problem is to use androidx activity which provides a way to ensure activity result reaches the recreated activity. But then checkout state (mFlows) is gone since instance is relevant only for the lifetime to the activity.

rpattabi avatar Jul 08 '20 06:07 rpattabi