You should put the PaymentIntent creation/Stripe code where you'd keep all of your other API endpoints/logic. You don't need to create a separate backend inside NextJS if you already have a Java server running your backend logic.