Question

I'm in the process of integrating stripe.js into my app. I'm doing something like:

var tokenDetails = {
    number: $('#cnumber').val(),
    exp_month: $('#expmonth').val(),
    exp_year: $('#expyear').val(),
    cvc: $('#cvc').val()
};

Stripe.createToken(tokenDetails, myCallback);

This does initiate the call to stripe to create the token, however, I'm getting the following error back:

{
    "error": {
        "message": "Invalid amount. Amount must be an integer in cents.",
        "param": "amount",
        "type": "invalid_request_error"
     }
}

The docs don't say anything about needing an "amount" field to get a token for the credit card details? Is this required? In this case I'm going to take the token, then add the user to a a recurring plan with stripe. Anyone know anything about this error?

EDIT:

The callback function must be present, and I wasn't passing it correctly.

Was it helpful?

Solution

Found out the issue here. Apparently the Stripe.createToken() function takes various types of second argument. If it's a function, it's invoked as the callback to the tokenization process. If it's not a function it's assumed to be the amount (I think).

In my case, the callback function was undefined (wrong namespace) so the createToken function assumes it's an amount, which it couldn't do anything with, thus the error.

The fix...make sure the callback function exists.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top