Skip to content

Commit

Permalink
Made success page after checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
Favor-star committed Jul 23, 2024
1 parent 0fc3085 commit 53f7bf1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
41 changes: 39 additions & 2 deletions public/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,46 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<title>Payment Successful</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.container {
text-align: center;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #007a7a;
}
.button {
display: inline-block;
padding: 10px 20px;
background-color: #007a7a;
color: white;
text-decoration: none;
border-radius: 4px;
transition: background-color 0.3s;
}
.button:hover {
background-color: #006262;
}
</style>
</head>
<body>
<h1>Success</h1>
<div class="container">
<h1>Payment Successful!</h1>
<p>Thank you for your purchase.</p>
<a href="https://e-commerce-mavericks-fn.netlify.app/" class="button">Return to Homepage</a>
</div>
</body>
</html>
7 changes: 5 additions & 2 deletions src/controllers/handlePaymentsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ export const handlePayments = async (req: Request, res: Response) => {
}
}
}

const successURL =
process.env.FRONT_END_BASEURL === ''
? `${process.env.URL_HOST}/success.html`
: `${process.env.FRONT_END_BASEURL}/payment/success?ok=true`;
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
mode: 'payment',
success_url: `${process.env.URL_HOST}/success.html`,
success_url: successURL,
line_items: lineItems,
cancel_url: `${process.env.URL_HOST}/cancel.html`,
metadata: {
Expand Down

0 comments on commit 53f7bf1

Please sign in to comment.