2017 © Pedro Peláez
 

project bazaar-api-laravel

An API wrapper for cafebazaar based on popular Laravel Framework

image

nikapps/bazaar-api-laravel

An API wrapper for cafebazaar based on popular Laravel Framework

  • Wednesday, February 15, 2017
  • by alibo
  • Repository
  • 2 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Bazaar-Api-Laravel (BazaarApi for Laravel)

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

Version 2.x is based on Bazaar-Api-PHP., (*2)

Installation

Simply run command:, (*3)

composer require nikapps/bazaar-api-laravel

Or you can add this package dependency to your Laravel's composer.json :, (*4)

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

}

Then update composer:, (*5)

composer update

-, (*6)

Add this package provider in your providers array [app/config/app.php]:, (*7)

'Nikapps\BazaarApiLaravel\BazaarApiLaravelServiceProvider',

Next you need to publish configuration file. Run this command:, (*8)

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

Run :, (*9)

php artisan

If you see a bazaar:refresh-token command, you are all set to go !, (*10)

Configuration

Create a client

First of all, you should go to your cafebazaar panel and get client id and client secret., (*11)

  • Login to your panel and go to this url: (Developer API section) http://pardakht.cafebazaar.ir/panel/developer-api/?l=fa, (*12)

  • Click on new client and enter your redirect uri (you have to set it for getting code and refresh_token from cafebazaar), (*13)

  • Change your configuration file and set your client_id, client_secret and redirect_uri., (*14)

Get refresh token

  • Open this url in your browser:
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>., (*15)

  • After clicking on accept/confirm button, you'll go to : <REDIRECT_URI>?code=<CODE>

- copy <CODE>, (*16)

  • Run this command:
php artisan bazaar:refresh-token <CODE>

- replace <CODE> with the copied data., (*17)

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

Done!

Usage

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 = 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

$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)

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

$token = BazaarApi::refreshToken();

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

Clear Cache

Run this command to clean your cache, this command also invalidates your token., (*19)

php artisan bazaar:clear-cache

Dependencies

Contribute

Wanna contribute? simply fork this project and make a pull request!, (*20)

License

This project released under the MIT License., (*21)

/*
 * 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

Donate via Paypal, (*22)

The Versions

15/02 2017

dev-shift-2512

dev-shift-2512

An API wrapper for cafebazaar based on popular Laravel Framework

  Sources   Download

MIT

The Requires

 

by Ali Borhani
by Hossein Moradgholi

laravel api wrapper cafebazaar cafebazaar api in app purchase iap

19/03 2015

dev-master

9999999-dev

An API wrapper for cafebazaar based on popular Laravel Framework

  Sources   Download

MIT

The Requires

 

by Ali Borhani
by Hossein Moradgholi

laravel api wrapper cafebazaar cafebazaar api in app purchase iap

18/03 2015

2.0.0

2.0.0.0

An API wrapper for cafebazaar based on popular Laravel Framework

  Sources   Download

MIT

The Requires

 

by Ali Borhani
by Hossein Moradgholi

laravel api wrapper cafebazaar cafebazaar api in app purchase iap

04/03 2015

1.0.0

1.0.0.0

An API wrapper for cafebazaar based on popular Laravel Framework

  Sources   Download

MIT

The Requires

 

by Ali Borhani
by Hossein Moradgholi

laravel api wrapper cafebazaar cafebazaar api in app purchase iap