chargebee / chargebee-php
ChargeBee API client implementation for PHP
Installs: 5 426 630
Dependents: 12
Suggesters: 2
Security: 0
Stars: 72
Watchers: 41
Forks: 62
Open Issues: 6
Requires
- php: >=5.6.0
- ext-curl: *
- guzzlehttp/guzzle: >=6.5
Requires (Dev)
- simpletest/simpletest: ^1.1
- dev-master
- v3.35.1
- v3.35.0
- v3.34.1
- v3.34.0
- v3.33.0
- v3.32.0
- v3.31.0
- v3.30.0
- v3.29.0
- v3.28.0
- v3.27.1
- v3.27.0
- v3.26.1
- v3.26.0
- v3.25.1
- v3.25.0
- v3.24.1
- v3.24.0
- v3.23.0
- v3.22.0
- v3.21.0
- v3.20.0
- v3.19.0
- v3.18.0
- v3.17.0
- v3.16.0
- v3.15.0
- v3.14.0
- v3.13.0
- v3.12.0
- v3.11.0
- v3.10.0
- v3.9.0
- v3.8.0
- v3.7.0
- v3.6.0
- v3.5.2
- v3.5.1
- v3.5.0
- v3.4.0
- v3.3.0
- v3.2.1
- v3.2.0
- v3.2.0-rc.1
- v3.1.0
- v3.0.0
- v2.8.3
- v2.8.2
- v2.8.1
- v2.7.9
- v2.7.8
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.9
- v2.6.8
- v2.6.7
- v2.6.6
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.9
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.9
- v2.3.8
- v2.3.7
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.9
- v2.2.8
- v2.2.7
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.9
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.7.5
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.9
- v1.6.8
- v1.6.7
- v1.6.6
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- dev-chore/add-greeting-workflow
- dev-chargebee-php56-support
- dev-chargebee-v1
This package is not auto-updated.
Last update: 2024-11-08 11:41:46 UTC
README
This is the PHP Library for integrating with Chargebee. Sign up for a Chargebee account here.
Chargebee now supports two API versions - V1 and V2, of which V2 is the latest release and all future developments will happen in V2. This library is for API version V2. If you’re looking for V1, head to chargebee-v1 branch.
Requirements
PHP 5.6.0 or later
Installation
Composer
Chargebee
is available on Packagist and can be installed using Composer
composer require chargebee/chargebee-php
To use the bindings,
require_once('vendor/autoload.php');
Manual Installation
Download the latest release and to use the bindings, include
init.php
file.
require_once('/path/to/chargebee-php/lib/init.php');
Documentation
Usage
To create a new subscription:
use ChargeBee\ChargeBee\Environment; use ChargeBee\ChargeBee\Subscription; Environment::configure("your_site", "{your_site_api_key}"); $result = Subscription::create([ "id" => "__dev__KyVqH3NW3f42fD", "planId" => "starter", "customer" => [ "email" => "john@user.com", "firstName" => "John", "lastName" => "Wayne" ] ]); $subscription = $result->subscription(); $customer = $result->customer(); $card = $result->card();
Create an idempotent request
Idempotency keys are passed along with request headers to allow a safe retry of POST requests.
use ChargeBee\ChargeBee\Environment; use ChargeBee\ChargeBee\Models\Customer; Environment::configure("your_site", "{your_site_api_key}"); $result = Customer::create(array( "email" => "john@test.com", "first_name" => "john" ), null, array( "chargebee-idempotency-key" => "<<UUID>>" ) ); // Replace <<UUID>> with a unique string $customer = $result->customer(); print_r($customer); $responseHeaders = $result->getResponseHeaders(); // Retrieves response headers print_r($responseHeaders); $idempotencyReplayedValue = $result->isIdempotencyReplayed(); // Retrieves Idempotency replayed header value print_r($idempotencyReplayedValue);
isIdempotencyReplayed()
method can be accessed to differentiate between original and replayed requests.
Legacy Support
If you are using PHP < 5.6.0 , you can download chargebee-php v2.8.3. This version will not support recently added features since the version was released. We recommend you to upgrade PHP inorder to use the latest features.
License
See the LICENSE file.