Reputation: 3512
I just switched from Stripe's "test secret Key" to a "live secret key" as I am preparing to launch my website. The test secret key has always worked perfectly.
Now that I have the site live and am using the live secret key for some reason I am getting this error: "similar object exists in test mode, but a live mode key was used to make this request."
This is my set up:
stripe = require("stripe")("sk_live_stripelivekeyhere")
Then I charge my user's when they're creating their account as shown below:
user.save(function(err) {
console.log('this is the problem' + ' ' + err)
if(err){
return res.redirect('/buy')
}
var token = req.body.stripeToken; // Using Express
var charge = stripe.charges.create({
amount: 749,
currency: "usd",
description: "Example charge",
source: token,
}, function(err, charge) {
if(err) {
console.log(err);
return res.redirect('/buy')
}
console.log('charged')
req.logIn(user, function(err) {
if(err) {
console.log(err);
}
console.log('all looks good')
res.redirect('/results');
});
});
});
});
Upvotes: 1
Views: 6836
Reputation: 1035
This happened to me when I was copied an example and forgot to replace their publishable key with mine. Double check your keys are yours.
Upvotes: 0
Reputation: 3512
The error was I neglected to change the other test key that was located in my .js file. You must update the key in both locations.
The app.js file get's the "Live Secret Key" The yourpage.js get's the "Live Publishable key"
Upvotes: 7