ente/src/pages/success.tsx

34 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-03-10 03:24:33 +00:00
import Container from 'components/Container';
2021-03-12 11:43:02 +00:00
import router from 'next/router';
2021-03-10 03:24:33 +00:00
import { useEffect, useState } from 'react';
2021-03-12 11:43:02 +00:00
import { Button } from 'react-bootstrap';
2021-03-10 03:24:33 +00:00
import subscriptionService from 'services/subscriptionService';
export default function SuccessRedirect() {
const [sessionData, setSessionData] = useState(null);
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const sessionId = urlParams.get('session_id');
if (sessionId) {
(async () => {
const sessionJSON = await subscriptionService.getCheckoutSession(
sessionId
);
setSessionData(sessionJSON);
})();
}
}, []);
return (
2021-03-12 11:43:02 +00:00
<Container style={{ color: '#fff' }}>
2021-03-10 03:24:33 +00:00
<div>
<h1>Your payment succeeded</h1>
2021-03-12 11:43:02 +00:00
<Button onClick={() => router.push('/gallery')}>Go Home</Button>
2021-03-10 03:24:33 +00:00
<h4>View CheckoutSession response:</h4>
</div>
<div>
2021-03-12 11:43:02 +00:00
<pre style={{ color: '#fff' }}>{sessionData}</pre>
2021-03-10 03:24:33 +00:00
</div>
</Container>
);
}