Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
73b7008
[fix] Show payment failure page for plan-upgrade payments #1145
pandafy Jul 16, 2026
a442348
[fix] Fixes by @coderabbita
pandafy Jul 16, 2026
fe33f6e
[fix] Fixes by @coderabbitai
pandafy Jul 17, 2026
dd7d661
[fix] Perform captive portal login when user upgrades to paid plan #1147
pandafy Jul 20, 2026
4461cba
[change] Added flow for cancelling an ongoing upgrade
pandafy Jul 20, 2026
5356460
[feature] Added captive_portal_supports_coa flag
pandafy Jul 20, 2026
04b9cc5
[fix] Fixed captive portal login flow
pandafy Jul 20, 2026
2fe11cc
[fix] Refresh radius token before attempting upgrade
pandafy Jul 20, 2026
765d828
[change] Logout user from captive portal when upgrade is abandoned
pandafy Jul 22, 2026
a5f64ed
[fix] Fixed redirect to login after captive portal login
pandafy Jul 22, 2026
191e928
[fix] Payment retry should re-login the user to captive portal
pandafy Jul 23, 2026
2b1da49
[fix] Fixed bugs
pandafy Jul 23, 2026
dc31152
[chores] Fixed test suite
pandafy Jul 25, 2026
ae3a8eb
[fix] Fixed bugs
pandafy Jul 26, 2026
f198f60
[fix] Added handling for non-destructive authMessage
pandafy Jul 26, 2026
3e96b32
[fix] Don't hide loaded on status page for authMessage
pandafy Jul 26, 2026
fafcc69
Merge remote-tracking branch 'origin/master' into fix-payment-failed-…
pandafy Sep 29, 2026
e7b2e94
[feature] Support `?next=` query param in the login url
pandafy Oct 13, 2026
9f6b7c7
[qa] Fixed docs formatting
pandafy Oct 13, 2026
21aae2e
[feature] Added aliases for query params
pandafy Oct 13, 2026
ea19528
[tests] Added browser tests for login continuation and sync auth
pandafy Oct 13, 2026
3492e3d
[feature] Added copyable payment link to /payment/draft
pandafy Oct 13, 2026
8cefe1a
[fix] Added payment return URL handling
pandafy Oct 14, 2026
6e82900
[fix] Fixed browser tests
pandafy Oct 14, 2026
1154b8e
[fix] Fixes by @coderabbitai
pandafy Oct 14, 2026
44841d9
[change] Improved copyable payment link
pandafy Oct 14, 2026
a949781
[feature] Allowed users to select the payment gateway
pandafy Oct 15, 2026
0b56799
[qa] Fixed qa errors
pandafy Oct 15, 2026
2dffad6
[tests] Fixed failing tests
pandafy Oct 15, 2026
fded425
[fix] Allow user to abandom upgrade from payment gateway selection
pandafy Oct 15, 2026
6ae1194
[change] Udpated /payment/draft message
pandafy Oct 15, 2026
8f31b1a
[fix] Fixed failing tests
pandafy Oct 15, 2026
a4f22e4
[qa] Fixed qa issues
pandafy Oct 15, 2026
1daa1a3
[fix] Fixes from review of GPT 6.1 Astra
pandafy Oct 16, 2026
edcb8de
[fix] Don't remove loader when users comes back from sync auth login
pandafy Oct 16, 2026
10e1950
[fix] Login user to captive portal after successful payment
pandafy Oct 16, 2026
cb303ba
[fix] Restore internet for payment with iframe and without internet
pandafy Oct 16, 2026
b3d85be
Merge branch 'master' into fix-payment-failed-redirect
pandafy Oct 16, 2026
37909ec
[fix] Fixed captive portal re-login
pandafy Oct 16, 2026
8c3af09
[fix] Handle payment cancellation
pandafy Oct 21, 2026
928c3ad
[chores] Updated message for cancel button
pandafy Oct 21, 2026
9391300
[fix] Restored captive portal access after payment
pandafy Oct 21, 2026
2a33c37
[chores] Fixed browser tests
pandafy Oct 21, 2026
1b815a0
[fix] Fixes by @coderabbitai
pandafy Oct 21, 2026
34a8de6
[chores] Added prefix to the captive portal logout form fields
pandafy Oct 21, 2026
cc9d312
[tests] Fixed browser tests
pandafy Oct 21, 2026
da623c9
[change] Don't enable internet mode when sycn auth is enabled
pandafy Oct 22, 2026
fad50a0
[fix] Fixes by @coderabbitai
pandafy Oct 30, 2026
d03788e
[fix] Removed blank lines and de-slopification
pandafy Oct 30, 2026
ca3468d
[chores] Addressed review feedback
pandafy Oct 30, 2026
871eb07
[chores] Addressed review feedback
pandafy Oct 30, 2026
bc57c12
[chores] Addressed review feedback
pandafy Oct 30, 2026
762c80e
[fix] Fixes by @coderabbitai
pandafy Nov 1, 2026
f6a9257
[fix] Fixes by @coderabbitai
pandafy Nov 2, 2026
d0d61f2
[fix] Fixes by @coderabbitai
pandafy Nov 2, 2026
4d2a2fd
Merge branch 'master' into fix-payment-failed-redirect
pandafy Nov 2, 2026
e0f267d
[ci] Fixes by @coderabbitai
pandafy Nov 2, 2026
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
141 changes: 104 additions & 37 deletions client/components/payment-status/payment-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import {Link, Navigate} from "react-router-dom";
import {toast} from "react-toastify";
import {t} from "ttag";
import LoadingContext from "../../utils/loading-context";
import Loader from "../../utils/loader";
import Contact from "../contact-box";
import validateToken from "../../utils/validate-token";
import handleLogout from "../../utils/handle-logout";
import cancelUpgradePlan from "../../utils/cancel-upgrade-plan";
import logError from "../../utils/log-error";

