Skip to content

Commit

Permalink
fix return type of cancelSubscription
Browse files Browse the repository at this point in the history
  • Loading branch information
alibo committed Mar 18, 2015
1 parent 5e1fc55 commit 82121f1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 42 deletions.
66 changes: 25 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# Bazaar-Api-Laravel (BazaarApi for Laravel)
An API wrapper for CafeBazaar based on popular Laravel PHP Framework (Laravel 4.x)
An API wrapper for CafeBazaar based on popular Laravel PHP Framework (Laravel 4.2.x)

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

## Installation
Using composer, add this [package](https://packagist.org/packages/nikapps/bazaar-api-laravel) dependency to your Laravel's composer.json :

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 :

~~~json
{
"require": {
"nikapps/bazaar-api-laravel": "1.*"
"nikapps/bazaar-api-laravel": "2.*"
}
}
~~~
Expand All @@ -19,6 +27,8 @@ Then update composer:
composer update
```

-

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

~~~php
Expand Down Expand Up @@ -71,7 +81,8 @@ php artisan bazaar:refresh-token <CODE>
```
*- replace `<CODE>` with the copied data.*

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

#### Done!

Expand All @@ -84,51 +95,24 @@ php artisan bazaar:refresh-token <CODE>
If you want to get a purchase information:

~~~php
$bazaarApi = new BazaarApi();
$purchase = BazaarApi::purchase('com.package.name', 'product_id', 'purchase_token');

//creating purchase request
$purchaseStatusRequest = new PurchaseStatusRequest();
$purchaseStatusRequest->setPackage('com.package.name');
$purchaseStatusRequest->setProductId('product_id');
$purchaseStatusRequest->setPurchaseToken('123456789123456789');

//send request to cafebazaar and get purchase info
$purchase = $bazaarApi->getPurchase($purchaseStatusRequest);

//if response is valid and we have this purchase
if($purchase->isOk()){
echo "Developer Payload: " . $purchase->getDeveloperPayload();
echo "PurchaseTime: " . $purchase->getPurchaseTime(); //instance of Carbon
echo "Consumption State: " . $purchase->getConsumptionState();
echo "Purchase State: " . $purchase->getPurchaseState();
}else{
echo 'Failed!';
}
echo "Developer Payload: " . $purchase->getDeveloperPayload();
echo "PurchaseTime: " . $purchase->getPurchaseTime(); //instance of Carbon
echo "Consumption State: " . $purchase->getConsumptionState();
echo "Purchase State: " . $purchase->getPurchaseState();
~~~

#### Subscription
If you want to get a subscription information:

~~~php
$bazaarApi = new BazaarApi();

//creating subscription request
$subscriptionStatusRequest = new SubscriptionStatusRequest();
$subscriptionStatusRequest->setPackage('com.package.name');
$subscriptionStatusRequest->setSubscriptionId('subscription_id');
$subscriptionStatusRequest->setPurchaseToken('123456789123456789');

//send request to cafebazaar and get subscription info
$subscription = $bazaarApi->getSubscription($subscriptionStatusRequest);
$subscription = BazaarApi::subscription('com.package.name', 'subscription_id', 'purchase_token');

//if response is valid and we have this subscription
if ($subscription->isOk()) {
echo "Initiation Time: " . $subscription->getInitiationTime(); // instance of Carbon
echo "Expiration Time: " . $subscription->getExpirationTime(); // instance of Carbon
echo "Auto Renewing: " . $subscription->isAutoRenewing(); // boolean
} else {
echo 'Failed!';
}
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
Expand Down
2 changes: 1 addition & 1 deletion src/Nikapps/BazaarApiLaravel/BazaarApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function subscription($packageNameOrRequestOrArray, $subscriptionId = nul
* @param CancelSubscriptionRequest|array|string $packageNameOrRequestOrArray
* @param string|null $subscriptionId
* @param string|null $purchaseToken
* @return \Nikapps\BazaarApiPhp\Models\Responses\Subscription
* @return \Nikapps\BazaarApiPhp\Models\Responses\CancelSubscription
* @throws ExpiredAccessTokenException
* @throws \Nikapps\BazaarApiPhp\Exceptions\InvalidPackageNameException
* @throws \Nikapps\BazaarApiPhp\Exceptions\InvalidTokenException
Expand Down

0 comments on commit 82121f1

Please sign in to comment.