#thomas-payment-fulfillment
1 messages · Page 1 of 1 (latest)
Hi 👋
confirmPayment wille return a Promise that redirects to your return_url if the payment completes successfully. The return_url will include query parameters such as the client secret for the payment intent you just confirmed. You can then use Stripe.js to retrieve the payment intent and look up the status
https://stripe.com/docs/js/payment_intents/retrieve_payment_intent
But we recommend setting up webhooks as well
https://stripe.com/docs/webhooks#secure-webhook
So that you can still do these actions even if a user closes thier browser before being redirected
Sure. You can pass the client secret to the backend and use it to look up the Payment Intent https://stripe.com/docs/api/payment_intents/retrieve#retrieve_payment_intent-client_secret
Retrieving PaymentIntent is understood
I have confusion implementing webhooks
var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();
I'm getting error for the above line.
That isn't code I have any familiarity with, where did you geti it?
- Which language are you using?
- What does the error say?
.Net
An object reference is required for the non-static field, method, or property 'HttpContext.Request'
Hi @gusty grove , can you help me on how to check the status of the payment using client secret on the backend or web api side .Net
Does the code snippet we show here: https://stripe.com/docs/api/payment_intents/retrieve?lang=dotnet#retrieve_payment_intent-client_secret not work for you?
The example shows service.Get("pi_3Nx2NzJnRs6ZWiPy14eiBRi8");
pi_3Nx2NzJnRs6ZWiPy14eiBRi8 is a paymentIntent id right and not a clientSecret?
Correct but the list of available parameters includes the client_secret
I agree
Okay and so when you attempt to retrieve the Payment Intent using the client secret, what do you see?
thomas-payment-fulfillment
Could you show me as an example using clientsecret as parameter?
Also you really shouldn't need to do any of this. Your server should have a clear cookie/session tracking the current paying customer, you should know exactly who they are, what they are buying and be able to retrieve that PaymentIntent server-side instead
The frontend code is broken at the moment and is taken care by another developer.
I'm just handling the api side code.
Sounds interesting, could you provide me with a guide?
There's no guide for something like this, it's more basic web development practice
But really, if you're the server-side dev, when the customer hits your "return url" your server-side code runs and should know who the customer is and what they are buying
That I know
Please provide me an example
There's no reason to do this server-side, it doesn't make sense. You already should have the PaymentIntent id and can call the Retrieve PaymentIntent API https://stripe.com/docs/api/payment_intents/retrieve with that pi_123
But @brisk wing said its ok do look up the status of the paymentIntent in the backend
@chilly sphinx Had asked me to use webhooks
@lime spear I'm a customer, I pay, I get redirected to the return_url. You, the developer, know who I am, have cached the pi_123 somewhere in your database or a cookie or something and immediately call the Retrieve PaymentIntent API https://stripe.com/docs/api/payment_intents/retrieve
There is nothing more to it than this. There's no reason to look for a "client secret", that advice was incorrect and you can ignore it
@gusty grove Thanks, makes a lot of sense