Skip to content
Stripe PHP bindings
Latest commit 9eb9cb6 @brandur brandur Bump version to 3.8.0

Stripe PHP bindings

Build Status Latest Stable Version Total Downloads License Code Coverage

You can sign up for a Stripe account at


PHP 5.3.3 and later.


You can install the bindings via Composer. Run the following command:

composer require stripe/stripe-php

To use the bindings, use Composer's autoload:


Manual Installation

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.


Getting Started

Simple usage looks like:

$myCard = array('number' => '4242424242424242', 'exp_month' => 8, 'exp_year' => 2018);
$charge = \Stripe\Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'usd'));
echo $charge;


Please see for up-to-date documentation.

Legacy Version Support

If you are using PHP 5.2, you can download v1.18.0 (zip, tar.gz) from our releases page. This version will continue to work with new versions of the Stripe API for all common uses.

This legacy version may be included via require_once("/path/to/stripe-php/lib/Stripe.php");, and used like:

$myCard = array('number' => '4242424242424242', 'exp_month' => 8, 'exp_year' => 2018);
$charge = Stripe_Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'usd'));
echo $charge;

Custom Request Timeouts

NOTE: We do not recommend decreasing the timeout for non-read-only calls (e.g. charge creation), since even if you locally timeout, the request on Stripe's side can still complete. If you are decreasing timeouts on these calls, make sure to use idempotency tokens to avoid executing the same transaction twice as a result of timeout retry logic.

To modify request timeouts (connect or total, in seconds) you'll need to tell the API client to use a CurlClient other than its default. You'll set the timeouts in that CurlClient.

// set up your tweaked Curl client
$curl = new \Stripe\HttpClient\CurlClient();
$curl->setTimeout(10); // default is \Stripe\HttpClient\CurlClient::DEFAULT_TIMEOUT
$curl->setConnectTimeout(5); // default is \Stripe\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT

echo $curl->getTimeout(); // 10
echo $curl->getConnectTimeout(); // 5

// tell Stripe to use the tweaked client

// use the Stripe API client as you normally would


Install dependencies:

composer install


Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:


Or to run an individual test file:

./vendor/bin/phpunit tests/UtilTest.php
Something went wrong with that request. Please try again.