Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
6 changes: 5 additions & 1 deletion client/actions/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const logout = (cookies, orgSlug, userAutoLogin = false) => {
cookies.remove(`${orgSlug}_macaddr`, {path: "/"});
sessionStorage.clear();
}
[`${orgSlug}_mustLogin`, `${orgSlug}_mustLogout`].forEach((element) => {
[
`${orgSlug}_mustLogin`,
`${orgSlug}_mustLogout`,
`${orgSlug}_captivePortalLogoutOnly`,
].forEach((element) => {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
cookies.remove(element, {path: "/"});
localStorage.removeItem(element);
});
Expand Down
1 change: 1 addition & 0 deletions client/components/payment-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const mapStateToProps = (state, ownProps) => {
userData: conf.userData,
settings: conf.settings,
isAuthenticated: conf.isAuthenticated,
captivePortalSyncAuth: conf.components.captive_portal_sync_auth,
cookies: ownProps.cookies,
status: ownProps.status,
};
Expand Down
172 changes: 131 additions & 41 deletions client/components/payment-status/payment-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ 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";
import {storeValue, clearStoredValue} from "../../utils/synced-storage";

export default class PaymentStatus extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -45,16 +49,19 @@ 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,
});
// Skip logout/login cycle if CoA handles session group updates transparently
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
// Payment completion needs internet for both new registrations and upgrades
(userData.in_upgrade || (method === "bank_card" && isVerified === false))
) {
setUserData({
...userData,
Expand All @@ -63,6 +70,45 @@ export default class PaymentStatus extends React.Component {
}
}

// Abandon upgrade: cancel order, clear flags, reconnect under current plan
backToStatus = async () => {
const {orgSlug, navigate, setUserData, userData, language, cookies} =
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,
mustLogout: true,
captivePortalLogoutOnly: true,
});
} 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,
mustLogout: true,
captivePortalLogoutOnly: true,
});
}
// Clear persisted proceedToPayment flag
clearStoredValue(`${orgSlug}_proceedToPayment`, cookies);
navigate(`/${orgSlug}/status`);
};

logout = () => {
const {logout, cookies, orgSlug, setUserData, userData, navigate} =
this.props;
Expand All @@ -82,33 +128,32 @@ 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 (
// Upgraders retain their existing registration state; bypass bank-card redirect guards
const isFailedUpgrade = Boolean(inUpgrade) && status === "failed";
const isDraftUpgrade = Boolean(inUpgrade) && status === "draft";
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,30 +162,57 @@ export default class PaymentStatus extends React.Component {
return redirectToStatus();
}

return this.renderFailed();
// Show loader while validateToken resolves in_upgrade state on cold reload
if (status === "failed" && isTokenValid === null) {
return <Loader />;
}

return this.renderFailed(isFailedUpgrade);
}

paymentProceedHandler() {
const {authenticate, setUserData, userData, settings} = this.props;
const {
authenticate,
setUserData,
userData,
settings,
cookies,
orgSlug,
captivePortalSyncAuth,
} = this.props;
// Payment gateway may require internet access.
// Since, captive portal login is handled by the Status component,
// the user is navigated to the "/status" for captive portal login
// which then redirects the user to the payment gateway.
if (settings.payment_requires_internet) {
setUserData({
...userData,
mustLogin: true,
proceedToPayment: true,
});
// Persist so it survives page reload during sync captive portal auth
storeValue(captivePortalSyncAuth, `${orgSlug}_mustLogin`, true, cookies);
storeValue(
captivePortalSyncAuth,
`${orgSlug}_proceedToPayment`,
"true",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why is this storing a string literal?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@pandafy I'm not making a code change for this thread.

GitHub was unreachable, so the current PR and review thread could not be verified safely.

cookies,
);
}
authenticate(true);
}

renderDraft() {
const {orgSlug, page = {}, settings} = this.props;
const {timeout = 5, max_attempts: maxAttempts = 3} = page;
const payProceedUrl = settings.payment_requires_internet
getProceedUrl() {
const {orgSlug, settings} = this.props;
return settings.payment_requires_internet
? `/${orgSlug}/status`
: `/${orgSlug}/payment/process`;
}

renderDraft(isDraftUpgrade = false) {
const {page = {}} = this.props;
const {timeout = 5, max_attempts: maxAttempts = 3} = page;
const payProceedUrl = this.getProceedUrl();

return (
<div className="container content">
Expand Down Expand Up @@ -170,9 +242,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 +254,16 @@ export default class PaymentStatus extends React.Component {
);
}

renderFailed() {
const {orgSlug} = this.props;
renderFailed(isFailedUpgrade = false) {
const {orgSlug, userData} = this.props;
// User might have exhausted the temporary session quota while completing
// the payment. Thus, we need to login them back in the captive portal
// before directing them to the payment gateway.
const retryUrl = isFailedUpgrade
? this.getProceedUrl()
: `/${orgSlug}/payment/draft`;
// No retry when upgrade payment attempts exhausted (no payment_url)
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 +272,28 @@ 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}
onClick={
isFailedUpgrade ? this.paymentProceedHandler : undefined
}
>
{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 @@ -224,12 +312,14 @@ PaymentStatus.propTypes = {
userData: PropTypes.object.isRequired,
setUserData: PropTypes.func.isRequired,
isAuthenticated: PropTypes.bool,
captivePortalSyncAuth: PropTypes.bool,
authenticate: PropTypes.func.isRequired,
page: PropTypes.object,
logout: PropTypes.func.isRequired,
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