I'm implementing stripe payment in a web application using nodejs and reactjs.
If I test my payment on localhostm everything works! But if I push same code on http://beta.mywebsite.com I got this error server side. Client side everithing seems work..
Message:
You did not provide an API key, though you did set your Authorization header to "null". Using Bearer auth, your Authorization header should look something like 'Authorization: Bearer YOUR_SECRET_KEY'. See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/
Server side
const stripeClient = stripe('sk_test*************')
stripeClient.setApiVersion('2017-06-05')
const Stripe = {
pay (payload) {
return new Promise((resolve, reject) => {
if (!payload || !isObject(payload)) throw new BadCreateRequest('Stripe: pay. Unexpected parameters.')
let { user, total, token, cartId } = payload
stripeClient.customers.create({
email: token.email,
source: token.id
})
.then(customer => {
return stripeClient.charges.create({
amount: total * 100,
currency: 'eur',
customer: customer.id,
description: `Paid from ${user.email} (${user.id})`
})
})
.then(charge => {
if (!charge) throw new BadCreateRequest()
let closeCartData = {
balanceTransaction: charge.balance_transaction,
stripeId: charge.id,
refundUrl: charge.refunds.url
}
return Cart.setAsPayed(cartId, closeCartData)
})
.then(closedCart => resolve(closedCart))
.catch(reject)
})
}
}