#Abdul Shakoor

1 messages ยท Page 1 of 1 (latest)

lethal oracleBOT
echo hatch
#

Hi ๐Ÿ‘‹

You are creating a Token from raw card numbers? Are you using Stripe.js?

Quoting your message:

here is my code
Stripe.setPublishableKey($form.data('stripe-publishable-key'));
Stripe.createToken({
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val()
}, stripeResponseHandler);

#

This code looks like it is a server-side language

ornate oak
echo hatch
#

That isn't an API version. That is our JavaScript library

ornate oak
#

yes its is server side

echo hatch
#

Which is not server side

#

Your code looks like PHP to me

#

Wait...no because your createToken parameters aren't using PHP

ornate oak
#

i have used this code in javascript .blade file but want to tell one thing same code working using v2 library

echo hatch
#

Do you have request IDs I can review?

ornate oak
#

no i dont have a request id

#

can you please tell me where can i find so i can share with you

echo hatch
#

The link I provided tells you how to find your API requests and their IDs

ornate oak
#

got it

#

do you need reponse body?

#

Request ID : req_5PRYyJ0gXDYJzK

echo hatch
#

Thanks

#

The parameters passed in the card element is empty. here

ornate oak
#

but the error i am getting is on creating token: TypeError: Stripe.setPublishableKey is not a function

echo hatch
ornate oak
#

i have already tried this approach lemme try again

ornate oak
#

this is the form i am using and when tried initializing approach getting some different error:

You must provide a Stripe Element or a valid token type to create a Token.

echo hatch
#

Okay that form ins't anything Stripe controls. Can you show me your JavaScript code that is throwing the error?

ornate oak
#

one more thing its working with v2 library why its not working with v3

echo hatch
#

What code are you referring to?

ornate oak
#

same code i have share up

#

this code

echo hatch
#

What is the exact code and what is the entire contents of the error message

ornate oak
#

var stripe = Stripe($form.data('stripe-publishable-key'));

                stripe.createToken({
                    number: $('.card-number').val(),
                    cvc: $('.card-cvc').val(),
                    exp_month: $('.card-expiry-month').val(),
                    exp_year: $('.card-expiry-year').val()
                }, stripeResponseHandler);
echo hatch
#

And what throws the error?

ornate oak
lethal oracleBOT
echo hatch
#

Right, you need to pass everything in the .createToken inside a ({card:{}}) object

ornate oak
ornate oak
#

is this correct now:
var stripe = Stripe($form.data('stripe-publishable-key'));

                stripe.createToken({
                    card: {
                        number: $('.card-number').val(),
                        cvc: $('.card-cvc').val(),
                        exp_month: $('.card-expiry-month').val(),
                        exp_year: $('.card-expiry-year').val()
                    }
                }).then(function(result) {
                    if (result.error) {
                        // Handle token creation error
                        console.error(result.error.message);
                    } else {
                        // Token created successfully, send it to your server for further processing
                        var token = result.token.id;
                        stripeResponseHandler(token);
                    }
                });
lethal oracleBOT
ornate oak
#

tried this code and getting new error :

floral ether
#

๐Ÿ‘‹ catching up and stepping in for my teammate!

#

If you eventually want to accept other payment methods (ACH, other bank debits, buy now pay later methods), I recommend moving over to using the PaymentElement instead

ornate oak
#

can i create all these fields in card elemnt lik country etc.?

floral ether
#

The card element will only collect card number, expiration date, and cvc. If you want to collect other billing details, you can but you'd need to use your own custom input fields for those.

ornate oak
#

ok thanks for your time, I have a last question in library version 2 its working directly why its not working in version 3 ?

floral ether
#

I'm not sure without digging deeper but honestly, I recommend using the Card Element instead since that's a more secure route overall

ornate oak
#

ok @floral ether