jsdecena/omnipay-chargebee

Omnipay Chargebee package

v0.1.5 2022-02-16 21:49 UTC

This package is auto-updated.

Last update: 2024-10-17 05:16:16 UTC


README

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('john@doe.com');