Skip to content

Commit 89cab61

Browse files
committed
chore(flipcash/pools): handle NSF errors for bids explicitly
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent ce545c8 commit 89cab61

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

apps/flipcash/core/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215

216216
<string name="error_title_paymentFailedDueToInsufficientFunds">Insufficient Balance</string>
217217
<string name="error_description_paymentFailedDueToInsufficientFunds">You don\’t have enough funds to complete this payment</string>
218+
<string name="error_description_poolBidFailedDueToInsufficientFunds">You need more funds to join this Pool</string>
218219

219220
<string name="error_title_placeBetFailed">Something Went Wrong</string>
220221
<string name="error_description_placeBetFailed">We were unable to place your bid. Please try again</string>

apps/flipcash/features/pools/src/main/kotlin/com/flipcash/app/pools/internal/betting/PoolBettingViewModel.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.flipcash.app.core.pools.PoolWithBets
1313
import com.flipcash.app.payments.PaymentController
1414
import com.flipcash.app.payments.PaymentEvent
1515
import com.flipcash.app.payments.PaymentRequest
16+
import com.flipcash.app.payments.internal.PaymentError
1617
import com.flipcash.app.payments.internal.PoolBidPaymentMetadata
1718
import com.flipcash.app.pools.PoolUpdater
1819
import com.flipcash.app.pools.PoolsCoordinator
@@ -347,7 +348,18 @@ internal class PoolBettingViewModel @Inject constructor(
347348
}.onEach { event ->
348349
when (event) {
349350
PaymentEvent.OnPaymentCancelled -> Unit
350-
is PaymentEvent.OnPaymentError -> Unit
351+
is PaymentEvent.OnPaymentError -> {
352+
when (event.error) {
353+
is PaymentError.InsufficientBalance -> {
354+
BottomBarManager.showError(
355+
resources.getString(R.string.error_title_paymentFailedDueToInsufficientFunds),
356+
resources.getString(R.string.error_description_poolBidFailedDueToInsufficientFunds),
357+
)
358+
}
359+
// other errors are handled internally
360+
else -> Unit
361+
}
362+
}
351363
is PaymentEvent.OnRpcFailure -> {
352364
BottomBarManager.showError(
353365
resources.getString(R.string.error_title_placeBetFailed),

apps/flipcash/shared/payments/src/main/kotlin/com/flipcash/app/payments/internal/InternalPaymentController.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,12 @@ internal class InternalPaymentController(
212212
when {
213213
error is PaymentError -> {
214214
when (error) {
215-
is PaymentError.InsufficientBalance -> presentInsufficientFundsError()
215+
is PaymentError.InsufficientBalance -> {
216+
if (state.value.request !is PaymentRequest.PoolBid) {
217+
// NSF on pool bids is handled at client level
218+
presentInsufficientFundsError()
219+
}
220+
}
216221
is PaymentError.NoOwnerForDistribution -> presentPaymentFailedError()
217222
is PaymentError.NoPoolBalance -> presentPaymentFailedError()
218223
}

0 commit comments

Comments
 (0)