fexed stripe webhook
This commit is contained in:
parent
4421acd052
commit
ca019ae28d
1 changed files with 11 additions and 4 deletions
|
|
@ -350,14 +350,21 @@ export const SubscriptionTab: React.FC<SubscriptionTabProps> = ({ mandateId }) =
|
||||||
|
|
||||||
if (sessionId && !verifyCalledRef.current) {
|
if (sessionId && !verifyCalledRef.current) {
|
||||||
verifyCalledRef.current = true;
|
verifyCalledRef.current = true;
|
||||||
verifyCheckout(sessionId)
|
const _pollUntilActive = async (retries = 5, delayMs = 2000) => {
|
||||||
.then((result) => {
|
try {
|
||||||
|
const result = await verifyCheckout(sessionId);
|
||||||
if (result.status === 'activated') {
|
if (result.status === 'activated') {
|
||||||
setCheckoutMessage({ type: 'success', text: 'Abonnement wurde aktiviert.' });
|
setCheckoutMessage({ type: 'success', text: 'Abonnement wurde aktiviert.' });
|
||||||
setJustPaid(false);
|
setJustPaid(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
})
|
} catch { /* handled below via retry */ }
|
||||||
.catch(() => {});
|
if (retries > 0) {
|
||||||
|
await new Promise(r => setTimeout(r, delayMs));
|
||||||
|
await _pollUntilActive(retries - 1, delayMs);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_pollUntilActive();
|
||||||
}
|
}
|
||||||
} else if (params.get('canceled') === 'true') {
|
} else if (params.get('canceled') === 'true') {
|
||||||
setCheckoutMessage({ type: 'info', text: 'Checkout abgebrochen. Ihr bestehendes Abonnement bleibt aktiv.' });
|
setCheckoutMessage({ type: 'info', text: 'Checkout abgebrochen. Ihr bestehendes Abonnement bleibt aktiv.' });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue