Shopify / checkout-sheet-kit-android

Shopify’s Checkout Sheet Kit makes it simple to perform a checkout inside your Android app.
MIT License
12 stars 3 forks source link

Retain webview cache on cancel #69

Closed kiftio closed 8 months ago

kiftio commented 9 months ago

What are you trying to accomplish?

When you close the checkout sheet, the preloading cache is cleared. This has been raised a few times as a bug. The core of the issue is we don't not know when the users cart becomes invalid

We need to avoid this pitfall:

The assumption in this PR is, if the merchant calls preload once, they are taking responsibility to call it again when cart updates

Ideally we want the best of both worlds:


[!Note] The current implementation is a bit different to the swift one. We're not tracking if clients have called preload. We're instead updating the cache, so that if preload isn't called, there shouldn't be anything in the cache to retain. (We do always add something to the cache, but with a TTL of 0, so it'll be thrown away as stale before presenting).

Test scenarios:

  1. preloading enabled, preload() never called (add to cart, open checkout, close checkout, modify cart, open checkout)
  2. preloading enabled, preload() called on each cart modification
  3. preloading disabled
  4. onRenderProcessGone
  5. server error

Before you deploy

kiftio commented 8 months ago

Are we clearing the cache on error in this lib?

Yeah, we have a handleError function in CheckoutWebView that eventually either dismisses the dialog (which clears the cache), or just clears the cache if the dialog hasn't been displayed yet.