You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
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 (
|
|
|
|
<>
|
|
|
|
<Head>
|
|
|
|
<title>Verifying Payment | Society of Socks</title>
|
|
|
|
</Head>
|
|
|
|
<h2>Checkout</h2>
|
|
|
|
<p style={{textAlign: 'center'}}>Verifying your payment . . .</p>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Head>
|
|
|
|
<title>Checkout Error | Society of Socks</title>
|
|
|
|
</Head>
|
|
|
|
<h2>Checkout</h2>
|
|
|
|
<p style={{textAlign: 'center'}}>There was a problem with your payment.</p>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|