Skip to content

Add check if plugin setup is completed #11549

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

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.woocommerce.android.ui.woopos
import com.woocommerce.android.tools.SelectedSite
import com.woocommerce.android.ui.payments.GetActivePaymentsPlugin
import com.woocommerce.android.util.IsWindowClassExpandedAndBigger
import org.wordpress.android.fluxc.model.payments.inperson.WCPaymentAccountResult
import org.wordpress.android.fluxc.store.WCInPersonPaymentsStore
import org.wordpress.android.fluxc.store.WCInPersonPaymentsStore.InPersonPaymentsPluginType.WOOCOMMERCE_PAYMENTS
import javax.inject.Inject
Expand Down Expand Up @@ -33,7 +34,11 @@ class IsWooPosEnabled @Inject constructor(
countryCode.lowercase() == "us" &&
ippPlugin == WOOCOMMERCE_PAYMENTS &&
paymentAccount.storeCurrencies.default.lowercase() == "usd" &&
isWindowSizeExpandedAndBigger()
isWindowSizeExpandedAndBigger() &&
isPluginSetupCompleted(paymentAccount)
).also { cachedResult = it }
}

private fun isPluginSetupCompleted(paymentAccount: WCPaymentAccountResult): Boolean =
paymentAccount.status == WCPaymentAccountResult.WCPaymentAccountStatus.COMPLETE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ I'll follow up on the P2, but just a heads-up that this doesn't handle the scenario when there are pending but skippable requirements on the Stripe's account.

Copy link
Contributor Author

@samiuelson samiuelson May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the decision (p91TBi-bje-p2), I've loosened the status requirement to ENABLED. I don't have a full understanding of all the status types though, so I'd appreciate it if you could confirm (@malinajirka or @kidinov) if the condition matches the following requirement:

- ...
- Onboarding is Completed (optional requirements should be considered as valid).
- ...

Copy link
Contributor

@kidinov kidinov May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malinajirka @samiuelson 👋

As for M1, it's planned to implement a "happy path" only, shall we assume that only the completed state is exacted for now? Handling optional requirements is done on å full-screen fragments, so it may bring some complexity to the initial implementation of connection/payment flows. In any case I added a ticket to handle that - we just need to decide priorities - for M1 or latter.

#11612

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing users to enter the POS with pending requirements but crashing (implementing only the happy path) sounds like a good approach for now. I've added high priority label to the issue just to make sure we don't leave the code in the crashing state.

I've loosened the status requirement to ENABLED. I don't have a full understanding of all the status types though,

I believe this should be enough - we'll need to eventually test all the flows though. We had a pretty detailed test plan for the onboarding project so we should be able to look it up and re-use it.

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ class IsWooPosEnabledTest : BaseUnitTest() {
assertFalse(sut())
}

@Test
fun `given woo payments setup not completed, then return false`() = testBlocking {
val result = buildPaymentAccountResult(status = WCPaymentAccountResult.WCPaymentAccountStatus.NO_ACCOUNT)
whenever(ippStore.loadAccount(any(), any())).thenReturn(result)
assertFalse(sut())
}

@Test
fun `given big enough screen, woo payments enabled, USD currency and store in the US, then return true`() = testBlocking {
val result = buildPaymentAccountResult(defaultCurrency = "USD", countryCode = "US", status = COMPLETE)
Expand Down
Loading