PHPackages                             nikapps/bazaar-api-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. nikapps/bazaar-api-laravel

ActiveProject[API Development](/categories/api)

nikapps/bazaar-api-laravel
==========================

An API wrapper for cafebazaar based on popular Laravel Framework

2.0.0(11y ago)223[1 PRs](https://github.com/nikapps/bazaar-api-laravel/pulls)MITPHPPHP &gt;=5.4.0

Since Mar 4Pushed 9y ago2 watchersCompare

[ Source](https://github.com/nikapps/bazaar-api-laravel)[ Packagist](https://packagist.org/packages/nikapps/bazaar-api-laravel)[ RSS](/packages/nikapps-bazaar-api-laravel/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

Bazaar-Api-Laravel (BazaarApi for Laravel)
==========================================

[](#bazaar-api-laravel-bazaarapi-for-laravel)

An Easy-To-Use CafeBazaar API helper package for Laravel Framework (Laravel 4.2.x)

*Version 2.x is based on [Bazaar-Api-PHP](https://github.com/nikapps/bazaar-api-php).*

Installation
------------

[](#installation)

Simply run command:

```
composer require nikapps/bazaar-api-laravel

```

Or you can add this [package](https://packagist.org/packages/nikapps/bazaar-api-laravel) dependency to your Laravel's composer.json :

```
{
    "require": {
        "nikapps/bazaar-api-laravel": "2.*"
    }

}
```

Then update composer:

```
composer update

```

-

Add this package provider in your providers array `[app/config/app.php]`:

```
'Nikapps\BazaarApiLaravel\BazaarApiLaravelServiceProvider',
```

Next you need to publish configuration file. Run this command:

```
php artisan config:publish nikapps/bazaar-api-laravel

```

Run :

```
php artisan

```

If you see a `bazaar:refresh-token` command, you are all set to go !

Configuration
-------------

[](#configuration)

#### Create a client

[](#create-a-client)

First of all, you should go to your cafebazaar panel and get `client id` and `client secret`.

- Login to your panel and go to this url: *(Developer API section)*`http://pardakht.cafebazaar.ir/panel/developer-api/?l=fa`
- Click on `new client` and enter your redirect uri (you have to set it for getting `code` and `refresh_token` from cafebazaar)
- Change your configuration file and set your `client_id`, `client_secret` and `redirect_uri`.

#### Get refresh token

[](#get-refresh-token)

- Open this url in your browser:

```
https://pardakht.cafebazaar.ir/auth/authorize/?response_type=code&access_type=offline&redirect_uri=&client_id=

```

*- don't forget to change `` and ``.*

- After clicking on accept/confirm button, you'll go to : `?code=`

*- copy ``*

- Run this command:

```
php artisan bazaar:refresh-token

```

*- replace `` with the copied data.*

- Copy `refresh_token` and save in your configuration file. *(app/config/packages/nikapps/bazaar-api-laravel/config.php)*

#### Done!

[](#done)

Usage
-----

[](#usage)

#### Purchase

[](#purchase)

```
$purchase = BazaarApi::purchase('com.package.name', 'product_id', 'purchase_token');

//or you can pass an array
$purchase = BazaarApi::purchase([
	'package' => 'com.package.name',
	'product_id' => 'product_id',
	'purchase_token' => 'purchase_token'
]);

echo "Developer Payload: " . $purchase->getDeveloperPayload();
echo "PurchaseTime: " . $purchase->getPurchaseTime(); //instance of Carbon
echo "Consumption State: " . $purchase->getConsumptionState();
echo "Purchase State: " . $purchase->getPurchaseState();
echo "Kind: " . $purchase->getKind();
```

#### Subscription

[](#subscription)

```
$subscription = BazaarApi::subscription('com.package.name', 'subscription_id', 'purchase_token');

//or you can pass an array
$subscription = BazaarApi::subscription([
    'package' => 'com.package.name',
    'subscription_id' => 'subscription_id',
    'purchase_token' => 'purchase_token'
]);

echo "Initiation Time: " . $subscription->getInitiationTime(); // instance of Carbon
echo "Expiration Time: " . $subscription->getExpirationTime(); // instance of Carbon
echo "Auto Renewing: " . $subscription->isAutoRenewing(); // boolean
echo "Kind: " . $subscription->getKind();
```

#### Cancel Subscription

[](#cancel-subscription)

```
$cancelSubscription = BazaarApi::cancelSubscription('com.package.name', 'subscription_id', 'purchase_token');

//or you can pass an array
$cancelSubscription = BazaarApi::cancelSubscription([
    'package' => 'com.package.name',
    'subscription_id' => 'subscription_id',
    'purchase_token' => 'purchase_token'
]);

echo "Cancel Subscription: " . $cancelSubscription->isCancelled(); // bool
```

#### Refresh Token (Manually)

[](#refresh-token-manually)

This packages refreshes token when it's necessary, but if you want you can do it manually.

```
$token = BazaarApi::refreshToken();

echo 'Access Token: ' . $token->getAccessToken();
echo 'Scope: ' . $token->getScope();
echo 'Expire In: ' . $token->getExpireIn();
echo 'Token Type: ' . $token->getTokenType();
```

#### Clear Cache

[](#clear-cache)

Run this command to clean your cache, this command also invalidates your token.

```
php artisan bazaar:clear-cache

```

Dependencies
------------

[](#dependencies)

- [GuzzleHttp 5.2.x](https://packagist.org/packages/guzzlehttp/guzzle)
- [Bazaar-Api-PHP 1.x](https://packagist.org/packages/nikapps/bazaar-api-php)

Contribute
----------

[](#contribute)

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

License
-------

[](#license)

This project released under the [MIT License](http://opensource.org/licenses/mit-license.php).

```
/*
 * Copyright (C) 2015 NikApps Team.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * 1- The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * 2- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

```

Donation
--------

[](#donation)

[![Donate via Paypal](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G3WRCRDXJD6A8)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Total

2

Last Release

4126d ago

Major Versions

1.0.0 → 2.0.02015-03-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f76490bba7e578cb08504eafaa582eaf0b07ab01345f9b8fb50e435f7aa2002?d=identicon)[nikapps](/maintainers/nikapps)

![](https://www.gravatar.com/avatar/94f199381138539812836796c76244cdbe6e5d5167961e0f1f8b7d2665ba8b73?d=identicon)[alibo](/maintainers/alibo)

---

Top Contributors

[![alibo](https://avatars.githubusercontent.com/u/5338482?v=4)](https://github.com/alibo "alibo (16 commits)")[![moradgholi](https://avatars.githubusercontent.com/u/6699138?v=4)](https://github.com/moradgholi "moradgholi (1 commits)")

---

Tags

apilaravelwrapperCafeBazaarCafebazaar ApiIn App Purchaseiap

### Embed Badge

![Health badge](/badges/nikapps-bazaar-api-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/nikapps-bazaar-api-laravel/health.svg)](https://phpackages.com/packages/nikapps-bazaar-api-laravel)
```

###  Alternatives

[asciisd/zoho

Laravel wrapper for Zoho CRM API v8

3854.8k](/packages/asciisd-zoho)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[deviddev/billingo-api-v3-wrapper

This is a simple Laravel wrapper for Billingo (billingo.hu) API V3 SwaggerHUB PHP SDK.

2218.9k](/packages/deviddev-billingo-api-v3-wrapper)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.2k](/packages/dariusiii-tmdb-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
