#Gautam
1 messages · Page 1 of 1 (latest)
Hi there, is it a question about API key rolling? https://stripe.com/docs/keys#rolling-keys
no .
basically ..we have two org (one for US and one for Canada)
at run time from the body we are getting the the countrycode and assigning the corresponding keys
no ..
let me ask again
we have two different org (one for US and one for Canada)
we are using stripe npm package to connect with stripe
const stripe = require('stripe')(process.env.stripe_key);
this key we are updating at run time if request is from canada or US
problem : we are not able to change this key at runtime (we are setting different keys but it is always taking the key which has assigned in beggining)
OK, so the question is to change the API key in runtime, am I right?
yes
OK
You just need to call stripe = require('stripe')(NEW_API_KEY) to create a new instance of stripe
this we are doing const stripe = require('stripe')(process.env.stripe_key);
on the top of js file
You should use let instead. You can't re-assign a const variable
So it's something like
let stripe = require('stripe')(INITIAL_KEY)
// when you change to another account
stripe = require('stripe')(NEW_API_KEY)
Thanks ... we could have tried it