#bear-checkout-error

1 messages · Page 1 of 1 (latest)

dreamy shuttleBOT
civic cradle
#

@proven gale Hello! I'm happy to help but I'm going to need more details. Exact code and exact request id req_123 for the error

proven gale
#

Sure, thanks

#

`import * as React from "react";
import Stripe from "stripe";
import axios from "axios";
import { NextResponse, NextRequest } from "next/server";

export async function POST (request) {
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY)
let data = await request.json()
let priceId = data.priceId
let subscriptionTier = data.subscriptionTier
let reportCredits = data.reportCredits
let liveSubscription = data.liveSubscription
let hasAccount = data.hasAccount
let subscriptionUpgrade = data.subscriptionUpgrade

const session = await stripe.checkout.sessions.create({
    line_items: [
      {
        price: priceId,
        quantity: 1
      }
    ],
    mode: 'subscription',
    success_url: `http://localhost:3000/success`,
    cancel_url: `http://localhost:3000/pricing`,
    subscription_data: {metadata:  
      { 'subscriptionTier':  subscriptionTier,
       'amount' : reportCredits,
       'liveSubscription' : liveSubscription,
       'hasAccount': hasAccount,
       'subscriptionUpgrade': subscriptionUpgrade
                                }},
  });

  return N`extResponse.json(session.url)

}

#

That is the route.js

#

could you elaborate and what you mean by req_123

civic cradle
#

when you get an error in our API, you also usually get a clear error message and request id req_123 or a Dashboard URL to see that error

proven gale
#

request _log _url?

civic cradle
#

Okay so if you load that URL in the Dashboard, you'll see all your parameters. And you can see that you never sent a Price id in the price parameter. I assume the priceId variable is empty. Log it first and you can easily confirm

proven gale
#

Ok I've got it now,

#

thanks for your time, useful to know about the dashboard link

civic cradle
#

yeah it's super powerful to debug things quickly.

#

I've flagged internally to fix the error message, it should ask you about the Price id instead