Chargebee API PHP Client (for API version 2 and Product Catalog version 2.0)

Overview

chargebee-php-sdk

Packagist Latest Stable Version License

Overview

This package provides an API client for Chargebee subscription management services.

It connects to Chargebee REST APIs for the following versions:

If your Chargebee site is using Product Catalog version 1.0, you can use our product_catalog_v1 branch. It works mostly the same, but be aware that it is neither maintained nor documented.

Installation

composer require globalis/chargebee-php-sdk php-http/guzzle7-adapter

Basic usage

<?php

use Globalis\Chargebee\Client as ChargebeeClient;
use Http\Client\Exception\HttpException;

$chargebee = new ChargebeeClient('{site}', '{site_api_key}');

try {
    // List last created subscription:
    $response = $chargebee->subscription()->list([
        "limit" => 1,
        "sort_by[desc]" => "created_at",
        "status[is]" => "active",
    ]);
} catch (HttpException $e) {
    // Get API error details:
    $response = json_decode($e->getResponse()->getBody(), true);
    echo sprintf("Error: (%s) %s", $response["api_error_code"], $response["message"]);
}

Events

The API client produces events on API responses. You can listen to those events and connect any callable on them.

The events implement Psr\EventDispatcher\StoppableEventInterface from league/event PSR-14 package.

<?php

use Globalis\Chargebee\Client as Chargebee;
use Globalis\Chargebee\Events\EventChargebeeApiResponseSuccess as EventResponseSuccess;
use Globalis\Chargebee\Events\EventChargebeeApiResponseError as EventResponseError;

Chargebee::onApiResponseSuccess(function (EventResponseSuccess $event) {
    // $event contains data about the API request and response
    // do something
});

Chargebee::onApiResponseError(function (EventResponseError $event) {
    // $event contains data about the API request and response
    // do something
});

Integrations

History

This project is a fork of nathandunn/chargebee-php-sdk package. We forked it so we could implement Product Catalog 2.0 changes. We also added PSR-14 events, and fixed a few bugs.

Documentation

We don't have a full documentation yet.

You will find more details on the usage of HTTPlug and the HttpClient\Builder on the original README.md and wiki.

You might also like...
Laravel Client REST Camunda API

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Airbrake.io & Errbit integration for Symfony 3/4/5. This bundle plugs the Airbrake API client into Symfony project

AmiAirbrakeBundle Airbrake.io & Errbit integration for Symfony 3/4/5. This bundle plugs the Airbrake API client into Symfony project. Prerequisites Th

PHP 8.1 like legacy enum (Experimental Alpha Version)

flux-legacy-enum PHP 8.1 like legacy enum Experimental Alpha Version Installation COPY --from=docker-registry.fluxpublisher.ch/flux-enum/legacy:latest

PHP library/SDK for Crypto APIs 2.0 using Guzzle version 7

cryptoapis/sdk-guzzle7 Crypto APIs 2.0 is a complex and innovative infrastructure layer that radically simplifies the development of any Blockchain an

PHP Pi Horizon Client Library

phpi-sdk PHP Pi Horizon Client Library This is part of FASTLANE project for the pi payment gateway, as we are trying to build a pi wallet inside FASTL

PSR-15 middleware to geolocate the client using the ip address

middlewares/geolocation ![SensioLabs Insight][ico-sensiolabs] Middleware to geolocate the client using the ip address and Geocoder and save the result

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API

Luracast Restler ![Gitter](https://badges.gitter.im/Join Chat.svg) Version 3.0 Release Candidate 5 Restler is a simple and effective multi-format Web

This API provides functionality for creating and maintaining users to control a simple To-Do-List application. The following shows the API structure for users and tasks resources.
This API provides functionality for creating and maintaining users to control a simple To-Do-List application. The following shows the API structure for users and tasks resources.

PHP API TO-DO-LIST v.2.0 This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science cours

This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses and the like.
This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses and the like.

Simple PHP API v.1.0 This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses a

Comments
  •  Handle Chargebee unexpected error

    Handle Chargebee unexpected error

    If there is an unexpected error (for example: Chargebee DNS problem, error 500 without body), The error handler is not working:

    image

    To fix that, can you apply this?

    File : nathandunn/chargebee-php-sdk/src/HttpClient/Exception/ApiExceptionHandler.php image

    opened by JAmathieu 1
Releases(1.0.2)
Owner
GLOBALIS media systems
GLOBALIS est une entreprise de service numérique Web, créée en 1997, spécialiste de #PHP et de #WordPress.
GLOBALIS media systems
Shopware plugin to show a variant switch on the product listing and within the (checkout) cart.

Variant switch for Shopware 6 A plugin for Shopware 6 Features Show variant switch on product listing card Variant switch when hovering a variant prop

Shape & Shift 17 Aug 26, 2022
Modern version of pocketmine forms API, ported to PHP 8.0+ with high quality code and phpstan integration

forms Modern version of pocketmine forms API, ported to PHP 8.0+ with high quality code and phpstan integration Code samples ModalForm Using ModalForm

Frago9876543210 23 Nov 18, 2022
Simple PHP API client for tube-hosting.com rest API

Tube-Hosting API PHP client Explanation This PHP library is a simple api wrapper/client for the tube-hosting.com api. It is based on the provided docu

null 4 Sep 12, 2022
The efficient and elegant, PSR-7 compliant JSON:API 1.1 client library for PHP

Woohoo Labs. Yang Woohoo Labs. Yang is a PHP framework which helps you to communicate with JSON:API servers more easily. Table of Contents Introductio

Woohoo Labs. 160 Oct 16, 2022
PHP unofficial client to CryptoPanic.com API

PHP unofficial client to CryptoPanic.com API CryptoPanic.com is a news aggregator platform indicating impact on price and market for traders and crypt

null 6 Nov 2, 2022
Tuya Api PHP Client

Tuya Api PHP Client This is a simple php client to interact with devices that support the tuya api over the cloud. Requirements I believe all is neede

null 11 Sep 22, 2022
This is the PHP ApiDQ API client

ApiDQ API PHP Client This is the PHP ApiDQ API client. This library allows using of the actual API version. You can find more info in the documentatio

Nikita Krasnikov 2 Oct 5, 2021
Simple Client for Airtable API

Airtable Client Bundle (Work In Progress) The Airtable Client bundle is a Symfony bundle that attempts to make the Airtable API easier to use. Retriev

Yoan Bernabeu 28 May 12, 2022
Laravel A2Reviews Client API lets you build apps, extensions, or plugins to get reviews from the A2reviews APP.

Overview Laravel A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP. Including adding reviews to a

Be Duc Tai 2 Sep 26, 2021
A basic, opinionated, Laravel Api Client

Laravel Api Client Installation Install the pacakage via composer composer require antonioprimera/laravel-api-client If you want to use pre-configured

Antonio Primera 2 Nov 3, 2022