#RafaCitec-webhooks
1 messages · Page 1 of 1 (latest)
I'm still starting with Stripe and I want to get an idea of how it works, I've read that it's best to use webhooks because they are faster and Stripe calls me when a payment is recorded (for example)
I have a React, I have seen that I should install stripe.js, correct?
If you're using React, you would want to use :
https://github.com/stripe/react-stripe-js
https://stripe.com/docs/stripe-js/react
how are you integrating with Stripe? i.e. are you using Checkout or the Payment Element?
Exactly
I don't know, we want to make an integration with monthly payments, type membership site, what do you recommend?
Checkout : https://stripe.com/docs/payments/checkout
Demo : https://checkout.stripe.dev/
Payment Element : https://stripe.com/docs/payments/payment-element
generally Checkout is much easier to integrate, mostly because the UI and a lot of validations are already built in. Of course, correspondingly, you aren't able to customize a lot of things.
The Payment Element would only collect the payment method details. You would have to build almost everything else e.g. collection of email / customer name, etc, which allows you to customize almost everything else
Could it be that the difference between "Checkout" and "Payment Elements" is that the first is on your servers and with the second we can do the whole process on our server? because it is what we want, to do everything in-house
the Checkout page is hosted on Stripe servers yes. You can take a look at the Checkout Demo, and how the Payment Element looks like on the respective links i pasted previously
(Checkout) It would look nice I suppose, but we would already redirect our clients to checkout.stripe.com or similar, to a stripe url, right?
is your concern the domain name? if so, you can use your own domain : https://stripe.com/docs/payments/checkout/custom-domains
ok, if we can use our domain, what advantages does Payment Element have over Checkout? because in principle we do not want anything complicated, only the monthly payment, we are more concerned about getting something fast, functional and safe
The Payment Element is for users who want to be able to customize everything
ok, is it difficult to migrate from Checkout to Payment Element ?
hmmm, i would say so yes. Mainly because you would have implement a lot of things on your page when using the Payment Element, which otherwise could have been handled by Checkout
I say this, because thinking about it, perhaps it would be a good option to choose Checkout initially now and later if we need more customization, migrate from one to another
you can always try a simple POC for each, and see how much effort it would take and what additional things you would need to implement for the Payment Element
I see, and implementing Checkout with our domain would be easier and faster, right?
ok, for the 2 do I have to use stripe.js or does Checkout work differently?
we have a sample / guide with React here : https://stripe.com/docs/checkout/quickstart
ok, I already have it clear, this, now I have to decide
but another question, in this process, either one or the other, do I have to create a webhook manually? or that is already managed by Stripe
you should also listen for webhooks. If the user closes the window before the Checkout Session completes, it's possible the callback won't execute. Then your application wouldn't know that the payment is done
ok I understand, I want to use webhooks, what I don't understand is how to use them...
and how to use them with checkout and how to use them with Elements
these guides might help :
https://stripe.com/docs/payments/checkout/fulfill-orders
https://stripe.com/docs/webhooks
ahhh regardless of whether I use Checkout or Elements I must create the webhook, is that true?
to clarify, you would listen for the webhook event, and create a webhook endpoint. Yes, whether you use Checkout or Elements, you should listen for the relevant webhook events
Ok, so I choose a payment method Checkout or Elements for my page, for the front and create a webhook in Stripe and configure the successful payment events and so on...
and I create in my application (backend) an endpoint that receives from Stripe the confirmation of Payment received, is that correct?
that's correct for a high level summary
High level summary is enough today jeje
And my last question today, how do I identify the client who is paying me? at which point I send you an id_client or email_client or token and I can link your successful payment with the client
when you create the Checkout Session, there're a couple of options you can use to identify the client who is paying you : the customer, customer_email, metadata or client_reference_id or id. You would have to make some kind of comparison based on a certain parameter
ok, and I suppose that if, for example, I use email to identify each client, the webhook events in each call made to our endpoint would pass us a parameter with the client's email
and with that we will be able to know if it has been paid correctly, if there have been errors in the payment or if the account must be canceled due to non-payment
so assuming you're listening for checkout.session.completed events - the event data would be that of a Checkout Session : https://stripe.com/docs/api/checkout/sessions/object
If you pass in an existing Customer id, then you would be able see the customer's email in customer_details.email in checkout.session.completed
"customer_creation": null,
"customer_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": "test+checkout@example.com",
"name": "checkout setup prefill",
"phone": null,
"tax_exempt": "none",
"tax_ids": [
]
},
"customer_email": null,
"expires_at": 1652934297,
"livemode": false,
if you don't pass in an existing Customer id, then you would be able to see the customer's email in customer_email in checkout.session.completed
The customers are saved in Stripe?
yes, customers are/can be saved in Stripe : https://stripe.com/docs/api/customers, https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer_creation
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Name, lastname, email, client_id and other information...
ok, and can not be saved?
i didn't quite understand this part ca not be saved?
customers can't be saved to Stripe? for data protection issues and such
I only ask for legal reasons, I don't know if saving customers in Stripe we would have to modify our privacy policies...
we mostly help out with technical/API questions on this channel and can't advise you on privacy questions. You would probably need to consult with your own legal team on this.
ok