Redirect checkout to billing with status
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-12 11:49:10 +01:00
parent 8f1d3a3eb6
commit 4bcaef53f7
4 changed files with 45 additions and 3 deletions

View File

@@ -34,6 +34,8 @@
"more": "Weitere Einträge konnten nicht geladen werden.",
"portal": "Paddle-Portal konnte nicht geöffnet werden."
},
"checkoutSuccess": "Checkout abgeschlossen. Dein Paket wird in Kürze aktiviert.",
"checkoutCancelled": "Checkout wurde abgebrochen.",
"sections": {
"invoices": {
"title": "Rechnungen & Zahlungen",

View File

@@ -34,6 +34,8 @@
"more": "Unable to load more entries.",
"portal": "Unable to open the Paddle portal."
},
"checkoutSuccess": "Checkout completed. Your package will activate shortly.",
"checkoutCancelled": "Checkout was cancelled.",
"sections": {
"invoices": {
"title": "Invoices & payments",

View File

@@ -108,6 +108,34 @@ export default function MobileBillingPage() {
}
}, [location.hash, loading]);
React.useEffect(() => {
if (!location.search) {
return;
}
const params = new URLSearchParams(location.search);
const checkout = params.get('checkout');
if (!checkout) {
return;
}
if (checkout === 'success') {
toast.success(t('billing.checkoutSuccess', 'Checkout completed. Your package will activate shortly.'));
} else if (checkout === 'cancel') {
toast(t('billing.checkoutCancelled', 'Checkout was cancelled.'));
}
params.delete('checkout');
navigate(
{
pathname: location.pathname,
search: params.toString(),
hash: location.hash,
},
{ replace: true },
);
}, [location.hash, location.pathname, location.search, navigate, t]);
return (
<MobileShell
activeTab="profile"

View File

@@ -249,9 +249,19 @@ function CheckoutConfirmation({ pkg, onCancel }: { pkg: Package; onCancel: () =>
if (!canProceed || busy) return;
setBusy(true);
try {
if (typeof window === 'undefined') {
throw new Error('Checkout is only available in the browser.');
}
const billingUrl = new URL(adminPath('/mobile/billing'), window.location.origin);
const successUrl = new URL(billingUrl);
successUrl.searchParams.set('checkout', 'success');
const cancelUrl = new URL(billingUrl);
cancelUrl.searchParams.set('checkout', 'cancel');
const { checkout_url } = await createTenantPaddleCheckout(pkg.id, {
success_url: window.location.href,
return_url: window.location.href,
success_url: successUrl.toString(),
return_url: cancelUrl.toString(),
});
window.location.href = checkout_url;
} catch (err) {