Skip to content
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

[Woo POS] Switch to dynamic card reader hint instead of hardcoded "Remove card" prompt #13283

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -292,13 +292,13 @@ class WooPosTotalsViewModel @Inject constructor(
viewModelScope.launch {
cardReaderPaymentController?.paymentState?.collect { paymentState ->
when (paymentState) {
is CardReaderPaymentState.CollectingPayment -> handleCollectingPaymentState()
is CardReaderPaymentState.CollectingPayment -> handleCollectingPaymentState(paymentState)

is CardReaderPaymentState.LoadingData -> handleReaderLoadingPaymentState()

is CardReaderPaymentState.ProcessingPayment,
is CardReaderPaymentState.PaymentCapturing -> {
uiState.value = buildPaymentInProgressState(paymentState)
uiState.value = buildPaymentInProgressState()
childrenToParentEventSender.sendToParent(ChildToParentEvent.PaymentInProgress)
}

Expand All @@ -324,13 +324,15 @@ class WooPosTotalsViewModel @Inject constructor(
}
}

private suspend fun handleCollectingPaymentState() {
private suspend fun handleCollectingPaymentState(paymentState: CardReaderPaymentState.CollectingPayment) {
val totalsState = uiState.value
if (totalsState is WooPosTotalsViewState.Totals) {
uiState.value = totalsState.copy(
readerStatus = WooPosTotalsViewState.ReaderStatus.ReadyForPayment(
title = resourceProvider.getString(R.string.woopos_totals_reader_ready_for_payment_title),
subtitle = resourceProvider.getString(R.string.woopos_totals_reader_ready_for_payment_subtitle)
subtitle = resourceProvider.getString(
paymentState.cardReaderHint ?: R.string.woopos_totals_reader_ready_for_payment_subtitle
)
)
)
} else {
Expand Down Expand Up @@ -378,16 +380,12 @@ class WooPosTotalsViewModel @Inject constructor(
)
}

private fun buildPaymentInProgressState(paymentState: CardReaderPaymentOrRefundState): PaymentInProgress {
val subtitle = when (paymentState) {
is CardReaderPaymentState.ProcessingPayment -> R.string.woo_pos_payment_remove_card
else -> R.string.woopos_success_totals_payment_processing_subtitle
}
private fun buildPaymentInProgressState(): PaymentInProgress {
return PaymentInProgress(
title = resourceProvider.getString(
R.string.woopos_success_totals_payment_processing_title
),
subtitle = resourceProvider.getString(subtitle)
subtitle = resourceProvider.getString(R.string.woopos_success_totals_payment_processing_subtitle)
)
}

Expand Down
1 change: 0 additions & 1 deletion WooCommerce/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4346,7 +4346,6 @@
<string name="woo_pos_payment_failed_try_another_payment_method">Try another payment method</string>
<string name="woo_pos_payment_failed_try_again">Try payment again</string>
<string name="woo_pos_payment_failed_go_back_to_checkout">Go back to checkout</string>
<string name="woo_pos_payment_remove_card">Remove card</string>

<string name="woopos_floating_toolbar_overlay_menu_content_description">Dimmed background. Tap to close the menu.</string>
<string name="woopos_floating_toolbar_card_reader_connected_status_content_description">Card reader connected</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,6 @@ class WooPosTotalsViewModelTest {
.thenReturn("Ready for payment")
whenever(resourceProvider.getString(R.string.woopos_totals_reader_ready_for_payment_subtitle))
.thenReturn("Tap, swipe or insert card")
whenever(resourceProvider.getString(R.string.woo_pos_payment_remove_card))
.thenReturn("Remove card")
whenever(resourceProvider.getString(R.string.woopos_no_internet_message))
.thenReturn("No internet")
whenever(resourceProvider.getString(R.string.woopos_success_totals_payment_failed_title))
Expand Down
Loading