Can't find any information on this particular error anywhere so please bear with me.
My Angular/NodeJS app has a payment page (for monthly and annual subscriptions) handled through Stripe.
I've created the subscription types in my Stripe dashboard (two subscriptions: StarterAnnual
and StarterMonthly
), and I've set up the handler like so:
var handler = StripeCheckout.configure({
key: 'pk_test_qs8Ot1USopAZAyLN3gNXma0T',
image: '/img/stripe-logo.png',
locale: 'auto',
email: $scope.user.email,
token: function(token) {
console.log(token)
var tempObj = {
stripeToken : token,
email : $scope.user.email,
cost : $scope.plan.price * 100
plan : $scope.plan.name
}
$http.post('/api/makePayment', tempObj).then(function(data){
console.log('stripe data', data);
},function(err){
console.log('stripe error', err);
})
}
});
handler.open({
name: '<bizname>',
description: $scope.plan.name,
amount: $scope.plan.price * 100
});
In my Node route, I'm doing this:
exports.makePayment = function(req,res){
var stripeToken = req.body.stripeToken,
email = req.body.email,
cost = req.body.cost,
plan = req.body.plan;
var tempObj = {
source: stripeToken,
plan: plan,
email: email
}
console.log(tempObj); // Everything looks fine in this log
stripe.customers.create(tempObj, function(err, customer) {
if(err){
console.log("Stripe Error");
console.log(err);
}else{
console.log(customer);
res.status(200).send(customer);
}
});
}
When I try to make a payment I get:
Stripe Error
{ [Error: token is not supported.]
type: 'StripeInvalidRequestError',
stack: 'Error: token is not supported.\n at Error._Error (/node_modules/stripe/lib/Error.js:12:17)\n at Error.Constructor (/node_modules/stripe/lib/utils.js:105:13)\n at Error.Constructor (/node_modules/stripe/lib/utils.js:105:13)\n at Function.StripeError.generate (/node_modules/stripe/lib/Error.js:56:14)\n at IncomingMessage.<anonymous> (/node_modules/stripe/lib/StripeResource.js:138:39)\n at emitNone (events.js:72:20)\n at IncomingMessage.emit (events.js:166:7)\n at endReadableNT (_stream_readable.js:905:12)\n at doNTCallback2 (node.js:452:9)\n at process._tickCallback (node.js:366:17)',
rawType: 'invalid_request_error',
code: undefined,
param: 'source',
message: 'token is not supported.',
detail: undefined,
raw:
{ type: 'invalid_request_error',
message: 'token is not supported.',
param: 'source',
statusCode: 400,
requestId: 'req_7hzY3mEgeM3nNJ' },
requestId: 'req_7hzY3mEgeM3nNJ',
statusCode: 400 }
I've pretty much just used code straight out of the docs, what am I doing wrong here? Do I need to set things up differently for creating a customer when doing a subscription?