-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd34560
commit 0c1ee31
Showing
2 changed files
with
59 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
'use client' | ||
'use client'; | ||
|
||
import { loadStripe } from '@stripe/stripe-js'; | ||
import { useSearchParams } from "next/navigation"; | ||
import { useSearchParams } from 'next/navigation'; | ||
|
||
// Make sure to call `loadStripe` outside of a component’s render to avoid | ||
// recreating the `Stripe` object on every render. | ||
loadStripe(process.env.STRIPE_PUBLISHABLE_KEY); | ||
|
||
// TODO: Needs styling | ||
export default function PreviewPage() { | ||
const searchParams = useSearchParams(); | ||
|
||
const paymentStatus = searchParams.get('paymentStatus'); | ||
const searchParams = useSearchParams(); | ||
|
||
if (paymentStatus) { | ||
return ( | ||
<> | ||
<h1>Payment Status</h1> | ||
<p>Payment was successful: {paymentStatus}</p> | ||
</> | ||
) | ||
} | ||
const paymentStatus = searchParams.get('paymentStatus'); | ||
|
||
if (paymentStatus) { | ||
return ( | ||
<form action="/api/stripe" method="POST"> | ||
<section> | ||
<button type="submit" role="link"> | ||
Checkout | ||
</button> | ||
</section> | ||
<style jsx> | ||
{` | ||
section { | ||
background: #ffffff; | ||
display: flex; | ||
flex-direction: column; | ||
width: 400px; | ||
height: 112px; | ||
border-radius: 6px; | ||
justify-content: space-between; | ||
} | ||
button { | ||
height: 36px; | ||
background: #556cd6; | ||
border-radius: 4px; | ||
color: white; | ||
border: 0; | ||
font-weight: 600; | ||
cursor: pointer; | ||
transition: all 0.2s ease; | ||
box-shadow: 0px 4px 5.5px 0px rgba(0, 0, 0, 0.07); | ||
} | ||
button:hover { | ||
opacity: 0.8; | ||
} | ||
`} | ||
</style> | ||
</form> | ||
<> | ||
<h1>Payment Status</h1> | ||
<p>Payment was successful: {paymentStatus}</p> | ||
</> | ||
); | ||
} | ||
} | ||
|
||
return ( | ||
<form action="/api/stripe" method="POST"> | ||
<section> | ||
<button type="submit" role="link"> | ||
Checkout | ||
</button> | ||
</section> | ||
<style jsx> | ||
{` | ||
section { | ||
background: #ffffff; | ||
display: flex; | ||
flex-direction: column; | ||
width: 400px; | ||
height: 112px; | ||
border-radius: 6px; | ||
justify-content: space-between; | ||
} | ||
button { | ||
height: 36px; | ||
background: #556cd6; | ||
border-radius: 4px; | ||
color: white; | ||
border: 0; | ||
font-weight: 600; | ||
cursor: pointer; | ||
transition: all 0.2s ease; | ||
box-shadow: 0px 4px 5.5px 0px rgba(0, 0, 0, 0.07); | ||
} | ||
button:hover { | ||
opacity: 0.8; | ||
} | ||
`} | ||
</style> | ||
</form> | ||
); | ||
} |