#jhonny_api

1 messages ¡ Page 1 of 1 (latest)

lofty jewelBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1225214612786647082

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

steep creekBOT
craggy zinc
#

Hi there! Which docs have you read so far?

royal narwhal
#

this one

#

it even created a payment and appears balance in my dashboard (test mode)

craggy zinc
#

Okay, got it. Where are you blocked exactly? The screenshot shows you created two PaymentIntents, each for $20. One of these PaymentIntents is tied to a successful charge.

royal narwhal
#

where did it get the money from

#

like, there is no customer, no bank info, no nothing

#

if I'm buying something I need to fill some infos, like my credit card info, so the money will go from my bank account to somewhere

#

in this payment intent, this doesnt happen

#

I just "magically" get the money

#

maybe I got it wrong and I'm looking for something else? @craggy zinc

craggy zinc
#

You must have passed the 4242 test card somewhere when you created this PaymentIntent

#

Could you copy/paste the PaymentIntent ID?

royal narwhal
#
  const paymentIntent = await stripe.paymentIntents.create({
    amount: 2000,
    currency: 'usd',
    automatic_payment_methods: {
      enabled: true,
    },
  });

that's the code I used

royal narwhal
#

pi_3MtwBwLkdIwHu7ix28a3tqPa

craggy zinc
#

Hold on a second. That PI is not in the screenshot you shared above

#

This appears to be one from our docs

royal narwhal
#

let me create another one

#

pi_3P1d3QHmET8UmikH1pGUjuDn

#
  const paymentIntent = await stripe.paymentIntents.create({
    amount: 2000,
    currency: 'usd',
    automatic_payment_methods: {
      enabled: true,
    },
  });

  await stripe.paymentIntents.confirm(
    paymentIntent.id,
    {
      payment_method: 'pm_card_visa',
      return_url: 'https://www.example.com',
    }
  );
craggy zinc
#

Yep, that's it. You're using one of our test PaymentMethods, pm_card_visa to confirm the PaymentIntent. This is the 4242 test card you see on the same testing page: https://docs.stripe.com/testing#cards

#

So what you've tested above is confirming a PaymentIntent with a PaymentMethod that already exists on Stripe (because the customer shared their card details with Stripe at some point prior)

royal narwhal
#

ooohh got it

#

so, how do I use an actual card?

craggy zinc
#

if I'm buying something I need to fill some infos, like my credit card info, so the money will go from my bank account to somewhere
You have a few different options for doing this. You can use Stripe Checkout, which redirects customers to a Stripe-hosted payment page, or you can use the PaymentElement to embed/add a payment module to your checkout page

royal narwhal
#

hmm, got it, but since I'm making an app with very customized screens, I want to use the API

#

my API will consume stripe and maybe other payment gateways too

craggy zinc
#

I strongly recommend using Elements (that corresponds to the "custom payment flow" tab in the guide above). This way you can add the PaymentElement to a page you own/manage and you ensure that all customer payment details are only ever shared with Stripe (payment details never touch your code)

royal narwhal
#

got it, but I really want to use the API haha

#

so... how do I create a card on paymentIntents?

craggy zinc
royal narwhal
#

is there another way?

craggy zinc
#

No, there's no other way

royal narwhal
#

oh

#

:(

craggy zinc
#

Working with raw card numbers requires additional PCI compliance so you'll have to meet the requirements mentioned in the support doc above if you plan on working with raw card numbers

royal narwhal
#

does this generates something to "save" the card?

#

I have a screen where all the user cards are listed

craggy zinc
#

Not sure I follow

royal narwhal
#

like this

#

using the elements

#

do I get those infos?

#

am I able to save the customer card?

craggy zinc
#

The PaymentElement won't list a customer's saved cards. However, you can use the PaymentElement to save cards for future use.

royal narwhal
#

hmm got it

craggy zinc
royal narwhal
#

hmm ok, I'll try it

#

thanks man!

craggy zinc
#

Sure thing, happy to help!