I was looking for exactly this piece of JS and C# code behind for WebForms. It is just not easy to read Stripe documentation and write all this. It really really helped a great deal. Thanks!
you actually saved my life, I have spent days reading stripe documentation and a short video like this would have saved my valuable time. I don't know why stripe can't follow Microsoft's examples by making short videos about their Api for developers to grasp quickly
Hey there! Thanks for the kind words. Not sure if you've seen this TH-cam channel full of those short videos about the API: th-cam.com/users/StripeDevelopersvideos. Would love to hear feedback about how we can make that more discoverable.
It may sound strange but this video changed my life. I am a better person now. I became mentally ill after reading through the Stripe API documentation and had to be admitted to the hospital. The doctors tried to give me medicine, but it didn't work. When I watched this video I realized that this was the medicine I needed. Thank you medicine man! You have a new subscriber!
Yes your video helped a lot. What I found was that the success page doesn't hit the Page Load event and I can't do any processing like update my database. I think it's because we're still on the client side. What I did was put a "Continue" button on the success page that does get executed when clicked and I can update my DB but then I don't have any of the query string variables. Luckily my session variables are still there. This isn't an optimum way handle it! Is there something I can do to get the Page Load event to trigger?
Hey there is one question in my mind, can we run all apps i.e. webforms aspx c# in visual studio in macbook too? and what are the application which help to set the environment i.e. visual studio community edition with SSMS Server. can we run both on macbook? @CJ Avilla
you made it simple. Just one thing -I say card payment and Gpay... How about if we want to pay by other modes/wallet as well.. can you share some reference to achieve that
@@cjav_dev Hi!:) Yes, I am wondering how do I secure my stripe checkout? I've read the stripe documentation on security at stripe but I'm still quite confused on how to do it. May I ask if you could show an easy way or some resources on how to secure stripe checkout?
@@nicolewong2227 couple things come to mind: adding captcha before redirecting and ensuring signature verification on the webhook handler. I’ll add this to the queue of topics to record, thanks!
Excellent video, thank you. Can you consider publishing a short video to detail the processing for the success page - we are struggling to find adequate examples of this in the Stripe API documentation
This is VERY close to what I am trying to accomplish and what I already have with PayPal. But I don't know the price yet on arriving at the page. So what I am trying to do, is derive the pricing stuff on the page, they click a single button which redirects to the stripe checkout and them come back to a success page. Doing that session work in the page load is essentially putting the cart ahead of the horse as they say... for me anyhow.
You can always wait to create the Checkout Session until after the form is submitted. I'm not 100% sure how to achieve this with webforms, but the idea would be that you preventDefault for the form submission, then create an AJAX call to the server to create the CheckoutSession, that route would return the session's ID that you can use again in JavaScript to redirect.
@@cjav_dev Hey thanks for the reply. I am making progress. I am a little unsure of the higher level path, but maybe you can take a moment just to ay it out for me. On a single form, I want the user to press a button, have it launch a checkout screen, and then have the payment result come back to the "success" page after payment. Now I want to setup the transaction to be a hold (manual capture), and there might be a few line items. So do I have to setup an intent ahead of time and then somehow pass that intent to the session object? I'm just a little unclear on what objects I need to setup and in what order. I'm a little unclear on how all these things link together. In PayPal I setup an order behind the scenes and then send the user to PayPal along with a return Url for them to comeback to. I thin I can do the samething in Strip with the Session or Checkout object.
@@cjav_dev I've got it all figured out... with one hangup so far. IN your sample here you have the script in the aspx file attached to a button listener. Instead of doing that, how would you just trigger the script to fire from the CS code instead? I've played around with script manager and stuff to no avail. Gawd if you can help me with this everything will just snap into place and I can use Stripe.
Hello! Great video! However, I followed your code and I was getting numerous errors. I went othe stripe docs and fized the errors on the srver side. However, I cannot ge the javascript to run when I click the Checkout button. Any thoughts. Do you have a copy of the code because since I am visually impaired I may have not copied the javascript correctly.
Hello, i have copied your codes, but When i run, i get error that i must define mode for prices, i put mode=”payment” …. But i get strand error, seems doesnt recognize it.. May i ask you please give me the code and where i should put it, thanks ja a d kind regards I use visual studio 2019, c# asp net webforms
Thanks for the video it really helped. Don't know if you can help when running on local host I get the following error redirectToCheckout is not a function all scripts are added.
The most likely cause of this is that Stripe.js isn't loaded before that is called. Is your javascript running inline in a script tag or loaded from another js file? Make sure the stripe.js library is loaded from js.stripe.com and is not using defer or async tags to load. You might also want to wrap your js in an event handler for DOMContentLoaded like: document.addEventListener('DOMContentLoaded', function(e) { // do everything });
Hi! Awesome video it was really helpful! But may I ask about the SessionLineItemOptions list in the cs file? Will it work if I wanna pass in a session/class to any one of the attributes? For example, instead of "Name = 'T-shirt' ", I put "Name= Session["SSName"].ToString()" or "Name=GetName()". I did try to pass the class as a parameter in the list but I got this error: Stripe.StripeException: 'You passed an empty string for 'line_items[0][name]'. We assume empty values are an attempt to unset a parameter; however 'line_items[0][name]' cannot be unset. You should remove 'line_items[0][name]' from your request or supply a non-empty value.'
Brother thanks for the Video. Can you help i am getting this error 'System.Web.SessionState.SessionId' is not accessible in this context because it is 'Friend'.
I was looking for exactly this piece of JS and C# code behind for WebForms. It is just not easy to read Stripe documentation and write all this. It really really helped a great deal. Thanks!
you actually saved my life, I have spent days reading stripe documentation and a short video like this would have saved my valuable time. I don't know why stripe can't follow Microsoft's examples by making short videos about their Api for developers to grasp quickly
Hey there! Thanks for the kind words. Not sure if you've seen this TH-cam channel full of those short videos about the API: th-cam.com/users/StripeDevelopersvideos. Would love to hear feedback about how we can make that more discoverable.
It may sound strange but this video changed my life. I am a better person now. I became mentally ill after reading through the Stripe API documentation and had to be admitted to the hospital. The doctors tried to give me medicine, but it didn't work. When I watched this video I realized that this was the medicine I needed. Thank you medicine man! You have a new subscriber!
🤪🥰
Funny!
Awesome! Yes that was very helpful. I'm glad I searched again and found you now I can get this stripe thing working!
Happy to help!
Great video.
How to retrieve the session by ID from the .Net web form?
Yes your video helped a lot. What I found was that the success page doesn't hit the Page Load event and I can't do any processing like update my database. I think it's because we're still on the client side. What I did was put a "Continue" button on the success page that does get executed when clicked and I can update my DB but then I don't have any of the query string variables. Luckily my session variables are still there. This isn't an optimum way handle it! Is there something I can do to get the Page Load event to trigger?
Hey there is one question in my mind, can we run all apps i.e. webforms aspx c# in visual studio in macbook too? and what are the application which help to set the environment i.e. visual studio community edition with SSMS Server. can we run both on macbook? @CJ Avilla
you made it simple. Just one thing -I say card payment and Gpay... How about if we want to pay by other modes/wallet as well.. can you share some reference to achieve that
What would I have to add if I wanted to include shipping costs on that order?
I recommend adding a separate line item just for shipping. That goes in the controller where the Checkout Session Options are created.
@@cjav_dev Thank you, that works perfectly
Your videos are super helpful and super great!
Thanks! Any topics you’d be interested in seeing? :)
@@cjav_dev Hi!:) Yes, I am wondering how do I secure my stripe checkout? I've read the stripe documentation on security at stripe but I'm still quite confused on how to do it. May I ask if you could show an easy way or some resources on how to secure stripe checkout?
@@nicolewong2227 couple things come to mind: adding captcha before redirecting and ensuring signature verification on the webhook handler. I’ll add this to the queue of topics to record, thanks!
Great video
Hi, how you create web forms in VS for Mac? Kindly tell me Please.
Excellent video, thank you. Can you consider publishing a short video to detail the processing for the success page - we are struggling to find adequate examples of this in the Stripe API documentation
Anything in particular you'd like to show on the success page?
You saved my life!
This is VERY close to what I am trying to accomplish and what I already have with PayPal. But I don't know the price yet on arriving at the page. So what I am trying to do, is derive the pricing stuff on the page, they click a single button which redirects to the stripe checkout and them come back to a success page. Doing that session work in the page load is essentially putting the cart ahead of the horse as they say... for me anyhow.
You can always wait to create the Checkout Session until after the form is submitted. I'm not 100% sure how to achieve this with webforms, but the idea would be that you preventDefault for the form submission, then create an AJAX call to the server to create the CheckoutSession, that route would return the session's ID that you can use again in JavaScript to redirect.
@@cjav_dev Hey thanks for the reply. I am making progress. I am a little unsure of the higher level path, but maybe you can take a moment just to ay it out for me. On a single form, I want the user to press a button, have it launch a checkout screen, and then have the payment result come back to the "success" page after payment. Now I want to setup the transaction to be a hold (manual capture), and there might be a few line items. So do I have to setup an intent ahead of time and then somehow pass that intent to the session object? I'm just a little unclear on what objects I need to setup and in what order. I'm a little unclear on how all these things link together. In PayPal I setup an order behind the scenes and then send the user to PayPal along with a return Url for them to comeback to. I thin I can do the samething in Strip with the Session or Checkout object.
@@cjav_dev I've got it all figured out... with one hangup so far. IN your sample here you have the script in the aspx file attached to a button listener. Instead of doing that, how would you just trigger the script to fire from the CS code instead? I've played around with script manager and stuff to no avail. Gawd if you can help me with this everything will just snap into place and I can use Stripe.
How to retrieve session by ID? Great video...
Hey Janko! Sorry for the delayed reply. Here's the code for retrieving by ID: stripe.com/docs/api/checkout/sessions/retrieve?lang=dotnet.
Hello! Great video! However, I followed your code and I was getting numerous errors. I went othe stripe docs and fized the errors on the srver side. However, I cannot ge the javascript to run when I click the Checkout button. Any thoughts. Do you have a copy of the code because since I am visually impaired I may have not copied the javascript correctly.
Do you have same implementation on Asp. Net Core /Mvc?
Does this one work? If not we can work on a new ep :) th-cam.com/video/TOVNYi-I3Wo/w-d-xo.html
Sir do you have any solution for my scenario i really need it for my college project
Hello, i have copied your codes, but When i run, i get error that i must define mode for prices, i put mode=”payment”
….
But i get strand error, seems doesnt recognize it..
May i ask you please give me the code and where i should put it, thanks ja a d kind regards
I use visual studio 2019, c# asp net webforms
How are you able to use webforms on your mac?
It used to work with visual studio 2019 but no longer ships with dotnet
Thanks for the video it really helped. Don't know if you can help when running on local host I get the following error redirectToCheckout is not a function all scripts are added.
The most likely cause of this is that Stripe.js isn't loaded before that is called. Is your javascript running inline in a script tag or loaded from another js file? Make sure the stripe.js library is loaded from js.stripe.com and is not using defer or async tags to load. You might also want to wrap your js in an event handler for DOMContentLoaded like:
document.addEventListener('DOMContentLoaded', function(e) {
// do everything
});
@@cjav_dev yes js loading from stripe will give the code a try. Thanks alot
Bro how comes i clicked checkout button but nothing happens
It's impossible to know without more details. I recommend reaching out to the team here to chat live: stripe.com/go/developer-chat.
Hi! Awesome video it was really helpful! But may I ask about the SessionLineItemOptions list in the cs file? Will it work if I wanna pass in a session/class to any one of the attributes? For example, instead of "Name = 'T-shirt' ", I put "Name= Session["SSName"].ToString()" or "Name=GetName()".
I did try to pass the class as a parameter in the list but I got this error:
Stripe.StripeException: 'You passed an empty string for 'line_items[0][name]'. We assume empty values are an attempt to unset a parameter; however 'line_items[0][name]' cannot be unset. You should remove 'line_items[0][name]' from your request or supply a non-empty value.'
Yeah that should work. Seems like what you passed was an empty string. Can you double check that method is returning a string value as expected?
Brother thanks for the Video. Can you help i am getting this error 'System.Web.SessionState.SessionId' is not accessible in this context because it is 'Friend'.
Seems like it needs to be public?
@@cjav_dev Dear Avilla, I am so new and beginner i could not understand how to make it public if you guide me it will be a great help. Thanks
@@visitsajid can you share your code in Twitter DM? @cjav_dev. It’s likely marked as protected instead of public in the code behind.
@@cjav_dev i will share my code in Twitter thank you so much
You won a kiss champion
not working
Please Provide Code file