#Gautam

1 messages · Page 1 of 1 (latest)

cedar saffronBOT
severe tree
distant depot
#

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

severe tree
#

I still struggle to understand you

#

Is there a request ID that I can take a look at?

distant depot
#

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)

severe tree
#

OK, so the question is to change the API key in runtime, am I right?

distant depot
#

yes

severe tree
#

OK

#

You just need to call stripe = require('stripe')(NEW_API_KEY) to create a new instance of stripe

distant depot
#

this we are doing const stripe = require('stripe')(process.env.stripe_key);

#

on the top of js file

severe tree
#

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) 
distant depot
#

Thanks ... we could have tried it