#Thesingh - invalid stripe version

1 messages · Page 1 of 1 (latest)

hollow glade
#

Hello. Give me a moment to catch up on threads and I'll be right with you

rough rune
#

ok

#

available?

hollow glade
#

Yes

#

Am in many threads. Ok ready

#

Can you share more details about the error?

#

Including any request IDS

rough rune
#

export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: "2020-08-27",
});

#

this is what the apiversion I am using ,that i got from my stripe dashboard

#

..getting error as I said above

#

When I try to create a session

hollow glade
#

Try setting it like this: const stripe = require('stripe')('sk_123', { apiVersion: '2020-08-27', });

rough rune
#

ok I try this

#

error ..remains the same

hollow glade
#

Interesting. Ok one moment

rough rune
#

but i am using es6

hollow glade
#

Looking

#

IE6?

rough rune
#

ES6 module in js

hollow glade
#

Ok. Asking a colleague

#

What version of stripe-node are you using? Older versions need to use api_version instead of apiVersion

rough rune
#

Ok now that error got cleared ...thank you..now facing another issue

#

import { stripe } from '../server.js';
import Stripe from 'stripe';
import asyncHandler from 'express-async-handler'
import Order from '../models/orderModel.js';
import { response } from 'express';

export const createStripeCheckoutSession=asyncHandler(async(req,res,next) => {

//get currently ordered products
const order = await Order.findById(req.params.id)

console.log(req.body.line_items)
const line_items=req.body
// console.log(req.body.body.line_items)

const url = http://localhost:3000;

const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
success_url: ${url}/success?session_id={CHECKOUT_SESSION_ID},
cancel_url: ${url}/failed,
// customer_email:req.user.email,
customer_email:'rajasinghplkm@gmail.com',
client_reference_id:req.params.id,
line_items:[
{
name:'asdf',
description:'qwerty',
images:['https://images.unsplash.com/photo-1612817288484-6f916006741a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80'],
amount:'700',
currency:'inr',
quantity: 1,
}
]

});

response.status(200).json({
status: 'success',
session
})
})

#

when I call this function...I am getting below error

#

TypeError: Cannot read properties of undefined (reading 'get')\n

inland matrix
#

Hello 👋
Stepping in for @hollow glade here
Which function are you calling? Sorry the code is too abstract.