Skip to content

Commit 09fda7d

Browse files
authored
Merge pull request #244 from XeroAPI/app_store
Add AppStore endpoints and other updates
2 parents 7338a2a + f57cc8a commit 09fda7d

29 files changed

+7710
-356
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,45 @@ To use this SDK with a Custom Connections:
521521
Because Custom Connections are only valid for a single organisation you don't need to pass the `xero-tenant-id` as the first parameter to every method, or more specifically for this SDK `xeroTenantId` can be an empty string.
522522

523523
---
524+
525+
## App Store Subscriptions
526+
527+
If you are implementing subscriptions to participate in Xero's App Store you will need to setup [App Store subscriptions](https://developer.xero.com/documentation/guides/how-to-guides/xero-app-store-referrals/) endpoints.
528+
529+
When a plan is successfully purchased, the user is redirected back to the URL specified in the setup process. The Xero App Store appends the subscription Id to this URL so you can immediately determine what plan the user has subscribed to through the subscriptions API.
530+
531+
With your app credentials you can create a client via `client_credentials` grant_type with the `marketplace.billing` scope. This unique access_token will allow you to query any functions in `appStoreApi`. Client Credentials tokens to query app store endpoints will only work for apps that have completed the App Store on-boarding process.
532+
533+
```php
534+
// => /post-purchase-url?subscriptionId=03bc74f2-1237-4477-b782-2dfb1a6d8b21
535+
536+
$provider = new \League\OAuth2\Client\Provider\GenericProvider([
537+
'clientId' => '__CLIENT_ID__',
538+
'clientSecret' => '__CLIENT_SECRET__',
539+
'urlAuthorize' => 'https://login.xero.com/identity/connect/authorize',
540+
'urlAccessToken' => 'https://identity.xero.com/connect/token',
541+
'urlResourceOwnerDetails' => 'https://identity.xero.com/resources'
542+
]);
543+
544+
$apiInstance = new XeroAPI\XeroPHP\Api\AppStoreApi(
545+
new GuzzleHttp\Client(),
546+
$config
547+
);
548+
549+
$accessToken = $provider->getAccessToken('client_credentials');
550+
551+
$apiResponse = $apiInstance->getSubscription($subscriptionId);
552+
553+
echo($apiResponse);
554+
```
555+
You should use this subscription data to provision user access/permissions to your application.
556+
557+
### App Store Subscription Webhooks
558+
559+
In additon to a subscription Id being passed through the URL, when a purchase or an upgrade takes place you will be notified via a webhook. You can then use the subscription Id in the webhook payload to query the AppStore endpoints and determine what plan the user purchased, upgraded, downgraded or cancelled.
560+
561+
Refer to Xero's documenation to learn more about setting up and receiving webhooks.
562+
> https://developer.xero.com/documentation/guides/webhooks/overview/
524563
## API Clients
525564
You can access the different API sets and their available methods through the following API sets:
526565
* AccountingApi
@@ -530,6 +569,8 @@ You can access the different API sets and their available methods through the fo
530569
* PayrollAuApi
531570
* PayrollNzApi
532571
* PayrollUkApi
572+
* AppStoreApi
573+
533574
```php
534575
<?php
535576
require_once(__DIR__ . '/vendor/autoload.php');

docs/v2/accounting/index.html

Lines changed: 552 additions & 6 deletions
Large diffs are not rendered by default.

docs/v2/appstore/index.html

Lines changed: 2993 additions & 0 deletions
Large diffs are not rendered by default.

docs/v2/assets/index.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@
13481348
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html" value="PayrollAu">Payroll AU</option>
13491349
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_uk/index.html" value="PayrollUk">Payroll UK</option>
13501350
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_nz/index.html" value="PayrollNz">Payroll NZ</option>
1351+
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/appstore/index.html" value="AppStore">AppStore</option>
13511352
</select>
13521353
</fieldset>
13531354
<div class='api-set-wrapper'>
@@ -1389,7 +1390,7 @@
13891390
<nav id="scrollingNav">
13901391
<ul class="sidenav nav nav-list">
13911392
<li class="nav-header" data-group="Asset"><strong>SDK: </strong><span id='sdk-name'></span></li>
1392-
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>2.7.0</li>
1393+
<li class="nav-header" data-group="Asset"><strong>VSN: </strong>2.8.0</li>
13931394
<li class="nav-header" data-group="Asset"><a href="#api-Asset">Methods</a></li>
13941395
<li data-group="Asset" data-name="createAsset" class="">
13951396
<a href="#api-Asset-createAsset">createAsset</a>
@@ -1738,6 +1739,11 @@ <h3>Usage and SDK Samples</h3>
17381739
<h2>Scopes</h2>
17391740
<table>
17401741

1742+
<tr>
1743+
<td>assets</td>
1744+
<td>Grant read-write access to fixed assets</td>
1745+
</tr>
1746+
17411747
<tr>
17421748
<td>assets.read</td>
17431749
<td>Grant read-only access to fixed assets</td>
@@ -1858,6 +1864,11 @@ <h3>Usage and SDK Samples</h3>
18581864
<h2>Scopes</h2>
18591865
<table>
18601866

1867+
<tr>
1868+
<td>assets</td>
1869+
<td>Grant read-write access to fixed assets</td>
1870+
</tr>
1871+
18611872
<tr>
18621873
<td>assets.read</td>
18631874
<td>Grant read-only access to fixed assets</td>
@@ -1945,6 +1956,11 @@ <h3>Usage and SDK Samples</h3>
19451956
<h2>Scopes</h2>
19461957
<table>
19471958

1959+
<tr>
1960+
<td>assets</td>
1961+
<td>Grant read-write access to fixed assets</td>
1962+
</tr>
1963+
19481964
<tr>
19491965
<td>assets.read</td>
19501966
<td>Grant read-only access to fixed assets</td>
@@ -2038,6 +2054,11 @@ <h3>Usage and SDK Samples</h3>
20382054
<h2>Scopes</h2>
20392055
<table>
20402056

2057+
<tr>
2058+
<td>assets</td>
2059+
<td>Grant read-write access to fixed assets</td>
2060+
</tr>
2061+
20412062
<tr>
20422063
<td>assets.read</td>
20432064
<td>Grant read-only access to fixed assets</td>

docs/v2/files/index.html

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@
11121112
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_au/index.html" value="PayrollAu">Payroll AU</option>
11131113
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_uk/index.html" value="PayrollUk">Payroll UK</option>
11141114
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/payroll_nz/index.html" value="PayrollNz">Payroll NZ</option>
1115+
<option data-url="https://xeroapi.github.io/xero-php-oauth2/docs/v2/appstore/index.html" value="AppStore">AppStore</option>
11151116
</select>
11161117
</fieldset>
11171118
<div class='api-set-wrapper'>
@@ -1153,7 +1154,7 @@
11531154
<nav id="scrollingNav">
11541155
<ul class="sidenav nav nav-list">
11551156
<li class="nav-header" data-group="Files"><strong>SDK: </strong><span id='sdk-name'></span></li>
1156-
<li class="nav-header" data-group="Files"><strong>VSN: </strong>2.7.0</li>
1157+
<li class="nav-header" data-group="Files"><strong>VSN: </strong>2.8.0</li>
11571158
<li class="nav-header" data-group="Files"><a href="#api-Files">Methods</a></li>
11581159
<li data-group="Files" data-name="createFileAssociation" class="">
11591160
<a href="#api-Files-createFileAssociation">createFileAssociation</a>
@@ -1934,6 +1935,11 @@ <h3>Usage and SDK Samples</h3>
19341935
<h2>Scopes</h2>
19351936
<table>
19361937

1938+
<tr>
1939+
<td>files</td>
1940+
<td>Grant read-write access to files and folders</td>
1941+
</tr>
1942+
19371943
<tr>
19381944
<td>files.read</td>
19391945
<td>Grant read-only access to files and folders</td>
@@ -2055,6 +2061,11 @@ <h3>Usage and SDK Samples</h3>
20552061
<h2>Scopes</h2>
20562062
<table>
20572063

2064+
<tr>
2065+
<td>files</td>
2066+
<td>Grant read-write access to files and folders</td>
2067+
</tr>
2068+
20582069
<tr>
20592070
<td>files.read</td>
20602071
<td>Grant read-only access to files and folders</td>
@@ -2176,6 +2187,11 @@ <h3>Usage and SDK Samples</h3>
21762187
<h2>Scopes</h2>
21772188
<table>
21782189

2190+
<tr>
2191+
<td>files</td>
2192+
<td>Grant read-write access to files and folders</td>
2193+
</tr>
2194+
21792195
<tr>
21802196
<td>files.read</td>
21812197
<td>Grant read-only access to files and folders</td>
@@ -2297,6 +2313,11 @@ <h3>Usage and SDK Samples</h3>
22972313
<h2>Scopes</h2>
22982314
<table>
22992315

2316+
<tr>
2317+
<td>files</td>
2318+
<td>Grant read-write access to files and folders</td>
2319+
</tr>
2320+
23002321
<tr>
23012322
<td>files.read</td>
23022323
<td>Grant read-only access to files and folders</td>
@@ -2420,6 +2441,11 @@ <h3>Usage and SDK Samples</h3>
24202441
<h2>Scopes</h2>
24212442
<table>
24222443

2444+
<tr>
2445+
<td>files</td>
2446+
<td>Grant read-write access to files and folders</td>
2447+
</tr>
2448+
24232449
<tr>
24242450
<td>files.read</td>
24252451
<td>Grant read-only access to files and folders</td>
@@ -2575,6 +2601,11 @@ <h3>Usage and SDK Samples</h3>
25752601
<h2>Scopes</h2>
25762602
<table>
25772603

2604+
<tr>
2605+
<td>files</td>
2606+
<td>Grant read-write access to files and folders</td>
2607+
</tr>
2608+
25782609
<tr>
25792610
<td>files.read</td>
25802611
<td>Grant read-only access to files and folders</td>
@@ -2696,6 +2727,11 @@ <h3>Usage and SDK Samples</h3>
26962727
<h2>Scopes</h2>
26972728
<table>
26982729

2730+
<tr>
2731+
<td>files</td>
2732+
<td>Grant read-write access to files and folders</td>
2733+
</tr>
2734+
26992735
<tr>
27002736
<td>files.read</td>
27012737
<td>Grant read-only access to files and folders</td>
@@ -2810,6 +2846,11 @@ <h3>Usage and SDK Samples</h3>
28102846
<h2>Scopes</h2>
28112847
<table>
28122848

2849+
<tr>
2850+
<td>files</td>
2851+
<td>Grant read-write access to files and folders</td>
2852+
</tr>
2853+
28132854
<tr>
28142855
<td>files.read</td>
28152856
<td>Grant read-only access to files and folders</td>

0 commit comments

Comments
 (0)