Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress Stripe Payment Forms for WordPress

Mayur Pande
PLUS
Mayur Pande
Courses Plus Student 11,711 Points

how does the payment actually go into my bank account?

I am setting up a wordpress site for tutors for a friend. However I have made a timetable which shows what tutor is available for what date and subject. But I want the user to be able to click book and then it takes them to the payment page where they enter their card details if they are logged in, however if they are not logged in, it takes them to the registration page. Not entirely sure how to go about this, would woocommerce be better for this?

2 Answers

Kevin Korte
Kevin Korte
28,149 Points

To take a payment with stripe, you set up the payment form as stripe shows how to do. You'll need to include the stripe javascript library, and some additionally javascript that attaches to the form and does some things when the payment form is submitted.

Here is the docs: https://stripe.com/docs/tutorials/forms

You submit your payment form to stripe, they process it, check it, send your server back a token, you send the token back to stripe, if the tokens match the payment goes through, and stripe sends back a request to let you know.

It's a bit complicated, but not bad once you understand it, everything you need is in that link.

Kevin Korte
Kevin Korte
28,149 Points

Sure thing, I may recommend starting with the embedded form option as that gives you a lot of things already set up for free.

Later you can transition to the custom form option, but there you're responsible to code up just about everything to communicate properly with stripe servers.

Also don't forget strip will require you have a SSL secure connection before you actually start taking payment. You do not need that while testing though.

Kevin Korte
Kevin Korte
28,149 Points

It would seem easy enough to check for a session, and if you had an active session, you'd have a logged in user and could get their details. If not you could redirect to a login/registration page.

I think woocommerce has this type of functionally, so it may be worth looking at but it's certainly not a necessity.

Mayur Pande
Mayur Pande
Courses Plus Student 11,711 Points

Thanks for the reply. But I am still a little bit confused, I get that if they click book it will take them to the payment page, but how would I actually take a payment from them?

With regards to a login/registration page, I'm guessing I just create a new page with a form and link the preceding page to this?

Hi Mayur,

Here's a Treehouse course on exactly how Stripe works. Should help you wrap your head around some of this.