Download the PHP package zfr/zfr-stripe without Composer

On this page you can find all versions of the php package zfr/zfr-stripe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package zfr-stripe

ZfrStripe

Latest Stable Version

ZfrStripe is a modern PHP library based on Guzzle for Stripe payment system.

Dependencies

Installation

Installation of ZfrStripe is only officially supported using Composer:

Tutorial

First, you need to instantiate the Stripe client, passing your private API key (you can find it in your Stripe settings):

You can change the API key for the client using the setApiKey method. This is useful if you are using Stripe Connect and make both your own API calls and API calls on behalf of your users.

The currently latest supported version of the API is 2015-10-16. You can (and should) also explicitly specify the version of the client using the second parameter:

Versioning

Stripe API has an odd (yet very useful) versioning policy that makes it hard to version it correctly. The trick is that Stripe may change how some properties are passed on return on new versions (hence being a BC for older version), but still introduce new endpoints that will be available to older versions too.

Therefore, each time a new dated version of Stripe API is released, ZfrStripe will adopt this policy:

Currently, the following Stripe API versions are accepted by ZfrStripe: 2015-02-18, 2015-03-24, 2015-04-07, 2015-06-15, 2015-07-07, 2015-07-13, 2015-07-28, 2015-08-07, 2015-08-19, 2015-09-03, 2015-09-08, 2015-09-23, 2015-10-01, 2015-10-12, 2015-10-16. I will try to update the library as soon as new version are released.

If you need support for versions as old as 2014-03-28, please use branch v2 of ZfrStripe. If you need support for even older versions, please use branch v1 of ZfrStripe.

How to use it?

Using the client is easy. For instance, here is how you'd create a new charge:

The parameters have a direct one-to-one mapping with the official documentation (for any reference, you can also check the ZfrStripe\Client\ServiceDescription\Stripe-v1.1.php file). To know what the responses look like, please refer to the official API reference.

Using a different Stripe API version

For each requests, we send the "Stripe-Version" header to Stripe. Usually, the best way is to upgrade your API version globally in your Stripe dashboard. However, you may want to use two different versions in different part of your code, or test new features during development without changing it globally to your whole Stripe account.

To do that, you can explicitely set the wanted version in the constructor. Example:

You can dynamically change the version using the setApiVersion method:

Alternatively, you can also create different Stripe clients.

Stripe Connect

If you are using Stripe Connect, you will want to make API calls on behalf of your client. You have nothing special to do: just use the setApiKey method with the customer's access token:

Please note that if you want to use again your own secret key, you will need to make a new call to this method.

Expand

All Stripe API requests have support to expand some nested objects inside responses. Therefore, ZfrStripe supports this through the expand parameter, which must be an array:

Iterators

You may want to retrieve a list of customers, events or charges. Instead of manually doing all the requests yourself, you can use iterators. ZfrStripe provides iterators for all iterable resources:

By default, ZfrStripe retrieves 100 elements per API call (which is the maximum allowed by Stripe API). You may want to lower this limit by using the setPageSize method. You can also set a upper bound of how many results you want to retrieve by using the setLimit method.

Finally, you can still use API parameters when using an iterator. For instance, this will retrieve all the events that have the event customer.subscription.updated, doing a new API call each 50 elements (this means that only up to 50 elements are stored in memory), setting a limit of maximum 500 elements to retrieve:

You can also take advantage of Stripe cursor-based pagination:

ZfrStripe takes care of fetching the last item in the batch, extracting the id, and continuing doing requests until no more data is available!

Idempotency Key

Recently, Stripe has added support for idempotency key. This is added to every POST requests, and prevent an operation for being done twice, as long as the key is the same. You are responsible to generate your own idempotency key:

Undocumented features

While playing with Stripe API, I realized that the API has a few filtering capabilities that were not documented, but still accessible. Therefore, I've added some of them to this library but PLEASE be very defensive when you use them, as Stripe may remove them (or maybe officially document them in the future). Here is a list of the implemented hidden features:

Filter events

You can filter events by a object id using the object_id parameter. It will depend of the context. For instance if you are specifically retrieving subscription events, the object_id will allow to filter by subscription:

Retrieve deleted customers

You can retrieve deleted customers by using the deleted boolean:

Retrieve non-paid charges

You can retrieve non paid charges by using the paid boolean:

Retrieve proration items

You can retrieve proration invoice items only by using the proration boolean:

Exceptions

ZfrStripe tries its best to throw useful exceptions. Two kinds of exceptions can occur:

Here are all the exceptions:

Usage:

Complete reference

Here is a complete list of all methods:

CHARGE RELATED METHODS:

CUSTOMER RELATED METHODS:

CARD RELATED METHODS:

RECIPIENT CARD RELATED METHODS:

SUBSCRIPTION RELATED METHODS:

PLAN RELATED METHODS:

COUPON RELATED METHODS:

DISCOUNT RELATED METHODS:

INVOICE RELATED METHODS:

INVOICE ITEM RELATED METHODS:

DISPUTE RELATED METHODS:

TRANSFER RELATED METHODS:

RECIPIENT RELATED METHODS:

REFUND RELATED METHODS:

APPLICATION FEE RELATED METHODS:

BALANCE RELATED METHODS:

TOKEN RELATED METHODS:

EVENT RELATED METHODS:

ACCOUNT RELATED METHODS:


All versions of zfr-stripe with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
guzzle/guzzle Version ~3.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zfr/zfr-stripe contains the following files

Loading the files please wait ....