sudiptochoudhury/php-zoho-subscriptions

PHP Client Library to Consume Zoho Subscriptions REST API

v0.4.3 2024-06-26 09:46 UTC

README

Latest Stable Version Latest Unstable Version License Total Downloads composer.lock available

Zoho Subscriptions API Client for PHP

use SudiptoChoudhury\Zoho\Subscriptions\Api;

...

$subscriptions = new Api([
                'oauthtoken' => '<<Zoho Subscriptions OAuth Token>>', // https://www.zoho.com/subscriptions/api/v1/#oauth
                'zohoOrgId' => '<<Zoho Organization ID>>',
            ]);


$resultJson = $subscriptions->addCustomer($data); // create a customer

$resultJson = $subscriptions->addSubscription($data); // create a subscription
 
 

Auth Token (Will be deprecated soon), but you can still use it.

use SudiptoChoudhury\Zoho\Subscriptions\Api;

...

$subscriptions = new Api([
                'authtoken' => '<<Zoho Subscriptions Auth Token>>', // https://accounts.zoho.com/apiauthtoken/nb/create
                'zohoOrgId' => '<<Zoho Organization ID>>',
            ]);


$resultJson = $subscriptions->addCustomer($data); // create a customer

$resultJson = $subscriptions->addSubscription($data); // create a subscription
 
 

Installation

Requirements

  • Any flavour of PHP 7.0+ should do

Install With Composer

You can install the library via Composer by adding the following line to the require block of your composer.json file (replace dev-master with latest stable version):

"sudiptochoudhury/php-zoho-subscriptions": "dev-master"

or run the following command:

composer require sudiptochoudhury/php-zoho-subscriptions

Setting up Authentication

Get Organization ID Before you start, read https://www.zoho.com/subscriptions/api/v1/#organization-id to know your Organization ID.

Setup OAuth and use oauth token

Follow instructions from https://www.zoho.com/subscriptions/api/v1/#oauth and get the oathtoken.

Pass the oauth token via the constructor.

use SudiptoChoudhury\Zoho\Subscriptions\Api;


new Api([
    'oauthtoken' => '<<Zoho Subscriptions OAuth Token>>', // https://www.zoho.com/subscriptions/api/v1/#oauth
    'zohoOrgId' => '<<Zoho Organization ID>>',
]);

Or Use AuthToken

will be deprecated soon

Crete and retrieve AuthToken from https://accounts.zoho.com/apiauthtoken/nb/create and set the AuthToken and Organization ID in the constructor.

use SudiptoChoudhury\Zoho\Subscriptions\Api;


new Api([
    'authtoken' => '<<Zoho Subscriptions Auth Token>>', // https://accounts.zoho.com/apiauthtoken/nb/create
    'zohoOrgId' => '<<Zoho Organization ID>>',
]);

How to use

Next, call the desired method from the table given below. In some methods you may need to pass parameters. The parameters are to be passed as an associative array. The required list of parameters can be found in the parameters column of the table or you may get more details going to the original Zoho Subscription API documentation.

Examples:

$resultJson = $subscriptions->getOrganizations(); 

$resultJson = $subscriptions->addCustomer(['display_name'=> 'Sudipto Choudhury', 'email'=> 'mail@sudipto.net']); // create a customer

Available API Methods