Skip to content

jsdecena/omnipay-chargebee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Omnipay - Chargebee

jsdecena/omnipay-chargebee

A Chargebee driver for Omnipay PHP payment processing library.

Installation

composer require league/omnipay:^3 jsdecena/omnipay-chargebee

Usage

To start charging your customer

1. Make an Omnipay Gateway:

$gateway = Omnipay::create('Chargebee');

2. Initialize your site settings

$gateway->authorize(['site_name' => '<YOUR-SITE-NAME>', 'site_api_key' => '<YOUR-API-KEY>']);

3. Make a transaction

You need to pass in the subscriber_id and the item_price_id to make a subscription.

$payment = $gateway->purchase([
    'subscriber_id' => '16BR23Sxald0PM3m',
    'subscription_items' => [
        [
            'billing_cycles' => 12,
            'free_quantity' => 0,
            'item_price_id' => 'cbdemo_advanced-USD-monthly',
            'quantity' => 1
        ]
    ]
]);

This will return a Charge object containing information about your subscription.

Customers

Retrieve all your customers and get the id of your subscriber which will be used in making the transaction

$gateway->authorize(['site_name' => '<YOUR-SITE-NAME>', 'site_api_key' => '<YOUR-API-KEY>']);
$payment = $gateway->getSubscribers();

Retrieve your customer with their email and get the id of your subscriber which will be used in making the transaction

$gateway->authorize(['site_name' => '<YOUR-SITE-NAME>', 'site_api_key' => '<YOUR-API-KEY>']);
$payment = $gateway->getSubscribers('[email protected]');