Skip to content

Commit 9806405

Browse files
authored
Merge pull request #110 from code-payments/chore/slide-out-receipts
fix(micropayments): slide out receipts
2 parents c5ef9a2 + 2428f37 commit 9806405

2 files changed

Lines changed: 25 additions & 27 deletions

File tree

app/src/main/java/com/getcode/view/main/home/HomeViewModel.kt

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ class HomeViewModel @Inject constructor(
640640
}.onFailure { error ->
641641
error.printStackTrace()
642642
TopBarManager.showMessage(
643-
"Payment Failed",
644-
"This payment request could not be paid at this time. Please try again later."
643+
resources.getString(R.string.error_title_payment_failed),
644+
resources.getString(R.string.error_description_payment_failed),
645645
)
646646
uiFlow.update { uiModel ->
647647
uiModel.copy(
@@ -659,47 +659,43 @@ class HomeViewModel @Inject constructor(
659659
}
660660
}
661661

662-
fun cancelPayment(rejected: Boolean, ignoreRedirect: Boolean = false) {
662+
private fun cancelPayment(rejected: Boolean, ignoreRedirect: Boolean = false) {
663663
val bill = uiFlow.value.billState.bill ?: return
664664
val amount = bill.amount
665665
val request = bill.metadata.request
666666

667667
analytics.requestHidden(amount = amount)
668668

669-
if (rejected) {
670-
if (!ignoreRedirect) {
671-
request?.cancelUrl?.let {
672-
viewModelScope.launch {
673-
_eventFlow.emit(HomeEvent.OpenUrl(it))
674-
}
675-
}
676-
}
677-
} else {
678-
showToast(amount, isDeposit = false)
679-
680-
if (!ignoreRedirect) {
681-
request?.successUrl?.let {
682-
viewModelScope.launch {
683-
_eventFlow.emit(HomeEvent.OpenUrl(it))
684-
}
685-
}
686-
}
687-
}
688-
689669
uiFlow.update {
690670
it.copy(
691-
presentationStyle = PresentationStyle.Hidden,
671+
presentationStyle = PresentationStyle.Slide,
692672
billState = it.billState.copy(
693673
bill = null,
694-
showToast = false,
695674
paymentConfirmation = null,
696-
loginConfirmation = null,
697-
toast = null,
698675
valuation = null,
699676
hideBillButtons = false,
700677
)
701678
)
702679
}
680+
681+
viewModelScope.launch {
682+
delay(300)
683+
if (rejected) {
684+
if (!ignoreRedirect) {
685+
request?.cancelUrl?.let {
686+
_eventFlow.emit(HomeEvent.OpenUrl(it))
687+
}
688+
}
689+
} else {
690+
showToast(amount, isDeposit = false)
691+
692+
if (!ignoreRedirect) {
693+
request?.successUrl?.let {
694+
_eventFlow.emit(HomeEvent.OpenUrl(it))
695+
}
696+
}
697+
}
698+
}
703699
}
704700

705701
fun rejectPayment(ignoreRedirect: Boolean = false) {

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<string name="deleteAccount_title_wontDo">What deleting won\'t do</string>
6464
<string name="error_description_alreadyCollected">This Kin was already collected by someone else.</string>
6565
<string name="error_description_alreadyCollectedBySomeone">This Kin was already collected by someone.</string>
66+
<string name="error_description_payment_failed">This payment request could not be paid at this time. Please try again later.</string>
6667
<string name="error_description_cameraAccessRequired">Please allow access to the camera in Settings to use Code.</string>
6768
<string name="error_description_codeTimedOut">Please re-enter your phone number and try again.</string>
6869
<string name="error_description_contactsAccessRequired">Please allow access to the contacts in Settings to send invites.</string>
@@ -87,6 +88,7 @@
8788
<string name="error_description_tooManyAccounts">You can only create so many new accounts each day.</string>
8889
<string name="error_title_alreadyCollected">Kin Already Collected</string>
8990
<string name="error_title_alreadyCollectedBySomeone">Kin Already Collected</string>
91+
<string name="error_title_payment_failed">Payment Failed</string>
9092
<string name="error_title_cameraAccessRequired">Camera Access Required</string>
9193
<string name="error_title_codeTimedOut">Verification Code Timed Out</string>
9294
<string name="error_title_contactsAccessRequired">Contacts Access Required</string>

0 commit comments

Comments
 (0)