Accept a card payment with React Stripe.js

Поделиться
HTML-код
  • Опубликовано: 27 авг 2024
  • Learn the front end steps for accepting a payment with a card from your customers using a custom form in a React application. You'll learn how to use the CardElement component and how to use the confirmCardPayment method from Stripe.js to securely confirm a PaymentIntent client-side. This method handles 3D Secure and Secure Customer Authentication (SCA).
    Watch one of these episodes to learn the server side steps required to create a PaymentIntent using the Stripe API with one of the officially supported client libraries:
    Ruby - • Accept a payment - Cre...
    Python - • Video
    Node.js - • Accept a payment - Cre...
    Go - • Accept a payment - Cre...
    Java - • Accept a payment - Cre...
    .NET - • Accept a payment - Cre...
    PHP - • Accept a payment - Cre...
    Want to see how to implement with a different client?
    HTML and JavaScript - • Accept a card payment ...
    iOS - • Accepting card payment...
    Android - • Accept a card payment ...
    Presenter
    CJ Avilla - Developer Advocate at Stripe - / cjav_dev
    Resources
    Getting started with React Stripe.js: • Getting started with R...
    Stripe.js documentation: stripe.com/doc...
    Accept a payment documentation: stripe.com/doc...
    Code: github.com/str...
    Table of contents
    00:45 Confirm the server is working as expected
    02:00 Add a new payment form
    03:52 Add the CardElement component
    05:57 Add useElements and useStripe hooks
    06:36 Create PaymentIntent on the server
    08:07 Add StatusMessages helper component
    09:48 Confirm with confirmCardPayment
    12:21 View successful payment in the dashboard
    13:00 Test 3D Secure and Secure Customer Authentication card
    14:12 Add error handling
    15:40 Review
    Support
    If you have a question, please feel free to reach out to our support team on Discord at stripe.com/go/....
    Updates
    Sign up to stay updated with developer news: go.stripe.glob...
    Feedback
    If you have any feedback about this or other episodes, let us know: forms.gle/VjNq....
    #Stripe #Payments

