Download the PHP package chronon/stripe without Composer
On this page you can find all versions of the php package chronon/stripe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package stripe
CakePHP Stripe Component
NOTE: This plugin is CakePHP 2 only and will not be updated for CakePHP 3. For CakePHP 3, consider checking out Omnipay. A great introduction on how to use it with CakePHP 3 can be found in Jose's post.
This is a simple component that interfaces a CakePHP app with Stripe's PHP API library. Pass the component an array containing at least an amount and a Stripe token id, it will attempt the charge and return an array of the fields you want.
Version 2 adds the ability to create and retrieve customers, optionally subscribing them to a recurring payment plan or just charging them.
Compatibility:
Tested with CakePHP 2.2.x and up, though please note it's not compatible with CakePHP 3.x. The required Stripe PHP API library requires PHP 5 with cURL support and must be version 1.18.0 or below. This plugin will now work with version 2.0.0 or above without modification.
Installation:
In your project composer.json
file:
This will install the plugin into Plugin/Stripe
, and install the Stripe library (from Packagist) into your Vendor
directory.
In your app's Config/bootstrap.php
, import composer's autoload file:
Using git:
Composer installation is highly recommended over git installation.
You will need the component (packaged as a plugin), and Stripe's PHP library. The Stripe library needs to be in this plugin's Vendor directory and must be named 'Stripe'. Using git you can add this plugin and the required Stripe library (as a git submodule). From your APP root (where you see your Model, Controller, Plugin, etc. directories) run:
git clone --recursive [email protected]:chronon/CakePHP-StripeComponent-Plugin.git Plugin/Stripe
OR
git clone --recursive https://github.com/chronon/CakePHP-StripeComponent-Plugin.git Plugin/Stripe
Configuration:
All configuration is in APP/Config/bootstrap.php.
Required: Load the plugin:
or load all plugins:
Required: Set your Stripe secret API keys (both testing and live):
Optional: Set Stripe mode, either 'Live' or 'Test'. Defaults to Test if not set.
Optional: Set the currency. Defaults to 'usd'. Currently Stripe supports usd only.
Optional: fields for the component to return mapped to => Stripe charge object response fields. Defaults to 'stripe_id' => 'id'
. See the Stripe API docs for Stripe_Charge::create() for available fields. For example:
See Usage below if Stripe.fields
is confusing.
Optional: add a logging config:
Making a Charge:
Make a payment form however you want, see the Stripe docs for sample code or use Stripe's excellent checkout button. Add the component to your controller:
Format your form data so you can send the component an array containing at least an amount, a Stripe token (with key stripeToken
), or a Stripe customer id (with key stripeCustomer
):
Optionally you can include a description
key (default is null):
An arbitrary string which you can attach to a charge object. It is displayed when in the web interface alongside the charge. It's often a good idea to use an email address as a description for tracking later.
Optionally you can include a capture
key set to true or false (default is true):
Whether or not to immediately capture the charge. When false, the charge issues an authorization (or pre-authorization), and will need to be captured later. Uncaptured charges expire in 7 days.
For example:
If the charge was successful, $result
will be an array as described by the configuration value of Stripe.fields
. If Stripe.fields
is not set:
If Stripe.fields
is set, using the example described above in the Configuration section would give you:
If the charge was not successful, $result
will be a string containing an error message, and log the error.
Creating a Customer:
Creating a customer with a card attached can be used for recurring billing/subscriptions, or can be charged immediately.
If creating the customer was successful, $result
will be an array as described by the configuration value of Stripe.fields
. If Stripe.fields
is not set:
If creating the customer was not successful, $result
will be a string containing an error message, and log the error.
You can pass the customerCreate()
method any valid keys/data as described by Stripe's API for creating a customer. See the API reference for the list. A customer can be created without a card, but obviously can't be charged or subscribed until a card is attached.
Example: to create a customer and subscribe them to a plan in one step, you could do something like this:
Retrieving a Customer:
Once a customer has been created, you can retrieve the customer object easily with the customer id.
Once you have the $customer
object you can update and delete as needed. For example, to change the email address of an existing customer:
Retrieve and charge a customer:
Retrieve and update a customer's card with a token:
Contributors:
@louisroy, @PhantomWatson
All versions of stripe with dependencies
ext-curl Version *
composer/installers Version *
stripe/stripe-php Version 1.18.*