Accept a payment with the Payment Element using PHP

Поділитися
Вставка
  • Опубліковано 2 лис 2024

КОМЕНТАРІ • 36

  • @jlcontarino
    @jlcontarino 2 місяці тому

    Really clear and complete explanation of this Stripe feature. Actually far better, practical and more concise than their documentation!

  • @timurgafforov8856
    @timurgafforov8856 8 місяців тому +1

    Thanks a lot for the tutorial. Though, it would be nice to have this exact code you've written downloadable. I know there are enough samples provided in GitHub, but it really simplifies when you just have such step-by-step instructions for a downloadable code. One wouldn't have to look for chunks of required code or type them manually. Not critical, but, I think, a valid suggestion.

    • @senju31
      @senju31 3 місяці тому

      I agree.

  • @MattBarraud
    @MattBarraud 11 місяців тому

    This is a great tutorial, thank you - I do have a question, how do I also add the users name, email and a short description of the payment? I believe I need to create the customer first - then the intent? How does that work in this workflow?

    • @StripeDev
      @StripeDev  11 місяців тому +1

      Hi Matthew-this tutorial specifically covers one-time payments. If you need to add a customer for recurring payments, you can do so through the API or the Dashboard: stripe.com/docs/billing/customer.
      You might find our documentation on getting started helpful for setting up this workflow: stripe.com/docs/payments/accept-a-payment.

  • @chrispaul4090
    @chrispaul4090 Рік тому

    Regarding currencies, how do I enable multiple currency option?

    • @StripeDev
      @StripeDev  Рік тому

      Hi Chris, have a look at our multiple currency doc here: stripe.com/docs/connect/currencies. Any further questions, feel free to get in touch using support.stripe.com. Thanks.

  • @fustibal
    @fustibal Рік тому

    My customer sells tickets in the US for us events and sells tickets in Mexico for MX events. Will the exchange rate be done automatically to dollars if a ticket is sold in Mexico?

    • @StripeDev
      @StripeDev  Рік тому

      Hey Mario-are you speaking about Automatic Currency Conversion: support.stripe.com/questions/automatic-currency-conversion-pricing?
      Otherwise, this doc has more information about currency conversions: stripe.com/docs/currencies/conversions.

    • @fustibal
      @fustibal Рік тому

      @@StripeDev Yes, this makes sense. What are the requirements to have an elegible account to have ACC enabled?

    • @StripeDev
      @StripeDev  Рік тому +1

      This feature is currently limited to beta users, but you can enter in your email at the bottom of this page if you're interested in participating: stripe.com/docs/payments/checkout/present-local-currencies#:~:text=Automatic%20currency%20conversion%20allows%20you,needing%20to%20update%20your%20integration.

    • @fustibal
      @fustibal Рік тому

      @@StripeDev Thank you for the fast answers.

  • @sensingturtle
    @sensingturtle Рік тому

    This was a fantastic tutorial. Thank you so much :)

  • @jamesr2408
    @jamesr2408 Рік тому

    I have test-mode pair of publishable and secret keys, but where to get the webhook secret? Is it generated when creating endpoints? Would that be in test mode or the live? Also in the video, the publishable and secret keys, are in quote marks as in Strings, but not in the generated code.

    • @StripeDev
      @StripeDev  Рік тому

      We'd be happy to explain this further. Feel free to chat with us on Discord at stripe.com/go/developer-chat

    • @jamesr2408
      @jamesr2408 Рік тому

      @@StripeDev Thanks for the discord link. I will use it in the near future. But for now, having ./stripe login done, the regenerated the started project, and .env was properly populated with the keys in quote marks. As a bonus, the webhook key was there too. THANKS AGAIN.🙂

  • @StripeDev
    @StripeDev  Рік тому

    Hey there-good question! You can take a look at how to create charges which will generate a charge ID here: stripe.com/docs/api/charges/create. You'll also find more information on how to retrieve charges using the charge ID a bit further down.

    • @tiydosoft
      @tiydosoft 10 місяців тому

      Hi there,
      This tutorial is really helpfull. I need to know one more think. I want to set the customer name but they maybe a guest user! So how can I do this?
      is there any parameter to add the guest customer name??
      $paymentIntent = $stripe->paymentIntents->create([
      'amount' => $amount,
      'currency' => $currency,
      'automatic_payment_methods' => ['enabled' => true],
      // 'customer' => $customer,
      'description' => $description,
      'receipt_email' => $receipt_email,
      'metadata' => [
      'u_id' => $u_id,
      'o_id' => $o_id,
      ],
      ]);
      Thank you!

  • @aliyufari
    @aliyufari Рік тому

    Great, but how can I add input to the form to collect user email and so on. And how to handle that in the back end.

    • @StripeDev
      @StripeDev  Рік тому

      Hey there-great question! Could you please elaborate on this so that we can better answer your question?

    • @StripeDev
      @StripeDev  Рік тому

      So, we dug a little deeper from what we could grasp out of your question. The email address mentioned here: stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields-billingDetails-email, if set to `auto` will only show as an input field when the PaymentMethod requires collecting it i.e. it will not always be displayed as an input field.
      What you can try is implementing the input field yourself and passing that in as part of the billing_details when confirming the PaymentIntent or SetupIntent. If you're implementing your own input field to collect the email address, you'll likely want to set it such that the Payment Element never collects the email.
      Alternatively, if you're willing to integrate with Link, you can take a look at this guide: stripe.com/docs/payments/link/add-link-elements-integration?link-integration-type=collect-email&defaultValues-integration-type=same#design-your-integration.

  • @jamesr2408
    @jamesr2408 Рік тому

    @17.49 the webhook trigger was successful, and the results are evident in the terminal. When I redirect the return_url to webhook.php, upon payment, I get the error: {"error":"Unable to extract timestamp and signatures from header"}. It is unfortunate, that the demo does not show the webhook.php in action. But all the same, thanks a ton for sharing this tutorial.

  • @thesigmasystems
    @thesigmasystems 7 місяців тому

    Perfect

  • @nnnkgjj
    @nnnkgjj Рік тому

    can u make video on how to change charge to intent

    • @StripeDev
      @StripeDev  Рік тому

      Hey T. We will certainly consider doing another video about it. For now, you can find information on changing a Charge to a Payment Intent in the official Stripe documentation:
      Payment Intents API: stripe.com/docs/payments/payment-intents
      Confirm a Payment Intent: stripe.com/docs/payments/payment-intents/quickstart#confirm-payment-intent
      Capture a Payment Intent: stripe.com/docs/payments/payment-intents/quickstart#capture
      In general, the Payment Intents API is designed to replace the Charges API, so you might also find it helpful to review the following resources for background information:
      Migrating to Payment Intents: stripe.com/docs/payments/payment-intents/migration
      Charge API vs. Payment Intents API: stripe.com/docs/payments/payment-intents/migration/charges

  • @riddhipanchal9141
    @riddhipanchal9141 Рік тому

    Hello, can you guide how can we set Google pay instead of cards ?

    • @StripeDev
      @StripeDev  Рік тому

      Hello there. Happy to help you with that. After activating Google Pay on your dashboard here: dashboard.stripe.com/settings/payment_methods, you can follow the steps on this document to set this payment method to your website: stripe.com/docs/google-pay.

  • @alpachino468
    @alpachino468 Рік тому

    Here's one for you: Using the API, I can get the payment_intent , and I can also get its associated charge for a successful purchase completed via the Stripe Hosted payment url. What I can't do is get the product that either the intent or the charge are associated to - how in the world do I get which charge or intent is associated to a product?

    • @StripeDev
      @StripeDev  Рік тому +1

      Hi there, you can do this by retrieving the Session and using expansion stripe.com/docs/expand, to include the 'line_item': stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items.
      You can also take a look at this doc for more context: stripe.com/docs/api/checkout/sessions/retrieve.

    • @alpachino468
      @alpachino468 Рік тому

      @@StripeDev Awesome, thanks for pointing me in the right direction ❤

    • @StripeDev
      @StripeDev  Рік тому

      Happy to help!

  • @АлександрЮрковский-ж4ы

    Can you share vscode theme name? :)

  • @bmtamim7818
    @bmtamim7818 Рік тому

    I don’t want to redirect them. Just want the charge id for the backend. How can I do this?
    Note: we are using stripe api. We took card data and send to srtipe. In test mood its work. But tomorrow we will live our application and today we just put the live key. And saw stripe sucks. They publish new rule we can't send raw card details. Okay perfect. This message should be with test too. So we aware and took necessary step erliery.
    But they didn’t and we have yo launch it tomorrow and we got this error..now I want to add stripe element but its want redirect url. Our system can't deal with this within one day. So, Stripe put us in trouble.