Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ama-cantabile authored and github-actions[bot] committed May 13, 2024
1 parent bd34560 commit 0c1ee31
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 55 deletions.
18 changes: 11 additions & 7 deletions src/app/api/stripe/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ export async function POST(req) {
cancel_url: `${baseURL}/?paymentStatus=false`,
});

return NextResponse.json({url: session.url}, {status: 303, headers: {
'Location': session.url
}});

return NextResponse.json(
{ url: session.url },
{
status: 303,
headers: {
Location: session.url,
},
}
);
} catch (err) {
return NextResponse.json(err.message, {status: err.statusCode || 500});
return NextResponse.json(err.message, { status: err.statusCode || 500 });
}

}
}
96 changes: 48 additions & 48 deletions src/app/payment/page.js
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>
);
}

0 comments on commit 0c1ee31

Please sign in to comment.