| Package Data | |
|---|---|
| Maintainer Username: | nikapps | 
| Maintainer Contact: | h.moradgholi@icloud.com (Hossein Moradgholi) | 
| Package Create Date: | 2015-03-04 | 
| Package Last Update: | 2017-02-15 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-30 03:01:42 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 23 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 1 | 
| Total Watchers: | 2 | 
| Total Forks: | 0 | 
| Total Open Issues: | 1 | 
An Easy-To-Use CafeBazaar API helper package for Laravel Framework (Laravel 4.2.x)
Version 2.x is based on Bazaar-Api-PHP.
Simply run command:
composer require nikapps/bazaar-api-laravel
Or you can add this package 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 !
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.
https://pardakht.cafebazaar.ir/auth/authorize/?response_type=code&access_type=offline&redirect_uri=<REDIRECT_URI>&client_id=<CLIENT_ID>
- don't forget to change <REDIRECT_URI> and <CLIENT_ID>.
<REDIRECT_URI>?code=<CODE>
- copy  <CODE>
php artisan bazaar:refresh-token <CODE>
- replace <CODE> with the copied data.
refresh_token and save in your configuration file.
(app/config/packages/nikapps/bazaar-api-laravel/config.php)
$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 = 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();
$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
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();
Run this command to clean your cache, this command also invalidates your token.
php artisan bazaar:clear-cache
Wanna contribute? simply fork this project and make a pull request!
This project released under the MIT License.
/*
 * 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.
 */