Skip to content

Add redirect modal for provider unavailable scenario #15627

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

Merged
Merged
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
3 changes: 3 additions & 0 deletions browser/ui/webui/brave_webui_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ void CustomizeWebUIHTMLSource(content::WebUI* web_ui,
{ "redirectModalMismatchedCountriesTitle", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_MISMATCHED_COUNTRIES_TITLE}, // NOLINT
{ "redirectModalMismatchedProviderAccountsText", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_MISMATCHED_PROVIDER_ACCOUNTS_TEXT}, // NOLINT
{ "redirectModalMismatchedProviderAccountsTitle", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_MISMATCHED_PROVIDER_ACCOUNTS_TITLE}, // NOLINT
{ "redirectModalProviderUnavailableText1", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_PROVIDER_UNAVAILABLE_TEXT_1}, // NOLINT
{ "redirectModalProviderUnavailableText2", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_PROVIDER_UNAVAILABLE_TEXT_2}, // NOLINT
{ "redirectModalProviderUnavailableTitle", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_PROVIDER_UNAVAILABLE_TITLE}, // NOLINT
{ "redirectModalRegionNotSupportedText1", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_REGION_NOT_SUPPORTED_TEXT_1}, // NOLINT
{ "redirectModalRegionNotSupportedText2", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_REGION_NOT_SUPPORTED_TEXT_2}, // NOLINT
{ "redirectModalRegionNotSupportedTitle", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_REGION_NOT_SUPPORTED_TITLE}, // NOLINT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ export function ProviderRedirectModal () {
onClick={actions.hideRedirectModal}
/>
)
case 'providerUnavailableModal':
return (
<ModalRedirect
id={'redirect-modal-provider-unavailable'}
errorText={[
getString('redirectModalProviderUnavailableText1').replaceAll('$1', providerName),
getString('redirectModalProviderUnavailableText2')]}
titleText={getString('redirectModalProviderUnavailableTitle')}
errorTextLink={'https://status.brave.com/'}
buttonText={getString('redirectModalClose')}
walletType={walletType}
onClick={actions.hideRedirectModal}
/>
)
case 'regionNotSupportedModal':
return (
<ModalRedirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ const rewardsReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State
break
}

if (data.result === 47) { // type::Result::PROVIDER_UNAVAILABLE
ui.modalRedirect = 'providerUnavailableModal'
break
}

if (data.result !== 0) {
ui.modalRedirect = 'error'
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ const walletReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State,
break
}

if (action.payload.result === 47) { // type::Result::PROVIDER_UNAVAILABLE
state.ui.modalRedirect = 'providerUnavailableModal'
break
}

if (action.payload.result === 0) { // type::Result::LEDGER_OK
chrome.send('brave_rewards.fetchBalance')
}
Expand Down
1 change: 1 addition & 0 deletions components/definitions/rewards.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ declare namespace Rewards {
| 'kycRequiredModal'
| 'mismatchedCountriesModal'
| 'mismatchedProviderAccountsModal'
| 'providerUnavailableModal'
| 'regionNotSupportedModal'
| 'show'
| 'upholdBATNotAllowedModal'
Expand Down
3 changes: 3 additions & 0 deletions components/resources/brave_components_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_MISMATCHED_COUNTRIES_TITLE" desc="">Error: Country mismatch</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_MISMATCHED_PROVIDER_ACCOUNTS_TEXT" desc="">Hmm, it looks like your Brave Rewards has already been verified with another <ph name="PROVIDER">$1<ex>Uphold</ex></ph> account. Please try verifying again using your previous account.</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_MISMATCHED_PROVIDER_ACCOUNTS_TITLE" desc="">Error: Different account</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_PROVIDER_UNAVAILABLE_TEXT_1" desc="">It looks like connecting <ph name="PROVIDER">$1<ex>Uphold</ex></ph> to Brave Rewards is temporarily unavailable. Please try again later.</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_PROVIDER_UNAVAILABLE_TEXT_2" desc="">You can view <ph name="BEGIN_LINK">$2</ph>service status here<ph name="END_LINK">$3</ph>.</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_PROVIDER_UNAVAILABLE_TITLE" desc="">Error: Connecting to selected custodian temporarily unavailable</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_REGION_NOT_SUPPORTED_TEXT_1" desc="">Your <ph name="PROVIDER">$1<ex>Uphold</ex></ph> account can't be connected to your Brave Rewards profile at this time. Your <ph name="PROVIDER">$1<ex>Uphold</ex></ph> account is registered in a country that's not currently supported for connecting to Brave Rewards.</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_REGION_NOT_SUPPORTED_TEXT_2" desc="">See the <ph name="LINK_BEGIN">$2</ph>current list of supported regions and learn more<ph name="END_LINK">$3</ph> about connecting a custodial account to Brave Rewards.</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_REGION_NOT_SUPPORTED_TITLE" desc="">Error: Region currently not supported</message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ enum Result {
UPHOLD_INSUFFICIENT_CAPABILITIES = 43,
FLAGGED_WALLET = 44,
REGION_NOT_SUPPORTED = 45,
MISMATCHED_COUNTRIES = 46
MISMATCHED_COUNTRIES = 46,
PROVIDER_UNAVAILABLE = 47
};

