import {useState, useEffect} from 'react' import Head from 'next/head' import axios from 'axios' import Router from 'next/router' CheckoutComplete.getInitialProps = async function({ctx: {query: {session_id}}}){ return {session_id} } export default function CheckoutComplete({session_id}){ const [loading, setLoading] = useState(true) useEffect(()=>{ (async ()=>{ const {data: {status}} = await axios.post('/api/orders/current/checkout/verify', {session_id}) if(status === "succeeded") Router.push('/store/checkout/complete') else setLoading(false) })() }, []) if(loading) return ( <> Verifying Payment | Society of Socks

Checkout

Verifying your payment . . .

) return ( <> Checkout Error | Society of Socks

Checkout

There was a problem with your payment.

) }