Комментарии • 55

  • @TheBeatBen
    @TheBeatBen 10 месяцев назад +1

    It's awesome!
    I wish all the tutorial vids are like this.
    Cool lector we got here. :)

    • @StripeDev
      @StripeDev  10 месяцев назад

      Thanks for your kind words! We're glad that you find these tutorials helpful.

  • @mattiapalmese2971
    @mattiapalmese2971 2 года назад

    This man is going super saiyan, thank you for the video. Amazing.

  • @StripeDev
    @StripeDev  2 года назад +2

    Hi Akash, this documentation about placing a hold on a card may help answer your question: stripe.com/docs/payments/capture-later

    • @akashsamuel5298
      @akashsamuel5298 2 года назад

      and the card element looks simple how to customize it?

    • @StripeDev
      @StripeDev  2 года назад +1

      You can find more information on customising elements here: stackoverflow.com/questions/47097403/how-to-customize-credit-card-form-in-stripe and stripe.com/docs/js. Let us know if these help answer your question.

  • @StripeDev
    @StripeDev  2 года назад +1

    Hey there, the provider component is used around the 11:09 mark (ruclips.net/video/IhvtIbfDZJI/видео.html), and is required. You can read more here: stripe.com/docs/stripe-js/react#elements-provider.

  • @StripeDev
    @StripeDev  2 года назад

    Hi there! Sorry about that, you can find it here: github.com/stripe-samples/accept-a-payment/blob/main/custom-payment-flow/client/react-cra/src/Card.js

  • @victorcesardepaularangel2016
    @victorcesardepaularangel2016 2 года назад +1

    What if i'm not using the stripe elements?

  • @clamgts
    @clamgts 2 года назад +1

    Can you guys please make a tutorial for implementation on backend only and testing with postman. Its ridiculous for me to build a small frontend just for the sake of testing Stripe. I literally cant find a tutorial anywhere that covers this.

  • @morrismenanya9059
    @morrismenanya9059 Год назад

    This is very confusing. how are you able to pass the amount in eur. I am seeing EUR19.99

  • @StripeDev
    @StripeDev  2 года назад

    Hey Jason! Glad you found this helpful-the UI is actually pre-built in the React Stripe.js library: github.com/stripe/react-stripe-js

  • @coreyhansen447
    @coreyhansen447 2 года назад

    I am confused as to where the price is coming from.
    I notice you don't specify a price id anywhere or a specific dollar amount.
    Does your specific stripe public key specify just a single available item available to purchase?
    In other implementations of stripe a price_id is required...

    • @StripeDev
      @StripeDev  2 года назад +1

      Hey Corey, thanks for reaching out. You can find the code used in the tutorial here: github.com/stripe-samples/accept-a-payment/blob/main/custom-payment-flow/client/react-cra/src/Card.js. This code doesn't include 'price', but does include the amount, which is specified in this backend code here: github.com/stripe-samples/accept-a-payment/blob/main/custom-payment-flow/server/node/server.js#L55 as '5999'.
      As for your third question, the publishable key is not tied to a particular purchasable item. For instances where a price_id is required, one such instance is for the creation of checkout sessions. You can find an example of this here: github.com/stripe-samples/accept-a-payment/blob/main/prebuilt-checkout-page/server/node/server.js#L54.
      Hope this helps, but let us know if you have any other questions!

  • @TheJason118511
    @TheJason118511 2 года назад

    Hey man! thanks for the helpful vid, how'd you get your form and everything to display so nicely? I didn't see you add any css, just wondering why yours is so great out of the box

    • @vsowill
      @vsowill 2 года назад

      Put the form in a div then style the div with padding and a shadow.

  • @23pointblank
    @23pointblank Год назад

    the 3184 test card does not bring up the modal. What should i be looking at?

    • @StripeDev
      @StripeDev  Год назад

      Hi Felix! We'd love to help you out here, could you give us a little more context on the problem you're facing?

  • @TheBeatBen
    @TheBeatBen 10 месяцев назад

    In this example we have "CardElement". But if I want to setup my form myself with separate CVC code, expiration date.
    What should I provide to payment method then?

    • @StripeDev
      @StripeDev  10 месяцев назад

      Hi there-to make sure we have a clearer understanding of your current integration, can you please contact us through support.stripe.com and we can assist you with this further?

  • @worthyvibes9989
    @worthyvibes9989 Год назад

    where is the backend of this '/config' and '/create-payemnt-intent'

  • @akashsamuel5298
    @akashsamuel5298 2 года назад

    how can I authorize a payment now and capture the amount after a specific time?

  • @ratnabhkumarrai5594
    @ratnabhkumarrai5594 2 года назад

    Hi, the "create-payment-intent" endpoint is our own custome endpoint or the stripe api which sents back the clientSecret key ?

    • @shubhendusen2
      @shubhendusen2 Год назад

      Yes, this video assumes that part is already completed by the user

  • @redrum884
    @redrum884 Год назад

    How can we know which user is creating a payment Intent? Can we send the customer info while creating a payment Intent ?

    • @StripeDev
      @StripeDev  Год назад

      Hey there-great question! You can use the "customer" parameter, which would contain the customer ID of the user. You can find more details on this here: stripe.com/docs/api/payment_intents/object#payment_intent_object-customer

    • @redrum884
      @redrum884 Год назад

      @@StripeDev I am creating a application in which user can pay one time with the help of stripe. For my understanding first we have to create customer and then payment intent and attached that paymentIntent to created a customer. But I am finding some way
      if a create a paymentIntent along I can send the customer info and stripe will create a user and attached the paymentIntent for me.

    • @StripeDev
      @StripeDev  Год назад

      You would need to have created a Customer object before the parameter could be attached to the PaymentIntent, as the customer parameter for PaymentIntents only contains the customer ID itself, not any other details for the customer. These other details would be contained within the Customer object. You'll find more details about creating Customer objects here: stripe.com/docs/api/customers/create.

  • @milanm2605
    @milanm2605 2 года назад

    How do you attach a customer? When showing the dashboard the customer had the value of "None".
    Isn't a payment without customer info pretty useless?
    I mean, surely you would need the name, e-mail, address and so on so you know who to contant or where to send the product.

    • @StripeDev
      @StripeDev  2 года назад

      Hey Milan! Can you please tell us a little more about what you're trying to do with Stripe, and what issues you're running into? We're happy to help.

    • @LegacyUntouched
      @LegacyUntouched 2 года назад

      I dont know if this helps, but I think it's just because we never attached a customer to the payment. Whenever I build a site, I typically have a login/signup that stores my customer into a DB (just the customer, no payment info).
      then when the customer makes a payment, they get all info generated and is displayed on their dashboard and a successful payment is then sent to me with the customer based on the database ID for easy lookup.
      I may be explaining it wrong as I'm still a JR and primarily work on front end but I'd imagine here we just don't have any customer information because a customer hasn't been built at all.

  • @ikrommurodov6639
    @ikrommurodov6639 Год назад

    thanks

  • @dhavalprajapati2084
    @dhavalprajapati2084 2 года назад

    I want the source code of this implementation sir, where can I find this? I have tried to access through GitHub URL but it isn't available there

    • @StripeDev
      @StripeDev  2 года назад +1

      Hi there! Sorry about that, you can find it here: github.com/stripe-samples/accept-a-payment/blob/main/custom-payment-flow/client/react-cra/src/Card.js

    • @dhavalprajapati2084
      @dhavalprajapati2084 2 года назад

      @@StripeDev Thanks sir for your kind and Instant Reply

  • @tszchunlau5643
    @tszchunlau5643 2 года назад

    is it possible to add card holder name or email text field ? since i want to make a record

    • @StripeDev
      @StripeDev  2 года назад

      Hey! Can you tell us a bit more about what you're trying to do? Where do you want to add the card holder name and what do you mean by 'email text field'?

    • @tszchunlau5643
      @tszchunlau5643 2 года назад

      @@StripeDev actually I want to know who pay for me , but seems like here’s only have card number I know I want to know who pay me according to email

    • @StripeDev
      @StripeDev  2 года назад

      Thanks for getting back to us. It seems what you're looking for might be here: stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-customized_fields
      We do also have a React document here, if it helps: stripe.com/docs/stripe-js/react

  • @omaralexandro2928
    @omaralexandro2928 3 года назад

    Integration with Angular please!

  • @iamdhison
    @iamdhison 2 года назад

    Hello, thank you for awesome video. I am currently building a website same like Airtasker or Airbnb where I need to collect booking payments from customer and then after the job completes, I need to deduct my service fee and pay to the tasker in their AU bank account.
    Could you please help me with this scenario how to achieve?
    Thanks heaps!

    • @StripeDev
      @StripeDev  2 года назад +1

      Hi Dhiraj, this page shows how you can split funds between your platform and your connected account by creating charges.
      This page is helpful for those who want to create marketplaces and pay out money to service providers: stripe.com/docs/connect/charges

  • @StripeDev
    @StripeDev  2 года назад

    Hi Ratnab, yes, this would be a function/route in your own server implementation, which would call the Stripe API using your secret keys. You can find an example of this here: github.com/stripe-samples/accept-a-payment/blob/main/custom-payment-flow/server/node/server.js#L40.

  • @Frank-wb2ds
    @Frank-wb2ds 3 года назад

    What is the name of this VScode theme!?

  • @munawarbasha2799
    @munawarbasha2799 2 года назад

    Hi, very helpful video. Can you help me stripe with ACH using react?

    • @StripeDev
      @StripeDev  2 года назад

      Hi there-would you mind expanding on what you need help setting up?

    • @munawarbasha2799
      @munawarbasha2799 2 года назад

      @@StripeDev we need to accept payments via card and ACH bank accounts of US, as part of it i am clear on how to accept payment via card but not clear with ACH...i am using React in Frontend and Java in backend

    • @StripeDev
      @StripeDev  2 года назад

      You can use Sources, a single integration path for creating payments using any supported method.
      We also have documentation here: stripe.com/docs/sources/ach-credit-transfer

  • @emeryd7432
    @emeryd7432 3 года назад

    Hello could you add the source code on git , please ?

    • @cjav_dev
      @cjav_dev 3 года назад

      Hey Emery, the git repo is linked in the description.

    • @theonethatprotectsyoufromt9271
      @theonethatprotectsyoufromt9271 2 года назад +3

      @@cjav_dev The link to github in the description leads to 404 page. Please add a working link.

  • @jovietrostky
    @jovietrostky 2 года назад

    Your too strong

  • @StripeDev
    @StripeDev  3 года назад +1

    Hey Emery, we'd recommend checking out github.com/stripe-samples/accept-a-payment/tree/main/custom-payment-flow/client which has multiple clients and the servers as well for more info!