export default class PaymentStatus extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -45,16 +48,22 @@ export default class PaymentStatus extends React.Component {
const {method, is_verified: isVerified} = userData;
// flag user to repeat login in order to restart session with new radius group
if (status === "success" && method === "bank_card" && isVerified === true) {
setUserData({
...userData,
mustLogin: !settings.payment_requires_internet,
mustLogout: settings.payment_requires_internet,
repeatLogin: settings.payment_requires_internet,
});
// when the captive portal supports CoA, the backend transitions the
// session to the new radius group transparently, so no logout/login
// cycle is needed here
if (!settings.captive_portal_supports_coa) {
setUserData({
...userData,
mustLogin: !settings.payment_requires_internet,
mustLogout: settings.payment_requires_internet,
repeatLogin: settings.payment_requires_internet,
});
}
} else if (
status === "draft" &&
method === "bank_card" &&
isVerified === false
// User will need internet access for completing the payment whether
// they are registering with a paid plan or upgrade to one.
(userData.in_upgrade || (method === "bank_card" && isVerified === false))
) {
setUserData({
...userData,
Expand All @@ -63,6 +72,42 @@ export default class PaymentStatus extends React.Component {
}
}

// a user who gives up on a plan upgrade keeps their existing plan,
// so they are sent back to the status page without logging out.
// The backend must cancel the pending upgrade order and stale
// upgrade/login flags must be cleared, otherwise status.js can still
// bounce the user back to payment/draft.
backToStatus = async () => {
const {orgSlug, navigate, setUserData, userData, language} = this.props;
try {
const response = await cancelUpgradePlan(
orgSlug,
userData.auth_token || userData.key,
language,
);
setUserData({
...userData,
...response,
auth_token: response.auth_token || response.key || userData.auth_token,
proceedToPayment: false,
mustLogin: undefined,
});
} catch (error) {
if (!error.response || error.response.status !== 404) {
toast.error(t`ERR_OCCUR`);
logError(error, "Error while cancelling plan upgrade");
}
setUserData({
...userData,
in_upgrade: false,
proceedToPayment: false,
payment_url: null,
mustLogin: undefined,
});
}
navigate(`/${orgSlug}/status`);
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

logout = () => {
const {logout, cookies, orgSlug, setUserData, userData, navigate} =
this.props;
Expand All @@ -82,33 +127,39 @@ export default class PaymentStatus extends React.Component {
render() {
const {orgSlug, params, isAuthenticated, userData} = this.props;
const {status} = params;
const {method, is_verified: isVerified} = userData;
const {method, is_verified: isVerified, in_upgrade: inUpgrade} = userData;
const redirectToStatus = () => <Navigate to={`/${orgSlug}/status`} />;
const acceptedValues = ["success", "failed", "draft"];
const {isTokenValid} = this.state;

// not registered with bank card flow
if (
(method && method !== "bank_card") ||
!acceptedValues.includes(status)
) {
return redirectToStatus();
}

// likely somebody opening this page by mistake
if (
// a user upgrading their plan keeps the registration method and the
// verified flag they already had, so the checks written for the bank
// card registration flow would send them away from this page
const isFailedUpgrade = Boolean(inUpgrade) && status === "failed";
// a user upgrading their plan keeps the registration method and the
// verified flag they already had, so the draft page checks written for
// the bank card registration flow would otherwise send them away
const isDraftUpgrade = Boolean(inUpgrade) && status === "draft";
// invalid status, not registered with bank card flow, or likely
// somebody opening this page by mistake
const shouldRedirectToStatus =
!acceptedValues.includes(status) ||
(!inUpgrade && method && method !== "bank_card") ||
(isAuthenticated === false && status !== "draft") ||
(["failed", "draft"].includes(status) && isVerified === true) ||
(!isFailedUpgrade &&
!isDraftUpgrade &&
["failed", "draft"].includes(status) &&
isVerified === true) ||
(status === "success" && isVerified === false) ||
isTokenValid === false
) {
isTokenValid === false;

if (shouldRedirectToStatus) {
return redirectToStatus();
}

// draft case
// if (isAuthenticated === false && status === "draft") {
if (status === "draft") {
return this.renderDraft();
return this.renderDraft(isDraftUpgrade);
}

// success case
Expand All @@ -117,7 +168,14 @@ export default class PaymentStatus extends React.Component {
return redirectToStatus();
}

return this.renderFailed();
// isTokenValid is still null while validateToken() is resolving, so
// in_upgrade (and therefore isFailedUpgrade) isn't reliable yet on a cold
// reload; show a loader instead of flashing the wrong failed-page variant
if (status === "failed" && isTokenValid === null) {
return <Loader />;
}

return this.renderFailed(isFailedUpgrade);
}

paymentProceedHandler() {
Expand All @@ -135,7 +193,7 @@ export default class PaymentStatus extends React.Component {
authenticate(true);
}

renderDraft() {
renderDraft(isDraftUpgrade = false) {
const {orgSlug, page = {}, settings} = this.props;
const {timeout = 5, max_attempts: maxAttempts = 3} = page;
const payProceedUrl = settings.payment_requires_internet
Expand Down Expand Up @@ -170,9 +228,9 @@ export default class PaymentStatus extends React.Component {
<button
type="button"
className="button full"
onClick={this.logout}
onClick={isDraftUpgrade ? this.backToStatus : this.logout}
>
{t`PAY_GIVE_UP_BTN`}
{isDraftUpgrade ? t`PAY_GO_BACK_BTN` : t`PAY_GIVE_UP_BTN`}
</button>
</div>
</div>
Expand All @@ -182,8 +240,14 @@ export default class PaymentStatus extends React.Component {
);
}

renderFailed() {
const {orgSlug} = this.props;
renderFailed(isFailedUpgrade = false) {
const {orgSlug, userData} = this.props;
const retryUrl = isFailedUpgrade
? `/${orgSlug}/payment/process`
: `/${orgSlug}/payment/draft`;
// an upgrade which ran out of allowed payment attempts has no
// payment URL left to send the user to
const showRetry = !isFailedUpgrade || Boolean(userData.payment_url);
Comment thread
pandafy marked this conversation as resolved.
Resolved
// failed payment case
return (
<div className="container content">
Expand All @@ -192,20 +256,22 @@ export default class PaymentStatus extends React.Component {
<div className="inner">
<h2 className="row payment-status-row-1">{t`PAY_FAIL`}</h2>
<div className="row payment-status-row-2">{t`PAY_SUB_H`}</div>
<div className="row payment-status-row-3">
<Link className="button full" to={`/${orgSlug}/payment/draft`}>
{t`PAY_TRY_AGAIN_BTN`}
</Link>
</div>
{showRetry && (
<div className="row payment-status-row-3">
<Link className="button full" to={retryUrl}>
{t`PAY_TRY_AGAIN_BTN`}
</Link>
</div>
)}

<div className="row payment-status-row-4">
<p>{t`PAY_GIVE_UP_TXT`}</p>
<button
type="button"
className="button full"
onClick={this.logout}
onClick={isFailedUpgrade ? this.backToStatus : this.logout}
>
{t`PAY_GIVE_UP_BTN`}
{isFailedUpgrade ? t`PAY_GO_BACK_BTN` : t`PAY_GIVE_UP_BTN`}
</button>
</div>
</div>
Expand All @@ -230,6 +296,7 @@ PaymentStatus.propTypes = {
cookies: PropTypes.instanceOf(Cookies).isRequired,
settings: PropTypes.shape({
payment_requires_internet: PropTypes.bool,
captive_portal_supports_coa: PropTypes.bool,
}).isRequired,
params: PropTypes.shape({
status: PropTypes.string,
Expand Down
Loading
Loading