Stripe.com is a powerful payment processor that is designed for developers and is by far one of the best payment systems I have ever worked with. This tutorial series is going to walk you through how to integrate payment forms, payment tracking, setting up recurring payment profiles, and more in WordPress with the Stripe API.
We will start simple by just building a minimal payment form that allows a user to enter their card information and make a payment to you. We will then get more advanced and work with tracking payments and creating subscriptions, as well as storing / updating credit card information.
- Stripe Integration Part 1 - Building the Settings and a Simple Payment Form
- Stripe Integration Part 2 - Recurring Payments
- Stripe Integration Part 3 - Variable Prices and Enhanced Plan Handling
- Stripe Integration Part 4 - Multiple Recurring Payment Options
- Stripe Integration Part 5 - Accepting Discount Codes
- Stripe Integration Part 6 - Payment Receipts
- Stripe Integration Part 7 - Creating and Storing Customers
- Stripe Integration Part 8 – Working with Invoices
- Stripe Integration Part 9 - The Stripe Button

Oh fun!
It will be
Great series on hooking up Stripe to WordPress. I’ve been looking at Stripe for recurring payments & it was serendipity that I saw this series.
I hacked the plugin a bit to work with CMB meta boxes. instead of giving the end-user a drop-down of all the plans, I needed to put that in the backend so I can select the right recurring plan for the client.
I also replaced the default success message with the output from a wpeditor() field, allowing me to craft a custom message.
Once I get some downtime, I can post some code.
Again, Thanks for the series.
Cheers!
That sounds like a fantastic adaptation of the code
Awesome Plugin!! Thanks for sharing this. Have been working with it all day and it is rocking.
One question though, when I use the shortcode on a page, the payment form gets output before all of the page content, even though in the page I have the form at the bottom.
Any ideas on this?
Did you download the plugin source code, or copy the tutorial code into your own plugin?
I downloaded the plugin source code
Found the problem. I’ve just updated the source code available in Part 5. Download it again and everything should work fine.
Thanks Pippin – that worked like a charm.
Another question though, could you do another part that details how to actually add the purchaser as a “Customer” within Stripe?
Do you mean for one-time charges? When a user signs up for a recurring payment, a customer is automatically created.
Ahh, yes, I meant for 1-time charges
Ah, yes, I can probably do that. I have a couple of different parts to the series to do first, but I will try and get to that.
After spending quite some time on working with Stripe I have reached a major issue with the service. It appears there is no way to directly associate an email address with a financial transaction.
I am awaiting a response from Stripe, but after going thru their API docs over and over, the only way I can see to do this is to create a unique Customer object for every transaction.
Any thoughts?
Steve
As far as I know, you are completely correct in this. The only option (aside from creating a customer) is to store the email in the “description” field, which is what they recommend on the API Docs page.
Is there any reason you wouldn’t want to create a customer for each charge?
I found that, I can’t believe they suggest that.
The reason I want all of a customer’s purchases tied together is so that I can display the historical transactions associated to that customer on their “account” page.
So, if I was to create a new Customer record for each purchase I would have no way of making those connections. I’d have to record all of their record id’s in my own table.
So, I’d have to confirm that Stripe have a flawed data model. That in conjunction with their lack of a response to my query (about 6 hrs ago) has really sealed their fate.
I really liked the idea of Stripe, but until they can improve the API and the service response, it’s not something I can trust my business too.
Thanks for your tutorial on this Pippin. I greatly appreciated it. It was great a jumping off point.
Steve
There’s no need to create a new customer with each Charge. The Charge creation function accepts a customer ID as an option parameter. See here: https://stripe.com/docs/api?lang=php#create_charge
As long as you create a customer with the first charge they make, the future charges are super simple, and it’s really easy to get all charges made by a particular user.
Not to play the devil’s advocate, but 6 hours is hardly enough time to be considered too long. I’m sorry, but that’s ridiculously presumptuous (sorry to be harsh). Also, just FYI, the definite best way to get answers about Stripe is in their community chat room: https://stripechat.campfirenow.com/room/314456 – They almost always have devs in their to answer your questions. I’ve asked dozens of questions there and always gotten very helpful responses in under 5 minutes.
Hi, its nice one. Where can find i download Stripe wordpess plugin?
Go to the last part in the series and download it at the bottom of the post.
Do you need to use the plugin on a PCI complaint web site?
Not required but it is a good idea.
Hey Pippin, great plugin!
I’m running into an error though
On one site it works perfectly, on another I get the error:
urlencode() expects parameter 1 to be string, array given in /wp-content/plugins/wordpress-stripe-integration/lib/Stripe/ApiResource.php on line 43
I’m not quite sure what it could be. I’ve disabled all plugins (in case of a conflict) to no avail.
Could you Help me out? Thanks!
When do you get that error? While processing a payment?
Thanks for replying back. Yeah, I see a charge in my account when using the form. However, no customer is created. I’m guessing it processes the card, then runs into an error before adding the customer to a plan.
At what point does that error get displayed?
Hi,
Thanks for the article. The payments seem to be working flawlessly. However, I’m having an issue with the shortcode. For some reason the payment form always appears at the top of the page, not where I’ve placed the shortcode in the editor. Any idea what’s going on here?
Thanks!
Make sure that you are returning the short code HTMl, not echoing it.