nikapps/bazaar-api-laravel
Composer 安装命令:
composer create-project nikapps/bazaar-api-laravel
包简介
An API wrapper for cafebazaar based on popular Laravel Framework
README 文档
README
An Easy-To-Use CafeBazaar API helper package for Laravel Framework (Laravel 4.2.x)
Version 2.x is based on Bazaar-Api-PHP.
Installation
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 !
Configuration
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 clientand enter your redirect uri (you have to set it for gettingcodeandrefresh_tokenfrom cafebazaar) -
Change your configuration file and set your
client_id,client_secretandredirect_uri.
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>.
- After clicking on accept/confirm button, you'll go to :
<REDIRECT_URI>?code=<CODE>
- copy <CODE>
- Run this command:
php artisan bazaar:refresh-token <CODE>
- replace <CODE> with the copied data.
- Copy
refresh_tokenand 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.
$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.
php artisan bazaar:clear-cache
Dependencies
Contribute
Wanna contribute? simply fork this project and make a pull request!
License
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.
*/
Donation
nikapps/bazaar-api-laravel 适用场景与选型建议
nikapps/bazaar-api-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「wrapper」 「laravel」 「CafeBazaar」 「Cafebazaar Api」 「In App Purchase」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nikapps/bazaar-api-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nikapps/bazaar-api-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nikapps/bazaar-api-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
A PSR-7 compatible library for making CRUD API endpoints
gv config package
A PHP (read-only) wrapper for the Git command line utility
Alfabank REST API integration
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-04