Skip to content

Commit

Permalink
Disable recovery for multipass urls
Browse files Browse the repository at this point in the history
  • Loading branch information
kiftio committed Oct 15, 2024
1 parent 684502b commit f18c2d7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.1.2 October 15 2024

- Prevent entering recovery mode for single-use multipass URLs.

## 3.1.1 October 2, 2024

- Ensure that cached WebView instances don't have existing parents before trying to add them to their container.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ your project:
#### Gradle

```groovy
implementation "com.shopify:checkout-sheet-kit:3.1.1"
implementation "com.shopify:checkout-sheet-kit:3.1.2"
```

#### Maven
Expand All @@ -33,7 +33,7 @@ implementation "com.shopify:checkout-sheet-kit:3.1.1"
<dependency>
<groupId>com.shopify</groupId>
<artifactId>checkout-sheet-kit</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def resolveEnvVarValue(name, defaultValue) {
return rawValue ? rawValue : defaultValue
}

def versionName = resolveEnvVarValue("CHECKOUT_SHEET_KIT_VERSION", "3.1.1")
def versionName = resolveEnvVarValue("CHECKOUT_SHEET_KIT_VERSION", "3.1.2")

ext {
app_compat_version = '1.6.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ internal class CheckoutDialog(

internal fun closeCheckoutDialogWithError(exception: CheckoutException) {
checkoutEventProcessor.onCheckoutFailed(exception)
if (ShopifyCheckoutSheetKit.configuration.errorRecovery.shouldRecoverFromError(exception)) {

val isOneTimeUseURL = this.checkoutUrl.contains("multipass")
if (!isOneTimeUseURL && ShopifyCheckoutSheetKit.configuration.errorRecovery.shouldRecoverFromError(exception)) {
attemptToRecoverFromError(exception)
} else {
dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ class CheckoutDialogTest {
verify(mockEventProcessor).onCheckoutFailed(any())
}

@Test
fun `does not call attemptToRecoverFromError if closeCheckoutDialogWithError is called when url contains multipass`() {
val mockEventProcessor = mock<DefaultCheckoutEventProcessor>()
ShopifyCheckoutSheetKit.present("https://shopify.com/a/b/c/multipass", activity, mockEventProcessor)

val checkoutDialog = ShadowDialog.getLatestDialog() as CheckoutDialog
assertThat(checkoutDialog.containsChildOfType(CheckoutWebView::class.java)).isTrue()

checkoutDialog.closeCheckoutDialogWithError(checkoutException(isRecoverable = true))
shadowOf(Looper.getMainLooper()).runToEndOfTasks()

// attemptToRecoverFromError creates a FallbackWebView and removes the CheckoutWebView
assertThat(checkoutDialog.containsChildOfType(FallbackWebView::class.java)).isFalse()
assertThat(checkoutDialog.containsChildOfType(CheckoutWebView::class.java)).isFalse()
verify(mockEventProcessor, never()).onCheckoutCanceled()
verify(mockEventProcessor).onCheckoutFailed(any())
}

@Test
fun `can disable fallback behaviour via shouldRecoverFromError`() {
val mockEventProcessor = mock<DefaultCheckoutEventProcessor>()
Expand Down

0 comments on commit f18c2d7

Please sign in to comment.