#pkdiscgolf_checkout-jsonerror

1 messages ¡ Page 1 of 1 (latest)

ruby wyvernBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1278820506186944554

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

brazen veldt
#

"json object requested, multiple or no rows returned' this is not a Stripe thing at all

#

@gleaming lotus I'm going to need more details from you about what exactly in your code (With the code) returns this, but it's not Stripe

gleaming lotus
#

Looks like this. Seems like the error is coming from stripe when I create the checkout session in the catch

brazen veldt
#

Ack, just for future asks, please don't just share a picture of your code if possible. Share real code here as text instead.

My guess is that the error has nothing to do with Stripe and it's catching an exception from the beginning of the code where you are hitting your database. Our API would never return this

gleaming lotus
#

router.post("/", requireAuth, async (req, res) => {

console.log('stripe create checkout session')
console.log('api/stripe-create-checkout-session.js')
const body = req.body;
const user = req.user;

console.log('body', body)
console.log('user', user)

// if (!body.priceId) {
// return res.status(400).send({
// status: "error",
// message: "No priceId is defined in request body",
// });
// }

try {
const { email } = await getUser(user.id);
let { stripeCustomerId } = (await getCustomer(user.id)) || {};

// If user is not a customer then create a customer in Stripe
if (!stripeCustomerId) {
  const customer = await stripe.customers.create({ email: email });

  await createCustomer(user.id, {
    stripeCustomerId: customer.id,
  });

  stripeCustomerId = customer.id;
}

// Create a checkout session
const session = await stripe.checkout.sessions.create({
  customer: stripeCustomerId,
  payment_method_types: ["card"],
  line_items: [
    {
      // price: body.priceId,
      // quantity: 1,
      price_data: {
        currency: 'USD',
        unit_amount: body.totalCharge,
        product_data: {
          name: 'entry',
          description: body.entryDescription,
        }
      },
      quantity: 1,
    },
  ],
  metadata: body.metadata,
  mode: 'payment',
  success_url: body.successUrl,
  cancel_url: body.cancelUrl,
});

// Return success response
res.send({ status: "success", data: session });

} catch (error) {
console.log("stripe-create-checkout-session error", error);

// Return error response
res.send({ status: "error", code: error.code, message: error.message });

}

});

brazen veldt
#

Try adding logs throughout the code before/after each call to our API. I'm confident you are "crashing" before those calls are reached

#

pkdiscgolf_checkout-jsonerror