Skip to content

Commit 19cfd04

Browse files
authored
Merge pull request #733 from code-payments/fix/onramp-error-codes
fix(onramp): align Coinbase error codes with official docs and group by UI
2 parents e785077 + 250d24c commit 19cfd04

5 files changed

Lines changed: 265 additions & 93 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@
570570
<string name="error_title_onrampTransactionAvsValidationFailed">Billing Address Invalid</string>
571571
<string name="error_description_onrampTransactionAvsValidationFailed">Please check that your billing address is correct and try again</string>
572572

573+
<string name="error_title_onrampInvalidBillingName">Billing Name Invalid</string>
574+
<string name="error_description_onrampInvalidBillingName">Please check that the name on your card matches your billing name and try again</string>
575+
573576
<string name="error_title_onrampTransactionFailed">Something Went Wrong</string>
574577
<string name="error_description_onrampTransactionFailed">The Coinbase team has been notified and is investigating the issue. Your funds will arrive once resolved. We appreciate your patience</string>
575578

apps/flipcash/shared/onramp/coinbase/src/main/kotlin/com/flipcash/app/onramp/CoinbaseOnRampHandler.kt

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -62,83 +62,119 @@ fun CoinbaseOnRampHandler(
6262

6363
private fun showOnRampFailure(resources: Resources, error: CoinbaseOnRampWebError) {
6464
when (error) {
65-
is CoinbaseOnRampWebError.Unknown,
66-
is CoinbaseOnRampWebError.MissingTransactionUuid -> {
65+
// --- Grouped errors ---
66+
67+
is CoinbaseOnRampWebError.UnknownFailure -> {
6768
BottomBarManager.showError(
6869
title = resources.getString(R.string.error_title_onrampUnknownFailure),
6970
message = resources.getString(R.string.error_description_onrampUnknownFailure),
7071
)
7172
}
7273

74+
is CoinbaseOnRampWebError.CardDeclined -> {
75+
BottomBarManager.showAlert(
76+
title = resources.getString(R.string.error_title_onrampCardSoftDeclined),
77+
message = resources.getString(R.string.error_description_onrampCardSoftDeclined),
78+
)
79+
}
80+
81+
is CoinbaseOnRampWebError.BillingAddressInvalid -> {
82+
BottomBarManager.showAlert(
83+
title = resources.getString(R.string.error_title_onrampTransactionAvsValidationFailed),
84+
message = resources.getString(R.string.error_description_onrampTransactionAvsValidationFailed),
85+
)
86+
}
87+
88+
is CoinbaseOnRampWebError.InternalFailure -> {
89+
BottomBarManager.showError(
90+
title = resources.getString(R.string.error_title_onrampInternal),
91+
message = resources.getString(R.string.error_description_onrampInternal),
92+
)
93+
}
94+
95+
is CoinbaseOnRampWebError.TransactionFailed -> {
96+
BottomBarManager.showError(
97+
title = resources.getString(R.string.error_title_onrampTransactionFailed),
98+
message = resources.getString(R.string.error_description_onrampTransactionFailed),
99+
)
100+
}
101+
102+
// --- Single-variant errors ---
103+
73104
is CoinbaseOnRampWebError.GuestCardNotDebit -> {
74105
BottomBarManager.showAlert(
75106
title = resources.getString(R.string.error_title_onrampInvalidCard),
76107
message = resources.getString(R.string.error_description_onrampInvalidCard),
77108
)
78109
}
79110

80-
is CoinbaseOnRampWebError.GuestRegionMismatch -> {
111+
is CoinbaseOnRampWebError.GuestCardRiskDeclined -> {
81112
BottomBarManager.showAlert(
82-
title = resources.getString(R.string.error_title_onrampRegionMismatch),
83-
message = resources.getString(R.string.error_description_onrampRegionMismatch),
113+
title = resources.getString(R.string.error_title_onrampCardRiskDeclined),
114+
message = resources.getString(R.string.error_description_onrampCardRiskDeclined),
115+
)
116+
}
117+
118+
is CoinbaseOnRampWebError.GuestPermissionDenied -> {
119+
BottomBarManager.showAlert(
120+
title = resources.getString(R.string.error_title_onrampCardPermissionDenied),
121+
message = resources.getString(R.string.error_description_onrampCardPermissionDenied),
84122
)
85123
}
86124

87-
is CoinbaseOnRampWebError.AssetNotTradableInRegion -> {
125+
is CoinbaseOnRampWebError.RegionNotSupported -> {
88126
BottomBarManager.showAlert(
89127
title = resources.getString(R.string.error_title_onrampRegionMismatch),
90128
message = resources.getString(R.string.error_description_onrampRegionMismatch),
91129
)
92130
}
93131

94-
is CoinbaseOnRampWebError.GuestGooglePayError -> {
95-
BottomBarManager.showError(
96-
title = resources.getString(R.string.error_title_onrampTransactionFailed),
97-
message = resources.getString(R.string.error_description_onrampTransactionFailed),
132+
is CoinbaseOnRampWebError.GuestWeeklyTransactionLimitReached -> {
133+
BottomBarManager.showAlert(
134+
title = resources.getString(R.string.error_title_onrampTransactionLimit),
135+
message = resources.getString(R.string.error_description_onrampTransactionLimit),
98136
)
99137
}
100138

101-
is CoinbaseOnRampWebError.GuestGooglePayNotReady -> {
139+
is CoinbaseOnRampWebError.GuestTransactionMaxLimitReached -> {
102140
BottomBarManager.showAlert(
103-
title = resources.getString(R.string.error_title_onrampGooglePayNotReady),
104-
message = resources.getString(R.string.error_description_onrampGooglePayNotReady),
141+
title = resources.getString(R.string.error_title_onrampTransactionCount),
142+
message = resources.getString(R.string.error_description_onrampTransactionCount),
105143
)
106144
}
107145

108-
is CoinbaseOnRampWebError.GuestTransactionBuyFailed -> {
109-
BottomBarManager.showError(
110-
title = resources.getString(R.string.error_title_onrampTransactionBuyFailed),
111-
message = resources.getString(R.string.error_description_onrampTransactionBuyFailed),
146+
is CoinbaseOnRampWebError.GuestGooglePayNotReady -> {
147+
BottomBarManager.showAlert(
148+
title = resources.getString(R.string.error_title_onrampGooglePayNotReady),
149+
message = resources.getString(R.string.error_description_onrampGooglePayNotReady),
112150
)
113151
}
114152

115-
is CoinbaseOnRampWebError.GuestTransactionSendFailed -> {
116-
BottomBarManager.showError(
117-
title = resources.getString(R.string.error_title_onrampTransactionSendFailed),
118-
message = resources.getString(R.string.error_description_onrampTransactionSendFailed),
153+
is CoinbaseOnRampWebError.GuestGooglePayNotSupported -> {
154+
BottomBarManager.showAlert(
155+
title = resources.getString(R.string.error_title_onrampGooglePayNotSupported),
156+
message = resources.getString(R.string.error_description_onrampGooglePayNotSupported),
119157
)
120158
}
121159

122-
is CoinbaseOnRampWebError.GuestTransactionAvsValidationFailed -> {
123-
BottomBarManager.showError(
124-
title = resources.getString(R.string.error_title_onrampTransactionAvsValidationFailed),
125-
message = resources.getString(R.string.error_description_onrampTransactionAvsValidationFailed),
160+
is CoinbaseOnRampWebError.GuestCardInsufficientBalance -> {
161+
BottomBarManager.showAlert(
162+
title = resources.getString(R.string.error_title_onrampCardInsufficientBalance),
163+
message = resources.getString(R.string.error_description_onrampCardInsufficientBalance),
126164
)
127165
}
128166

129-
is CoinbaseOnRampWebError.GuestTransactionTransactionFailed -> {
130-
BottomBarManager.showError(
131-
title = resources.getString(R.string.error_title_onrampTransactionFailed),
132-
message = resources.getString(R.string.error_description_onrampTransactionFailed),
167+
is CoinbaseOnRampWebError.GuestCardPrepaidDeclined -> {
168+
BottomBarManager.showAlert(
169+
title = resources.getString(R.string.error_title_onrampCardPrepaidDeclined),
170+
message = resources.getString(R.string.error_description_onrampCardPrepaidDeclined),
133171
)
134172
}
135173

136-
is CoinbaseOnRampWebError.Internal,
137-
is CoinbaseOnRampWebError.GooglePayButtonNotFound,
138-
is CoinbaseOnRampWebError.WebViewTimeout -> {
139-
BottomBarManager.showError(
140-
title = resources.getString(R.string.error_title_onrampInternal),
141-
message = resources.getString(R.string.error_description_onrampInternal),
174+
is CoinbaseOnRampWebError.InvalidBillingName -> {
175+
BottomBarManager.showAlert(
176+
title = resources.getString(R.string.error_title_onrampInvalidBillingName),
177+
message = resources.getString(R.string.error_description_onrampInvalidBillingName),
142178
)
143179
}
144180

apps/flipcash/shared/onramp/coinbase/src/main/kotlin/com/flipcash/app/onramp/CoinbaseOnRampWebview.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private fun WebView.configureForCoinbaseOnRamp(
9797
"gmsVersion" to gmsVersion
9898
},
9999
)
100-
onPaymentFailure(CoinbaseOnRampWebError.WebViewTimeout())
100+
onPaymentFailure(CoinbaseOnRampWebError.InternalFailure.WebViewTimeout())
101101
}
102102
}
103103

@@ -221,7 +221,7 @@ private fun WebView.configureForCoinbaseOnRamp(
221221
error: WebResourceError?
222222
) {
223223
if (request?.isForMainFrame == true) {
224-
wrappedOnPaymentFailure(CoinbaseOnRampWebError.GuestGooglePayError())
224+
wrappedOnPaymentFailure(CoinbaseOnRampWebError.TransactionFailed.GooglePayError())
225225
}
226226
}
227227
}

0 commit comments

Comments
 (0)