#Farhaan_Kaleem

1 messages · Page 1 of 1 (latest)

snow veldt
#

Can you share your code

true prairie
#

sure

#

if (!stripe || !elements) {
// Stripe.js has not loaded yet. Make sure to disable
// form submission until Stripe.js has loaded.
return;
}

// Get a reference to a mounted CardElement. Elements knows how
// to find your CardElement because there can only ever be one of
// each type of element.
const cardNumberElement = elements.getElement(CardNumberElement);
// const cardNumberElement = elements.getElement(CardElement);

if(createToken && save_card) {
  //const stri = require('stripe')(config.stripe_pk)
  var token = await stripe.createToken({cardNumberElement})
}
snow veldt
#

Your code looks wrong, createToken expects a single argument, not a hash:

stripe.createToken(cardNumberElement)
#

Why are you using tokens anyway? They're not really the optimal integration path

true prairie
#

I need it for this curl:

curl --location --request POST 'https://api.stripe.com/v1/customers'
--header 'Authorization: Basic c2tfdGVzdF81MUc2Ukk4QWxudTdtVlNXbFF0YkVzMDJHRGxFMkNYdG9yV3A3MkJvcE51T2RsdG83NU9XZzRURFAyZ0NzWUN5M0UwODl5MXptWW80bTFkbG9YeDg1eWtHSDAwa1JQcHoxWVE6'
--header 'Content-Type: application/x-www-form-urlencoded'
--data-urlencode 'email=MasterCard@yopmail.com'
--data-urlencode 'source=tok_1LItgsAlnu7mVSWlvVI67wsR'
--data-urlencode 'name=MasterCard'

#

Is my code looking wrong what should I pass to createToken?

snow veldt
#

Right, but why are you doing that? You should be using Payment Methods instead

snow veldt
true prairie
#

cool, it started working, I am using it coz I need to save the cards.