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

Multiple requests to checkoutURL #141

Open ainoske opened 1 week ago

ainoske commented 1 week ago

What area is the issue related to?

Checkout Sheet Kit

What version of the package are you using?

3.0.1

Reproducible sample code

val cartCreateResponse =
        storefront.mutationAsSingle(
            CartCreateMutation(
                CartInput(
                    buyerIdentity =
                        Optional.presentIfNotNull(
                            CartBuyerIdentityInput(
                                customerAccessToken =
                                    Optional.presentIfNotNull(
                                        customerAccessToken.accessToken
                                    ),
                                countryCode = Optional.presentIfNotNull(countryCode)
                            )
                        ),
                    lines =
                        Optional.presentIfNotNull(
                            listOf(
                                CartLineInput(
                                    quantity = Optional.presentIfNotNull(1),
                                    merchandiseId = productVariantId,
                                    sellingPlanId = Optional.presentIfNotNull(sellingPlanId),
                                )
                            )
                        ),
                    attributes =
                        Optional.presentIfNotNull(
                            listOf(
                                AttributeInput(
                                    key = "id",
                                    value = id.raw
                                )
                            )
                        ),
                    note = Optional.presentIfNotNull("")
                ),
                countryCode = countryCode,
                languageCode = languageCode,
            )
        )

ShopifyCheckoutSheetKit.present(
            checkoutUrl = result.checkoutUrl.toString(),
            context = context as ComponentActivity,
            checkoutEventProcessor =
                object : DefaultCheckoutEventProcessor(context) {
                    override fun onCheckoutCanceled() {}

                    override fun onCheckoutCompleted(checkoutCompletedEvent: CheckoutCompletedEvent) { }

                    override fun onCheckoutFailed(error: CheckoutException) {
                        checkoutError = error.errorDescription
                    }

                    override fun onWebPixelEvent(event: PixelEvent) {
                        if (event is StandardPixelEvent) {
                            when (event.name) {
                                "checkout_shipping_info_submitted" -> { }

                                "checkout_completed" -> { }

                                "payment_info_submitted" -> { }
                            }
                        }
                    }
                }
        )

Steps to Reproduce

  1. Create a cart for the target product using CartCreateMutationAPI for pre-payment.
  2. Load it with CheckoutSheetKit using the checkoutURL obtained from the response.

Expected Behavior

The checkout screen must be displayed correctly and payment can be made.

Actual Behavior

HTTP429 error after such behavior that the Checkout screen is generated repeatedly.

Screenshots/Videos/Log output

https://github.com/user-attachments/assets/08b42bfb-65d4-44eb-bce2-683f2639a507

Storefront domain

no response

kiftio commented 1 week ago

Hi, I'd thought this may be related to the error recovery setup, but when I test via our MobileBuyIntegration sample app (with the server always returning 429) all seems OK there. The initial view attempts to recover from the error in a fallback view. But the fallback does not attempt to recover again.

Also, this should all happen within the same (un-dismissed) dialog instance. In the video, it looks like the dialog is being dismissed and re-opened.

Could I ask for a few more details:

Thanks