Skip to content

Commit bf89576

Browse files
authored
chore: handle payment failure attempt (#2068)
fixes PROD-452
1 parent 4dc5991 commit bf89576

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

@3rdweb-sdk/react/hooks/useApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type Account = {
3333
unconfirmedEmail?: string;
3434
stripePaymentActionUrl?: string;
3535
onboardSkipped?: boolean;
36+
paymentAttemptCount?: number;
3637
notificationPreferences?: {
3738
billing: "email" | "none";
3839
updates: "email" | "none";

components/settings/Account/BillingAlert.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const BillingAlert = () => {
128128
return null;
129129
}
130130

131-
const { status, stripePaymentActionUrl } = meQuery.data;
131+
const { status, stripePaymentActionUrl, paymentAttemptCount } = meQuery.data;
132132

133133
if (status === "paymentVerification") {
134134
const message = !stripePaymentActionUrl?.startsWith(
@@ -147,7 +147,10 @@ export const BillingAlert = () => {
147147
);
148148
}
149149

150-
if (status === "invalidPayment") {
150+
if (
151+
status === "invalidPayment" ||
152+
(paymentAttemptCount && paymentAttemptCount !== 0)
153+
) {
151154
return (
152155
<BillingTypeAlert
153156
title="Your payment method was declined"

components/settings/Account/ManageBillingButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const ManageBillingButton: React.FC<ManageBillingButtonProps> = ({
6464
size="sm"
6565
fontWeight="normal"
6666
>
67-
{account.status === "validPayment"
67+
{account.status === "validPayment" && !account.paymentAttemptCount
6868
? "Manage billing"
6969
: paymentVerification
7070
? "Verify payment method →"

pages/dashboard/settings/billing.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const SettingsBillingPage: ThirdwebNextPage = () => {
2020
const meQuery = useAccount();
2121
const router = useRouter();
2222
const { data: account } = meQuery;
23-
const validPayment = account?.status === "validPayment";
23+
const validPayment =
24+
account?.status === "validPayment" && !account.paymentAttemptCount;
2425
const paymentVerification = account?.status === "paymentVerification";
2526

2627
const [stepsCompleted, setStepsCompleted] = useState<

0 commit comments

Comments
 (0)