Skip to content
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

Clear error message when the charge got rejected #1923

Merged
merged 26 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
65a8b0d
initial testing
FSM1 Feb 1, 2022
af63dea
Merge remote-tracking branch 'origin/dev' into feat/pay-stripe-invoic…
FSM1 Feb 4, 2022
59236db
lingui extract
actions-user Feb 4, 2022
7b3011f
wire up confirm plan
FSM1 Feb 4, 2022
de83fe5
remove unused imports
FSM1 Feb 4, 2022
6da5bd0
fix error messages for declined card tx
FSM1 Feb 7, 2022
b76880b
use includes
FSM1 Feb 7, 2022
fbd66f9
Merge branch 'dev' into feat/pay-stripe-invoice-1884
FSM1 Feb 7, 2022
7dbfc42
lingui extract
actions-user Feb 7, 2022
b9d7b34
Merge branch 'dev' into feat/pay-stripe-invoice-1884
Tbaut Feb 7, 2022
96d5ad4
resolve lint
FSM1 Feb 7, 2022
03180b8
Update packages/files-ui/src/Components/Modules/Settings/Subscription…
FSM1 Feb 7, 2022
8e8b527
lingui extract
actions-user Feb 7, 2022
aae4e9e
Update packages/files-ui/src/Components/Modules/Settings/Subscription…
FSM1 Feb 7, 2022
84cbc08
revert deleted
FSM1 Feb 7, 2022
208b6d4
lingui extract
actions-user Feb 7, 2022
8c7f217
Update packages/files-ui/src/Components/Modules/Settings/Subscription…
FSM1 Feb 8, 2022
1019ade
fix ternary
FSM1 Feb 8, 2022
8664fd7
remove unused import
FSM1 Feb 8, 2022
166200d
clear error message
Tbaut Feb 8, 2022
c91e453
Merge branch 'dev' into fix/tbaut-errorMessage-1922
Tbaut Feb 8, 2022
cec7154
prevent repetition
Tbaut Feb 8, 2022
d0ec32a
Merge branch 'fix/tbaut-errorMessage-1922' of github.com:ChainSafe/ui…
Tbaut Feb 8, 2022
54618cc
oops
Tbaut Feb 8, 2022
b3abd6e
Update packages/files-ui/src/Components/Modules/Settings/Subscription…
Tbaut Feb 8, 2022
7ef3194
Merge branch 'dev' into fix/tbaut-errorMessage-1922
Tbaut Feb 8, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import PlanSuccess from "./PlanSuccess"
import DowngradeDetails from "./DowngradeDetails"
import { PaymentMethod } from "../../../../../Contexts/BillingContext"
import CryptoPayment from "../Common/CryptoPayment"
import { t } from "@lingui/macro"
import { formatSubscriptionError } from "../utils/formatSubscriptionError"

const useStyles = makeStyles(({ constants, breakpoints }: CSFTheme) =>
createStyles({
Expand Down Expand Up @@ -97,11 +97,8 @@ const ChangeProductModal = ({ onClose }: IChangeProductModal) => {
setSlide("planSuccess")
})
.catch((e) => {
if (e.error.code === 400 && e.error.message.includes("declined")) {
setSubscriptionErrorMessage(t`The transaction was declined. Please use a different card or try again.`)
} else {
setSubscriptionErrorMessage(t`Failed to update the subscription. Please try again later.`)
}
const errorMessage = formatSubscriptionError(e)
setSubscriptionErrorMessage(errorMessage)
})
.finally(() => setIsLoadingChangeSubscription(false))
}
Expand Down Expand Up @@ -185,8 +182,14 @@ const ChangeProductModal = ({ onClose }: IChangeProductModal) => {
<ConfirmPlan
plan={selectedPlan}
planPrice={selectedPrice}
goToSelectPlan={() => setSlide("select")}
goToPaymentMethod={() => setSlide("paymentMethod")}
goToSelectPlan={() => {
setSubscriptionErrorMessage(undefined)
setSlide("select")}
}
goToPaymentMethod={() => {
setSubscriptionErrorMessage(undefined)
setSlide("paymentMethod")
}}
loadingChangeSubscription={isLoadingChangeSubscription}
onChangeSubscription={selectedPaymentMethod === "creditCard" ? handleChangeSubscription : () => setSlide("cryptoPayment")}
subscriptionErrorMessage={subscriptionErrorMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CryptoPayment from "../Common/CryptoPayment"
import { useBilling } from "../../../../../Contexts/BillingContext"
import { useFilesApi } from "../../../../../Contexts/FilesApiContext"
import ConfirmPlan from "../Common/ConfirmPlan"
import { t } from "@lingui/macro"
import { formatSubscriptionError } from "../utils/formatSubscriptionError"

const useStyles = makeStyles(({ constants, breakpoints }: CSFTheme) =>
createStyles({
Expand Down Expand Up @@ -48,12 +48,9 @@ const PayInvoiceModal = ({ onClose, invoiceId }: IChangeProductModal) => {
setPayingInvoice(true)
setErrorMessage(undefined)
filesApiClient.payInvoice(invoiceToPay.uuid).then(refreshInvoices)
} catch (error) {
if ((error as any).error.code === 400 && (error as any).error.message.includes("declined")) {
setErrorMessage(t`The transaction was declined. Please use a different card or try again.`)
} else {
setErrorMessage(t`Failed to update the subscription. Please try again later.`)
}
} catch (error: any) {
const errorMessage = formatSubscriptionError(error)
setErrorMessage(errorMessage)
} finally {
setPayingInvoice(false)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { t } from "@lingui/macro"

export const formatSubscriptionError = (e: any): string =>
e.error.code === 400 && e.error.message.includes("declined")
? t`The transaction was declined. Please use a different card or try again.`
: t`Failed to update the subscription. Please try again later.`