enum PublisherStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum PostConnectError {
kFailedToCreateRequest,
kFlaggedWallet, // HTTP 400
kMismatchedCountries, // HTTP 400
kProviderUnavailable, // HTTP 400
kRegionNotSupported, // HTTP 400
kUnknownMessage, // HTTP 400, HTTP 403
kKycRequired, // HTTP 403, HTTP 404
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void BitflyerAuthorization::OnConnectWallet(
case mojom::Result::FLAGGED_WALLET:
case mojom::Result::REGION_NOT_SUPPORTED:
case mojom::Result::MISMATCHED_COUNTRIES:
case mojom::Result::PROVIDER_UNAVAILABLE:
ledger_->database()->SaveEventLog(
log::GetEventLogKeyForLinkingResult(legacy_result),
constant::kWalletBitflyer + std::string("/") + abbreviated_address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ Result ParseBody(const std::string& body) {
// HTTP 400: bitFlyer, Gemini, Uphold
BLOG(0, "Mismatched countries!");
return base::unexpected(Error::kMismatchedCountries);
} else if (message->find("is temporarily unavailable") != std::string::npos) {
// HTTP 400: bitFlyer, Gemini, Uphold
BLOG(0, "Provider unavailable!");
return base::unexpected(Error::kProviderUnavailable);
} else {
// bitFlyer, Gemini, Uphold
BLOG(0, "Unknown message!");
Expand Down Expand Up @@ -110,6 +114,8 @@ mojom::Result PostConnect::ToLegacyResult(const Result& result) {
return mojom::Result::FLAGGED_WALLET;
case Error::kMismatchedCountries: // HTTP 400
return mojom::Result::MISMATCHED_COUNTRIES;
case Error::kProviderUnavailable: // HTTP 400
return mojom::Result::PROVIDER_UNAVAILABLE;
case Error::kRegionNotSupported: // HTTP 400
return mojom::Result::REGION_NOT_SUPPORTED;
case Error::kUnknownMessage: // HTTP 400, HTTP 403
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ INSTANTIATE_TEST_SUITE_P(
PostConnect,
Values(
PostConnectParamType{
"00_HTTP_200_success",
"HTTP_200_success",
net::HTTP_OK,
"",
{}
},
PostConnectParamType{
"01_HTTP_400_flagged_wallet",
"HTTP_400_flagged_wallet",
net::HTTP_BAD_REQUEST,
R"(
{
Expand All @@ -123,7 +123,7 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kFlaggedWallet)
},
PostConnectParamType{
"02_HTTP_400_mismatched_countries",
"HTTP_400_mismatched_countries",
net::HTTP_BAD_REQUEST,
R"(
{
Expand All @@ -134,7 +134,18 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kMismatchedCountries)
},
PostConnectParamType{
"03_HTTP_400_region_not_supported",
"HTTP_400_provider_unavailable",
net::HTTP_BAD_REQUEST,
R"(
{
"message": "Error validating Connecting Brave Rewards to Uphold is temporarily unavailable. Please try again later",
"code": 400
}
Comment on lines +140 to +143
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ran into this myself 😄, this is what we get back:

{
  "code": 400,
  "data": {
    "validationErrors": null
  },
  "message": "Error validating Connecting Brave Rewards to Uphold is temporarily unavailable.  Please try again later"
}

)",
base::unexpected(Error::kProviderUnavailable)
},
PostConnectParamType{
"HTTP_400_region_not_supported",
net::HTTP_BAD_REQUEST,
R"(
{
Expand All @@ -145,7 +156,7 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kRegionNotSupported)
},
PostConnectParamType{
"04_HTTP_400_unknown_message",
"HTTP_400_unknown_message",
net::HTTP_BAD_REQUEST,
R"(
{
Expand All @@ -156,7 +167,7 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kUnknownMessage)
},
PostConnectParamType{
"05_HTTP_403_kyc_required",
"HTTP_403_kyc_required",
net::HTTP_FORBIDDEN,
R"(
{
Expand All @@ -167,7 +178,7 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kKycRequired)
},
PostConnectParamType{
"06_HTTP_403_mismatched_provider_accounts",
"HTTP_403_mismatched_provider_accounts",
net::HTTP_FORBIDDEN,
R"(
{
Expand All @@ -178,7 +189,7 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kMismatchedProviderAccounts)
},
PostConnectParamType{
"07_HTTP_403_request_signature_verification_failure",
"HTTP_403_request_signature_verification_failure",
net::HTTP_FORBIDDEN,
R"(
{
Expand All @@ -189,7 +200,7 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kRequestSignatureVerificationFailure)
},
PostConnectParamType{
"08_HTTP_403_transaction_verification_failure",
"HTTP_403_transaction_verification_failure",
net::HTTP_FORBIDDEN,
R"(
{
Expand All @@ -200,7 +211,7 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kTransactionVerificationFailure)
},
PostConnectParamType{
"09_HTTP_403_unknown_message",
"HTTP_403_unknown_message",
net::HTTP_FORBIDDEN,
R"(
{
Expand All @@ -211,25 +222,25 @@ INSTANTIATE_TEST_SUITE_P(
base::unexpected(Error::kUnknownMessage)
},
PostConnectParamType{
"10_HTTP_404_kyc_required",
"HTTP_404_kyc_required",
net::HTTP_NOT_FOUND,
"",
base::unexpected(Error::kKycRequired)
},
PostConnectParamType{
"11_HTTP_409_device_limit_reached",
"HTTP_409_device_limit_reached",
net::HTTP_CONFLICT,
"",
base::unexpected(Error::kDeviceLimitReached)
},
PostConnectParamType{
"12_HTTP_500_unexpected_error",
"HTTP_500_unexpected_error",
net::HTTP_INTERNAL_SERVER_ERROR,
"",
base::unexpected(Error::kUnexpectedError)
},
PostConnectParamType{
"13_HTTP_503_unexpected_status_code",
"HTTP_503_unexpected_status_code",
net::HTTP_SERVICE_UNAVAILABLE,
"",
base::unexpected(Error::kUnexpectedStatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ void GeminiAuthorization::OnConnectWallet(
case mojom::Result::FLAGGED_WALLET:
case mojom::Result::REGION_NOT_SUPPORTED:
case mojom::Result::MISMATCHED_COUNTRIES:
case mojom::Result::PROVIDER_UNAVAILABLE:
ledger_->database()->SaveEventLog(
log::GetEventLogKeyForLinkingResult(legacy_result),
constant::kWalletGemini + std::string("/") + abbreviated_address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const char kKYCRequired[] = "kyc_required";
const char kMismatchedCountries[] = "mismatched_countries";
const char kMismatchedProviderAccounts[] = "mismatched_provider_accounts";
const char kPromotionVBATDrained[] = "promotion_vbat_drained";
const char kProviderUnavailable[] = "provider_unavailable";
const char kRecurringTipAdded[] = "recurring_tip_added";
const char kRecurringTipRemoved[] = "recurring_tip_removed";
const char kRegionNotSupported[] = "region_not_supported";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ std::string GetEventLogKeyForLinkingResult(mojom::Result result) {
return log::kMismatchedProviderAccounts;
case mojom::Result::NOT_FOUND:
return log::kKYCRequired;
case mojom::Result::PROVIDER_UNAVAILABLE:
return log::kProviderUnavailable;
case mojom::Result::REGION_NOT_SUPPORTED:
return log::kRegionNotSupported;
case mojom::Result::REQUEST_SIGNATURE_VERIFICATION_FAILURE:
Expand Down
Loading