A tutorial integrating Stripe in PHP
Switch branches/tags
Nothing to show
Latest commit 652b080 Nov 29, 2016 @larry-stripe larry-stripe committed on GitHub Merge pull request #17 from stripe/larry-use-stable
update to always use latest stable
Failed to load latest commit information.
Step1 clean up Apr 22, 2015
Step2 clean up Apr 22, 2015
Step3 clean up Apr 22, 2015
Step4 error while crypting password Jun 6, 2016
Step5 error while crypting password Jun 6, 2016
Step6 error while crypting password Jun 6, 2016
Step7 clean up Apr 22, 2015
public update to always use latest stable Nov 29, 2016
.gitignore First commit of first 4 steps Nov 11, 2012
LICENSE Create LICENSE May 30, 2014
README.md update to always use latest stable Nov 29, 2016


Wilde Things - A study in PHP

Wilde Things is a website on which you can buy quotes by Oscar Wilde. This is a PHP demo that demonstrates integrating Stripe, originally done for a General Assembly livestream tutorial on November 14, 2012.

The demo is 7 steps and goes from setting up a simple site for accepting one-time payments to a subscription-based service complete with webhook support.

Getting started

To begin, you'll need to take three steps (aside from cloning this repo):

  • Setup the web root directory
  • Install the Stripe PHP library
  • Create a Stripe account

Web root directory

For the purposes of this tutorial, the public folder--included in the git repo--is assumed to be the web root directory. You'll need to configure your web server accordingly, or clone the repo in the right directory to arrange that.

For each step in the tutorial, copy the script(s) to be executed to the public directory to test them.

Installing the Stripe library

To run any of the steps, you will first need to install the Stripe PHP library. As of version 2 of the Stripe PHP library, installation is accomplished via Composer.

Assuming you have installed Composer, add Stripe to your composer.json file (in the public folder):

  "require": {
    "stripe/stripe-php": "@stable"

(The repo already includes this for you.)

Then run Composer's installation tool:

composer install

Creating a Stripe account

Next, sign up for a Stripe account at https://stripe.com and find your publishable and secret API keys in your account settings. As you go through the tutorial, you'll need to replace every instance of <YOUR PUBLISHABLE STRIPE API KEY> and <YOUR SECRET STRIPE API KEY> with your actual keys. You'll want to use your test API keys throughout.

Stripe PHP library versions and major changes

Version 2 of the Stripe PHP library, released in February 2015, makes use of namespaces, is installed via Composer, and requires PHP 5.3.3 or greater. All of the code in this tutorial has been updated for the 2.x Stripe PHP library.

If you're using an older version of the Stripe PHP library, see the changelog of this tutorial for the older code you'd use instead (in your PHP scripts). You can manually download older versions of the Stripe PHP library on GitHub.