#nikivi

1 messages · Page 1 of 1 (latest)

delicate garnetBOT
#

Hello nikivi, we'll be with you shortly! Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
nikivi, 2 hours ago, 19 messages
nikivi, 3 days ago, 224 messages
nikivi, 3 days ago, 68 messages

pastel bone
#

Hello

#

Where do you see that error exactly?

#

And are you using a plugin here?

delicate garnetBOT
tame lodge
#

is error i see

#
import { Context } from "@grafbase/sdk"
import { GraphQLError } from "graphql"
import Stripe from "stripe"
import { hankoIdFromToken } from "../lib/hanko-validate"
import { log, logError } from "../lib/baselime"

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
  apiVersion: "2023-08-16",
  typescript: true
})

type StripePlan = "month" | "year"

export default async function StripeResolver(
  root: any,
  args: { plan: StripePlan; userEmail: string },
  context: Context
) {
  log("stripe", "trying to get stripe checkout", { args })
  const hankoId = await hankoIdFromToken(context)
  if (hankoId) {
    try {
      switch (args.plan) {
        case "month":
          const monthSubscription = await stripe.checkout.sessions.create({
            success_url: process.env.STRIPE_SUCCESS_URL!,
            mode: "subscription",
            metadata: {
              userEmail: args.userEmail
            },
            line_items: [
              {
                quantity: 1,
                price: process.env.STRIPE_MONTH_SUBSCRIPTION!
              }
            ]
          })
          return monthSubscription.url
        case "year":
          const yearSubscription = await stripe.checkout.sessions.create({
            success_url: process.env.STRIPE_SUCCESS_URL!,
            mode: "subscription",
            metadata: {
              userEmail: args.userEmail
            },
            line_items: [
              {
                quantity: 1,
                price: process.env.STRIPE_YEAR_SUBSCRIPTION!
              }
            ]
          })
          return yearSubscription.url
        default:
          return {
            stripeCheckoutUrl: null
          }
      }
    } catch (error) {
      logError("stripe", error, { args })
      throw new GraphQLError(JSON.stringify(error))
    }
  } else {
    logError("stripe", "not a member", { args })
    throw new GraphQLError("not member")
  }
}

#

on this code

#

I have process.env.STRIPE_SECRET_KEY set correctly

#

or actually

#

going to test something

#

yea its 100% correct

#

double checked

#

yet it fails verification

pastel bone
#

"Verification failed" is not an error from our API to be clear

#

But what I would recommend doing next is hardcoding your key

#

And see if you see the same error or not

#

And then find exactly what is throwing that error

tame lodge
#

ohh

#

i see where error comes from now

#
  } catch (err) {
    throw new GraphQLError("Verification failed")
  }
#

in some other part of code

#

will resolve