Next.js + Springboot with Payment Widget SDK

Hi everyone.

I am having some trouble coming up with a solution for my Next.js Frontend and Springboot Backend. I want the payment to be confirmed in my springboot backend when the payment request is succeeded from toss. Previously, I was doing this with the successUrl parameter in the requestPayment method (shown below). However, I don't want to expose my endpoints so that anyone can call it. I only want toss to be able to call my endpoint. I was thinking of using an api key, but i have no clue how i might be able to do this without exposing the key to the browser in the nextwork tab when the method is called. The last thing i want to happen is people going in and confirming a bunch of orders that were not paid.

await paymentWidget?.requestPayment({
                orderId: order,
                orderName: "order for " + name,
                customerName: name,
                customerEmail: email,
                customerMobilePhone: phoneNumber,
                successUrl: `${window.location.origin}/api/orders/confirm/${order}`,
                failUrl: `${window.location.origin}/api/orders/fail/${order}`,
              });
Was this page helpful?