Download the PHP package nikapps/bazaar-api-php without Composer

On this page you can find all versions of the php package nikapps/bazaar-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bazaar-api-php

Bazaar-Api-PHP (BazaarApi for PHP)

A PHP API wrapper for Cafebazaar REST API (v2).

If you are looking for version 1.x, please visit branch v1.

CafeBazaar Logo

Table of Contents

Installation

If you don't have Composer, first you should install it on your system:

Now run this command to install the package:

Configuration

Create a client

First, you should go to your cafebazaar panel and create a client.

now you have your client-id and client-secret.

Getting refresh token

Don't forget to change <REDIRECT_URI> and <CLIENT_ID>.

$bazaar = new Bazaar(new Config([
    'client-secret' => 'your-client-secret',
    'client-id' => 'your-client-id'
]));

$token = $bazaar->token('<REDIRECT_URI>');

echo "Refresh Token: " . $token->refreshToken();

Here is the full example: authorization.php

Setting up config

As you can see in previous section, we create a Config instance and set client-id and client-secret.

For other api calls, we also should set refresh-token and storage.

$bazaar = new Bazaar(new Config([
    'client-secret' => 'your-client-secret',
    'client-id' => 'your-client-id',
    'refresh-token' => 'refresh-token-123456',
    'storage' => new FileTokenStorage(__DIR__ . '/token.json')
]));

The storage handles storing and retrieving access_token. in this package we have two different storages:

Usage

Purchase

Here is the example of getting state of a purchase:

$purchase = $bazaar->purchase('com.example.app', 'product-id (sku)', 'purchase-token');

if ($purchase->failed()) {
    echo $purchase->errorDescription();
} else {
    echo "Purchased: " . $purchase->purchased();
    echo "Consumed: " . $purchase->consumed();
    echo "Developer Payload: " . $purchase->developerPayload();
    echo "Purchase Time (Timestamp in ms): " . $purchase->time();
}

Full Example: purchase.php

Subscription

Here is the example of getting state of a subscription:

$subscription = $bazaar->subscription('com.example.app', 'subscription-id (sku)', 'purchase-token');

if ($subscription->failed()) {
    echo $subscription->errorDescription();
} else {
    echo "Start Time (Timestamp in ms): " . $subscription->startTime(); // initiationTime()
    echo "End Time (Timestamp in ms): " . $subscription->endTime(); // expirationTime(), nextTime()
    echo "Is auto renewing? " . $subscription->autoRenewing();
    echo "Is expired? (end time is past) " . $subscription->expired();
}

Full Example: subscription.php

Cancel Subscription (Unsubscribe)

Here is the example of how you can cancel a subscription:

$unsubscribe = $bazaar->unsubscribe('com.example.app', 'subscription-id (sku)', 'purchase-token');

if ($unsubscribe->successful()) {
    echo "The subscription has been successfully cancelled!";
} else {
    echo $unsubscribe->errorDescription();
}

Full Example: unsubscribe.php

Customization

Custom Token Storage

If you want to store the token somewhere else (maybe database or redis?!), you can implement the TokenStorageInterface

class CustomTokenStorage implements TokenStorageInterface 
{

    public function save(Token $token)
    {
        // store access token
    }

    public function retrieve()
    {
        // return access token
    }

    public function expired()
    {
        // is token expired?
    }

}

Examples

See: https://github.com/nikapps/bazaar-api-php/blob/master/examples/

Dependencies

Testing

Run:

Official Documentation

Contribute

Wanna contribute? simply fork this project and make a pull request!

License

This project released under the MIT License.

Donation

Donate via Paypal


All versions of bazaar-api-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
guzzlehttp/guzzle Version ~5.3|~6.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nikapps/bazaar-api-php contains the following files

Loading the files please wait ....