#឵឵x-card-element
1 messages · Page 1 of 1 (latest)
Hi again 👋 looks like you're using the Card Element. Have you tried using this guide to walk through the implementation process?
https://stripe.com/docs/payments/accept-card-payments?platform=web&ui=elements
hi its you toby
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
😐
That's going to depend on what you're using as your backend.
😭
just a js
sample from stripe
Does that mean you're using a Node backend?
yes
Gotcha, so Node on Express. You'd direct the fetch call to URL/address of that /create-payment-intent endpoint seen on line 40.
ok but how do i do
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
I would not recommend using the token and charges integration path, it's legacy and doesn't support SCA/3DS.
// 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,
});
i think im finw with it
Alright
so can you help
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
Sorry, very few people use this path now, so I need a moment to brush up on it.
As you can see in line 3, it's pointing to the payment-form created in Step 2
og i know
but like
ik*
how do i know its gonna send
to my api
oh
@plucky fern so what i have to do
is define that before
my element
and then its just good?
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.
wait i think i found it
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
stripeTokenHandler(result.token.id);
i think thats it
Your card was declined. Your request was in live mode, but used a known test card.
maybe its working
you should make sure youre doing all your testing with test keys only
oh
😐
okok so i
im using test
im not getting the response
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
what response? can you share a request ID thats not working?
https://stripe.com/docs/api/request_ids
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh sorry
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
you should test in test mode using teh test cards we provide: https://stripe.com/docs/testing
ok so it creates a token
but it does not do what i want it to do
what are you trying to do?
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
okok so i had it
and it redirected to /charge
instead of
posting
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
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
now im trying to submit the token
what docs? what commands are you calling?
how are you submitting that? to stripe via the api? to your own server?
using my own api
to submit a token to stripe
and you have a failing Stripe API request?
what is the request id? https://stripe.com/docs/api/request_ids
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.