Wanna stay up to date with all of our posts! We hate spammers so rest assure, we will only send you great content and interesting articles. That doesn't sound so bad, huh?
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form
So, you’ve heard that Stripe is an awesome way to accept payments online (it is!), but the instructions for getting things up and running seem a little confusing (they are!). Well have no fear, muchacho! We’re going to sort you out. We’ll cover how to get up and running as quickly as possible using some PHP and as little of your in-demand brain powers as possible. If we get requests for other languages (Java? Python? Ruby? Node, anyone?) we can go through those in subsequent posts. For this tutorial though, we’ll stick with PHP and assume you have XAMPP or a similar local server running.
When we’re done, you’ll have a page that you can send to clients which will accept a query-string variable representing the amount to be charged. For example, http://payments.grueandbleen.com/?100 will charge $100.
Composer is an easy way to install PHP packages and any dependencies that package may have. In this case, we want to use it to install the Stripe-PHP, which is a wrapper for the Stripe API that makes all of the things we want to do with it easier. Hey, why reinvent the wheel, right? We just want to get at that sweet sweet digital cheddar, ASAP.
Click here to get the Composer installer. Follow the install instructions and come back here when you’re done.
Open up a command window: Windows-R, type cmd then hit enter
Navigate to your project's folder: cd c:\xampp\htdocs\tutorial
Execute the command to get the Stripe-PHP package: composer require stripe/stripe-php
Composer will reach out and download our Stripe-PHP package, and store it in a folder at the root of our project
Now that we have Stripe-PHP installed, we can move on to building the page and custom code to use it.
Our project is going to consist of just 3 php files:
This file will load up Stripe-PHP, and connect it to your Stripe account using your Secret Key and Publishable Key.
Get your secret and publishable keys from your Stripe account:
For now you can use the test keys. This means that any transactions you place using the widget will be test transactions. You’ll be able to see them come in as if they were real transactions, but they won’t actually be charged.
Replace YOUR-SECRET-KEY-HERE and YOUR-PUBLISHABLE-KEY-HERE with the actual values pulled from your Stripe account.
This is the page where the Stripe widget will sit. It will look for a dollar amount in the query string, and pass that value to the Stripe widget on submit.
What we're doing here:
This file takes the input from the form on the previous page, and uses Stripe-PHP to make the charge.
What we're doing here:
And that’s it! To see a working version of this, check out http://payments.grueandbleen.com/?1000000 to give us a million dollars!