Below is the calling function
function getToken(data, TokenData) {
var stripe = Stripe(data.StripeID), // Check
c = {
"number": data.Cardnum,
"cvc": data.Cvv,
"exp_month": data.Expiry.getMonth() + 1,
"exp_year": data.Expiry.getFullYear(),
"name": data.NameOnCard,
"currency": data.CurrencyCulture
};
stripe.createToken(c, (status, result)=>{
if (result.error) {
alert(result.error.message);
}
else {
data.stripToken = result.token;
return TokenData(data);
}
});
}
The error I get in the console: Uncaught IntegrationError: You must provide a Stripe Element or a valid token type to create a Token.
I'm not sure about the card object. I'm using stripe.js v3.
When using Stripe.js v3, you do not pass card details directly to the createToken
function.
Instead, you need to pass in the instance to your "card" element (created from Stripe Elements): https://stripe.com/docs/js/tokens_sources/create_token?type=cardElement
More here on how to set up Stripe Elements: https://stripe.com/docs/payments/accept-a-payment#set-up-stripe-elements
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.