Skip to content

Commit

Permalink
Merge branch 'trunk' into issue/12437-update-origin-address-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
atorresveiga authored Jan 14, 2025
2 parents 026b7c6 + 069f146 commit 79b512a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fun WooPosPaymentInProgressScreen(
style = MaterialTheme.typography.h6,
fontWeight = FontWeight.Normal,
)
Spacer(modifier = Modifier.height(16.dp.toAdaptivePadding()))
Spacer(modifier = Modifier.height(8.dp.toAdaptivePadding()))
Text(
text = state.subtitle,
color = WooPosTheme.colors.paymentProcessingText,
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 @@ -4350,7 +4350,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 @@ -861,7 +861,7 @@ class WooPosTotalsViewModelTest {
assertThat(processingState).isInstanceOf(WooPosTotalsViewState.PaymentInProgress::class.java)
with(processingState) {
assertThat(title).isEqualTo("Processing payment")
assertThat(subtitle).isEqualTo("Remove card")
assertThat(subtitle).isEqualTo("Please wait…")
}
}

Expand Down 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

0 comments on commit 79b512a

Please sign in to comment.