|
1 | 1 | # Amazon Selling Partner API - PHP SDK
|
2 | 2 |
|
| 3 | +This repository is not an official amazon PHP library for their SP API. |
| 4 | + |
3 | 5 | ### Why next library?
|
4 | 6 |
|
5 |
| -There are already few php sp api sdk's available for [PHP](https://packagist.org/?query=sp%20api%20) |
6 |
| -however most of them comes with all issues of auto generated code. |
| 7 | +There are already few php sp api SDKs available for [PHP](https://packagist.org/?query=sp%20api%20) |
| 8 | +however most of them comes with many issues of auto generated code. |
7 | 9 |
|
8 |
| -- hardcoded `guzzlehttp/guzzle` or `aws/aws-sdk-php` dependency |
| 10 | +- hardcoded dependencies like `guzzlehttp/guzzle` or `aws/aws-sdk-php` |
9 | 11 | - legacy code base (7.2)
|
10 | 12 | - no logger
|
11 | 13 | - SDK's are oriented around single seller which is not suitable for bigger systems
|
12 | 14 | - missing or lacking support for `client_credentials` grant type
|
13 | 15 | - not all API covered
|
14 | 16 | - no extensions
|
15 | 17 |
|
16 |
| -This API goal is to resolve all above mentioned issues. |
| 18 | +This library goal is to resolve all above mentioned issues. |
| 19 | + |
| 20 | +### Installations |
| 21 | + |
| 22 | +``` |
| 23 | +composer install amazon-php/sp-api-sdk^1.0@dev |
| 24 | +``` |
| 25 | + |
| 26 | +This library is not in a stable stage yet, please use with caution. |
| 27 | + |
| 28 | +### Available SDKs |
| 29 | + |
| 30 | +* [APlusSDK](/src/AmazonPHP/SellingPartner/Api/APlusSDK.php) |
| 31 | +* [AuthorizationSDK](/src/AmazonPHP/SellingPartner/Api/AuthorizationSDK.php) |
| 32 | +* [CatalogItemSDK](/src/AmazonPHP/SellingPartner/Api/CatalogItemSDK.php) |
| 33 | +* [FBAInboundSDK](/src/AmazonPHP/SellingPartner/Api/FBAInboundSDK.php) |
| 34 | +* [FBAInventorySDK](/src/AmazonPHP/SellingPartner/Api/FBAInventorySDK.php) |
| 35 | +* [FBASmallAndLightSDK](/src/AmazonPHP/SellingPartner/Api/FBASmallAndLightSDK.php) |
| 36 | +* [FeedsSDK](/src/AmazonPHP/SellingPartner/Api/FeedsSDK.php) |
| 37 | +* [FinancesSDK](/src/AmazonPHP/SellingPartner/Api/FinancesSDK.php) |
| 38 | +* [FulfillmentOutboundSDK](/src/AmazonPHP/SellingPartner/Api/FulfillmentOutboundSDK.php) |
| 39 | +* [ListingsItemsSDK](/src/AmazonPHP/SellingPartner/Api/ListingsItemsSDK.php) |
| 40 | +* [MessagingSDK](/src/AmazonPHP/SellingPartner/Api/MessagingSDK.php) |
| 41 | +* [NotificationsSDK](/src/AmazonPHP/SellingPartner/Api/NotificationsSDK.php) |
| 42 | +* [OrdersSDK](/src/AmazonPHP/SellingPartner/Api/OrdersSDK.php) |
| 43 | +* [ProductFeesSDK](/src/AmazonPHP/SellingPartner/Api/ProductFeesSDK.php) |
| 44 | +* [Product#SDK](/src/AmazonPHP/SellingPartner/Api/Product#SDK.php) |
| 45 | +* [ProductTypesDefinitionsSDK](/src/AmazonPHP/SellingPartner/Api/ProductTypesDefinitionsSDK.php) |
| 46 | +* [ReportsSDK](/src/AmazonPHP/SellingPartner/Api/ReportsSDK.php) |
| 47 | +* [SalesSDK](/src/AmazonPHP/SellingPartner/Api/SalesSDK.php) |
| 48 | +* [SellersSDK](/src/AmazonPHP/SellingPartner/Api/SellersSDK.php) |
| 49 | +* [ServicesSDK](/src/AmazonPHP/SellingPartner/Api/ServicesSDK.php) |
| 50 | +* [ShipmentInvoicingSDK](/src/AmazonPHP/SellingPartner/Api/ShipmentInvoicingSDK.php) |
| 51 | +* [SolicitationsSDK](/src/AmazonPHP/SellingPartner/Api/SolicitationsSDK.php) |
| 52 | +* [TokensSDK](/src/AmazonPHP/SellingPartner/Api/TokensSDK.php) |
| 53 | +* [UploadsSDK](/src/AmazonPHP/SellingPartner/Api/UploadsSDK.php) |
| 54 | + |
| 55 | +### Authorization |
| 56 | + |
| 57 | +In order to start using SP API you need to first register as a Developer and create application. |
| 58 | +Whole process is described in [Amazon Official Guides](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md). |
| 59 | + |
| 60 | +Normally amazon recommends to use Role IAM when creating application however this requires and additional |
| 61 | +API call when obtaining refresh token. It's easier to use User IAM and just make sure that the user |
| 62 | +has following Inline Policy |
| 63 | + |
| 64 | +``` |
| 65 | +{ |
| 66 | + "Version": "2012-10-17", |
| 67 | + "Statement": [ |
| 68 | + { |
| 69 | + "Effect": "Allow", |
| 70 | + "Action": "execute-api:Invoke", |
| 71 | + "Resource": "arn:aws:execute-api:*:*:*" |
| 72 | + } |
| 73 | + ] |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +#### IAM User |
| 78 | + |
| 79 | +Example of changing refresh token into access token. |
| 80 | + |
| 81 | +``` |
| 82 | +<?php |
| 83 | +
|
| 84 | +use AmazonPHP\SellingPartner\OAuth; |
| 85 | +use AmazonPHP\SellingPartner\Configuration; |
| 86 | +use AmazonPHP\SellingPartner\HttpFactory; |
| 87 | +
|
| 88 | +$oauth = new OAuth( |
| 89 | + $client, |
| 90 | + $httpFactory = new HttpFactory($factory, $factory), |
| 91 | + $config = Configuration::forIAMUser( |
| 92 | + 'lwaClientID', |
| 93 | + 'lwaClientID', |
| 94 | + 'awsAccessKey', |
| 95 | + 'awsSecretKey' |
| 96 | + ) |
| 97 | +); |
| 98 | +
|
| 99 | +$accessToken = $oauth->exchangeRefreshToken('seller_oauth_refresh_token'); |
| 100 | +``` |
| 101 | + |
| 102 | +#### IAM Role |
| 103 | + |
| 104 | +@TODO |
17 | 105 |
|
18 | 106 | ### Development
|
19 | 107 |
|
|
0 commit comments