Skip to content

Commit 82121f1

Browse files
committed
fix return type of cancelSubscription
1 parent 5e1fc55 commit 82121f1

File tree

2 files changed

+26
-42
lines changed

2 files changed

+26
-42
lines changed

README.md

+25-41
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Bazaar-Api-Laravel (BazaarApi for Laravel)
2-
An API wrapper for CafeBazaar based on popular Laravel PHP Framework (Laravel 4.x)
2+
An API wrapper for CafeBazaar based on popular Laravel PHP Framework (Laravel 4.2.x)
33

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

56
## Installation
6-
Using composer, add this [package](https://packagist.org/packages/nikapps/bazaar-api-laravel) dependency to your Laravel's composer.json :
7+
8+
Simply run command:
9+
10+
```
11+
composer require nikapps/bazaar-api-laravel
12+
```
13+
14+
Or you can add this [package](https://packagist.org/packages/nikapps/bazaar-api-laravel) dependency to your Laravel's composer.json :
715

816
~~~json
917
{
1018
"require": {
11-
"nikapps/bazaar-api-laravel": "1.*"
19+
"nikapps/bazaar-api-laravel": "2.*"
1220
}
1321
}
1422
~~~
@@ -19,6 +27,8 @@ Then update composer:
1927
composer update
2028
```
2129

30+
-
31+
2232
Add this package provider in your providers array `[app/config/app.php]`:
2333

2434
~~~php
@@ -71,7 +81,8 @@ php artisan bazaar:refresh-token <CODE>
7181
```
7282
*- replace `<CODE>` with the copied data.*
7383

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

7687
#### Done!
7788

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

8697
~~~php
87-
$bazaarApi = new BazaarApi();
98+
$purchase = BazaarApi::purchase('com.package.name', 'product_id', 'purchase_token');
8899

89-
//creating purchase request
90-
$purchaseStatusRequest = new PurchaseStatusRequest();
91-
$purchaseStatusRequest->setPackage('com.package.name');
92-
$purchaseStatusRequest->setProductId('product_id');
93-
$purchaseStatusRequest->setPurchaseToken('123456789123456789');
94-
95-
//send request to cafebazaar and get purchase info
96-
$purchase = $bazaarApi->getPurchase($purchaseStatusRequest);
97-
98-
//if response is valid and we have this purchase
99-
if($purchase->isOk()){
100-
echo "Developer Payload: " . $purchase->getDeveloperPayload();
101-
echo "PurchaseTime: " . $purchase->getPurchaseTime(); //instance of Carbon
102-
echo "Consumption State: " . $purchase->getConsumptionState();
103-
echo "Purchase State: " . $purchase->getPurchaseState();
104-
}else{
105-
echo 'Failed!';
106-
}
100+
echo "Developer Payload: " . $purchase->getDeveloperPayload();
101+
echo "PurchaseTime: " . $purchase->getPurchaseTime(); //instance of Carbon
102+
echo "Consumption State: " . $purchase->getConsumptionState();
103+
echo "Purchase State: " . $purchase->getPurchaseState();
107104
~~~
108105

109106
#### Subscription
110107
If you want to get a subscription information:
111108

112109
~~~php
113-
$bazaarApi = new BazaarApi();
114-
115-
//creating subscription request
116-
$subscriptionStatusRequest = new SubscriptionStatusRequest();
117-
$subscriptionStatusRequest->setPackage('com.package.name');
118-
$subscriptionStatusRequest->setSubscriptionId('subscription_id');
119-
$subscriptionStatusRequest->setPurchaseToken('123456789123456789');
120-
121-
//send request to cafebazaar and get subscription info
122-
$subscription = $bazaarApi->getSubscription($subscriptionStatusRequest);
110+
$subscription = BazaarApi::subscription('com.package.name', 'subscription_id', 'purchase_token');
123111

124-
//if response is valid and we have this subscription
125-
if ($subscription->isOk()) {
126-
echo "Initiation Time: " . $subscription->getInitiationTime(); // instance of Carbon
127-
echo "Expiration Time: " . $subscription->getExpirationTime(); // instance of Carbon
128-
echo "Auto Renewing: " . $subscription->isAutoRenewing(); // boolean
129-
} else {
130-
echo 'Failed!';
131-
}
112+
echo "Initiation Time: " . $subscription->getInitiationTime(); // instance of Carbon
113+
echo "Expiration Time: " . $subscription->getExpirationTime(); // instance of Carbon
114+
echo "Auto Renewing: " . $subscription->isAutoRenewing(); // boolean
115+
echo "Kind: " . $subscription->getKind();
132116
~~~
133117

134118
#### Cancel Subscription

src/Nikapps/BazaarApiLaravel/BazaarApiFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function subscription($packageNameOrRequestOrArray, $subscriptionId = nul
158158
* @param CancelSubscriptionRequest|array|string $packageNameOrRequestOrArray
159159
* @param string|null $subscriptionId
160160
* @param string|null $purchaseToken
161-
* @return \Nikapps\BazaarApiPhp\Models\Responses\Subscription
161+
* @return \Nikapps\BazaarApiPhp\Models\Responses\CancelSubscription
162162
* @throws ExpiredAccessTokenException
163163
* @throws \Nikapps\BazaarApiPhp\Exceptions\InvalidPackageNameException
164164
* @throws \Nikapps\BazaarApiPhp\Exceptions\InvalidTokenException

0 commit comments

Comments
 (0)