#឵឵x-card-element

1 messages · Page 1 of 1 (latest)

plucky fern
broken ore
#

I did it

#

it creates a token

#

here is my code

#
  if (result.token) {
    // Use the token to create a charge or a customer
    // https://stripe.com/docs/charges
#

where it says that

#

how would i fetch the backend

#

to make a payment intent

#

i also

#

got a modal to wrok

#

work*

#

i dont know how to run sccss on github pages though

#

😐

plucky fern
broken ore
#

😭

broken ore
#

sample from stripe

plucky fern
#

Does that mean you're using a Node backend?

broken ore
plucky fern
#

Gotcha, so Node on Express. You'd direct the fetch call to URL/address of that /create-payment-intent endpoint seen on line 40.

broken ore
#

in the codepen

#

or on my server

#

wait so

#

what do i use the token for

#

wait wait

#

so how do i submit to server

plucky fern
#

I would not recommend using the token and charges integration path, it's legacy and doesn't support SCA/3DS.

broken ore
#

// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

// Token is created using Stripe Checkout or Elements!
// Get the payment token ID submitted by the form:
const token = request.body.stripeToken; // Using Express

const charge = await stripe.charges.create({
  amount: 999,
  currency: 'usd',
  description: 'Example charge',
  source: token,
});
plucky fern
#

Alright

broken ore
#

okok so

#

i have the token

#

what i dont get is

#
function stripeTokenHandler(token) {
  // Insert the token ID into the form so it gets submitted to the server
  var form = document.getElementById('payment-form');
  var hiddenInput = document.createElement('input');
  hiddenInput.setAttribute('type', 'hidden');
  hiddenInput.setAttribute('name', 'stripeToken');
  hiddenInput.setAttribute('value', token.id);
  form.appendChild(hiddenInput);

  // Submit the form
  form.submit();
}
#

its submitting something

#

but to what form

plucky fern
#

Sorry, very few people use this path now, so I need a moment to brush up on it.

plucky fern
broken ore
#

but like

#

ik*

#

how do i know its gonna send

#

to my api

plucky fern
#

It's specified by the action attribute on the form

broken ore
#

oh

#

@plucky fern so what i have to do

#

is define that before

#

my element

#

and then its just good?

sonic zephyr
#

hey there just stepping in for @plucky fern here and catching up

#

What exactly are you struggling with here @x#5859? Can you be precise about the issue you're having with Stripe.js? This sounds like you're having trouble with general form submission/js, not any of the stripe-specific pieces.

broken ore
#

so in my

#

card

#

my modal

#

i just have to put it in a form

#

that requests kajdlkja/api/charges

#

then i have to

#

put that other stuff in the js

#

man

#

idk how to tell if its working

broken ore
#

i think thats it

#

Your card was declined. Your request was in live mode, but used a known test card.

#

maybe its working

sonic zephyr
#

you should make sure youre doing all your testing with test keys only

broken ore
#

😐

#

okok so i

#

im using test

#

im not getting the response

sonic zephyr
#

its against the terms of service to conduct test transactions in live mode, but you should reach out to support if you have questions about that

broken ore
#

i didnt know

#

im using my credit card

#

so is it still against rules its a prepaid card i bought from the gas station

#

im on test mode now

sonic zephyr
broken ore
#

but it does not do what i want it to do

sonic zephyr
#

what are you trying to do?

broken ore
#

i add a

#

class in

#

a div

sonic zephyr
#

yes, but i dont see how thats related to your stripe code. i think you need to spend more time with your application logic in general and figure out what your goals are and where things are not behaving as you expect, what might be causing that

broken ore
#

and it redirected to /charge

#

instead of

#

posting

sonic zephyr
#

ti would also be more helpful for you to slow down, assess your issues, and communication the scenario for fully to us, we can't know what youre working on and these short messages do not share the context we'd need to be able to help

broken ore
#

ok so im followiung the dev docs*

#

following*

#

i have made a token

sonic zephyr
#

so please do some debugging, work at it, and if you hit an issue with the stripe-related parts of your code, we'd be happy to help you figure that out when you share a snippet, what you're trying to have it do, and what's going wrong

broken ore
#

now im trying to submit the token

sonic zephyr
#

what docs? what commands are you calling?

#

how are you submitting that? to stripe via the api? to your own server?

broken ore
#

to submit a token to stripe

sonic zephyr
#

and you have a failing Stripe API request?

broken ore
#

im gonna take a break and debug

#

because its a error on my part

#

you can close this thread i will get back to you guys when its a stripe one