├── LICENSE
├── README.md
├── composer.json
└── src
├── Config
└── ebay.php
├── Ebay.php
├── EbayServiceProvider.php
├── EbayServices.php
└── Facade
└── Ebay.php
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 hkonnet
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Ebay
2 |
3 | [](//packagist.org/packages/hkonnet/laravel-ebay)
4 | [](//packagist.org/packages/hkonnet/laravel-ebay)
5 | [](//packagist.org/packages/hkonnet/laravel-ebay)
6 | [](//packagist.org/packages/hkonnet/laravel-ebay)
7 |
8 | This package is based on [Ebay SDK](https://github.com/davidtsadler/ebay-sdk-php) written by David T. Sadler.
9 | This package will organize all the configuration according to laravel and make you use the SDK with out doing any exceptional work or configurations.
10 |
11 | ## Getting Started
12 |
13 | Follow the instruction to install and use this package.
14 |
15 | ### Prerequisites
16 |
17 | This is package use [**Ebay Php SDK**](http://devbay.net/)
18 |
19 | ### Installing
20 |
21 | Add Laravel-Ebay to your composer file via the composer require command:
22 |
23 |
24 | ```bash
25 | $ composer require hkonnet/laravel-ebay
26 | ```
27 |
28 | Or add it to `composer.json` manually:
29 |
30 | ```json
31 | "require": {
32 | "hkonnet/laravel-ebay": "^1.2"
33 | }
34 | ```
35 |
36 | Register the service provider by adding it to the providers key in config/app.php. Also register the facade by adding it to the aliases key in config/app.php.
37 |
38 | **Laravel 5.1 or greater**
39 | ```php
40 | 'providers' => [
41 | ...
42 | Hkonnet\LaravelEbay\EbayServiceProvider::class,
43 | ],
44 |
45 | 'aliases' => [
46 | ...
47 | 'Ebay' => Hkonnet\LaravelEbay\Facade\Ebay::class,
48 | ]
49 | ```
50 | **Laravel 5**
51 | ```php
52 | 'providers' => [
53 | ...
54 | 'Hkonnet\LaravelEbay\EbayServiceProvider',
55 | ],
56 |
57 | 'aliases' => [
58 | ...
59 | 'Ebay' => 'Hkonnet\LaravelEbay\Facade\Ebay',
60 | ]
61 | ```
62 |
63 | Next to get started, you'll need to publish all vendor assets:
64 |
65 | ```bash
66 | $ php artisan vendor:publish --provider="Hkonnet\LaravelEbay\EbayServiceProvider"
67 | ```
68 | This will create a config/ebay.php file in your app that you can modify to set your configuration.
69 |
70 | ###Configuration
71 | After installation, you will need to add your ebay settings. Following is the code you will find in config/ebay.php, which you should update accordingly.
72 |
73 | ```php
74 | return [
75 | 'mode' => env('EBAY_MODE', 'sandbox'),
76 |
77 | 'siteId' => env('EBAY_SITE_ID','0'),
78 |
79 | 'sandbox' => [
80 | 'credentials' => [
81 | 'devId' => env('EBAY_SANDBOX_DEV_ID'),
82 | 'appId' => env('EBAY_SANDBOX_APP_ID'),
83 | 'certId' => env('EBAY_SANDBOX_CERT_ID'),
84 | ],
85 | 'authToken' => env('EBAY_SANDBOX_AUTH_TOKEN'),
86 | 'oauthUserToken' => env('EBAY_SANDBOX_OAUTH_USER_TOKEN'),
87 | ],
88 | 'production' => [
89 | 'credentials' => [
90 | 'devId' => env('EBAY_PROD_DEV_ID'),
91 | 'appId' => env('EBAY_PROD_APP_ID'),
92 | 'certId' => env('EBAY_PROD_CERT_ID'),
93 | ],
94 | 'authToken' => env('EBAY_PROD_AUTH_TOKEN'),
95 | 'oauthUserToken' => env('EBAY_PROD_OAUTH_USER_TOKEN'),
96 | ]
97 | ];
98 | ```
99 |
100 | ## Usage
101 |
102 | Following are few examples for using this package.
103 |
104 | ### Ex 1: Get the official eBay time
105 |
106 | Following are the two ways you can do it
107 |
108 | **Method 1:**
109 |
110 | ```php
111 | use \Hkonnet\LaravelEbay\EbayServices;
112 | use \DTS\eBaySDK\Shopping\Types;
113 |
114 | // Create the service object.
115 | $ebay_service = new EbayServices();
116 | $service = $ebay_service->createShopping();
117 |
118 | // Create the request object.
119 | $request = new Types\GeteBayTimeRequestType();
120 |
121 | // Send the request to the service operation.
122 | $response = $service->geteBayTime($request);
123 |
124 | // Output the result of calling the service operation.
125 | printf("The official eBay time is: %s\n", $response->Timestamp->format('H:i (\G\M\T) \o\n l jS Y'));
126 | ```
127 |
128 | **Method 2:**
129 |
130 | > **Tip:** If you prefer to use **DTS** library class you need to pass the configuration.
131 |
132 | ```php
133 | use \DTS\eBaySDK\Shopping\Services;
134 | use \DTS\eBaySDK\Shopping\Types;
135 |
136 | $config = Ebay::getConfig();
137 |
138 | // Create the service object.
139 | $service = new Services\ShoppingService($config);
140 |
141 | // Create the request object.
142 | $request = new Types\GeteBayTimeRequestType();
143 |
144 | // Send the request to the service operation.
145 | $response = $service->geteBayTime($request);
146 |
147 | // Output the result of calling the service operation.
148 | printf("The official eBay time is: %s\n", $response->Timestamp->format('H:i (\G\M\T) \o\n l jS Y'));
149 | ```
150 |
151 | ### Ex 2: Find items by keyword
152 |
153 | This example will call the findItemsByKeywords operation
154 |
155 | **Method 1:**
156 | ```php
157 | use \Hkonnet\LaravelEbay\EbayServices;
158 | use \DTS\eBaySDK\Finding\Types;
159 |
160 | // Create the service object.
161 | $ebay_service = new EbayServices();
162 | $service = $ebay_service->createFinding();
163 |
164 | // Assign the keywords.
165 | $request = new Types\FindItemsByKeywordsRequest();
166 | $request->keywords = 'Harry Potter';
167 |
168 | // Ask for the first 25 items.
169 | $request->paginationInput = new Types\PaginationInput();
170 | $request->paginationInput->entriesPerPage = 25;
171 | $request->paginationInput->pageNumber = 1;
172 |
173 | // Ask for the results to be sorted from high to low price.
174 | $request->sortOrder = 'CurrentPriceHighest';
175 |
176 | $response = $service->findItemsByKeywords($request);
177 |
178 | // Output the response from the API.
179 | if ($response->ack !== 'Success') {
180 | foreach ($response->errorMessage->error as $error) {
181 | printf("Error: %s
", $error->message);
182 | }
183 | } else {
184 | foreach ($response->searchResult->item as $item) {
185 | printf("(%s) %s:%.2f
", $item->itemId, $item->title, $item->sellingStatus->currentPrice->value);
186 | }
187 | }
188 |
189 | ```
190 |
191 | **Method 2:**
192 | ```php
193 | use DTS\eBaySDK\Finding\Services\FindingService;
194 | use \DTS\eBaySDK\Finding\Types;
195 |
196 | // Create the service object.
197 | $config = Ebay::getConfig();
198 | $service = new FindingService($config);
199 |
200 | // Assign the keywords.
201 | $request = new Types\FindItemsByKeywordsRequest();
202 | $request->keywords = 'Harry Potter';
203 |
204 | // Ask for the first 25 items.
205 | $request->paginationInput = new Types\PaginationInput();
206 | $request->paginationInput->entriesPerPage = 25;
207 | $request->paginationInput->pageNumber = 1;
208 |
209 | // Ask for the results to be sorted from high to low price.
210 | $request->sortOrder = 'CurrentPriceHighest';
211 |
212 | $response = $service->findItemsByKeywords($request);
213 |
214 | // Output the response from the API.
215 | if ($response->ack !== 'Success') {
216 | foreach ($response->errorMessage->error as $error) {
217 | printf("Error: %s
", $error->message);
218 | }
219 | } else {
220 | foreach ($response->searchResult->item as $item) {
221 | printf("(%s) %s:%.2f
", $item->itemId, $item->title, $item->sellingStatus->currentPrice->value);
222 | }
223 | }
224 |
225 | ```
226 |
227 | ### Ex 3. Get my ebay selling
228 |
229 | ```php
230 | use \DTS\eBaySDK\Constants;
231 | use \DTS\eBaySDK\Trading\Types;
232 | use \DTS\eBaySDK\Trading\Enums;
233 | use \Hkonnet\LaravelEbay\EbayServices;
234 |
235 | /**
236 | * Create the service object.
237 | */
238 | $ebay_service = new EbayServices();
239 | $service = $ebay_service->createTrading();
240 |
241 | /**
242 | * Create the request object.
243 | */
244 | $request = new Types\GetMyeBaySellingRequestType();
245 |
246 | /**
247 | * An user token is required when using the Trading service.
248 | */
249 | $request->RequesterCredentials = new Types\CustomSecurityHeaderType();
250 | $authToken = Ebay::getAuthToken();
251 | $request->RequesterCredentials->eBayAuthToken = $authToken;
252 |
253 | /**
254 | * Request that eBay returns the list of actively selling items.
255 | * We want 10 items per page and they should be sorted in descending order by the current price.
256 | */
257 | $request->ActiveList = new Types\ItemListCustomizationType();
258 | $request->ActiveList->Include = true;
259 | $request->ActiveList->Pagination = new Types\PaginationType();
260 | $request->ActiveList->Pagination->EntriesPerPage = 10;
261 | $request->ActiveList->Sort = Enums\ItemSortTypeCodeType::C_CURRENT_PRICE_DESCENDING;
262 | $pageNum = 1;
263 |
264 | do {
265 | $request->ActiveList->Pagination->PageNumber = $pageNum;
266 |
267 | /**
268 | * Send the request.
269 | */
270 | $response = $service->getMyeBaySelling($request);
271 |
272 | /**
273 | * Output the result of calling the service operation.
274 | */
275 | echo "==================\nResults for page $pageNum\n==================\n";
276 | if (isset($response->Errors)) {
277 | foreach ($response->Errors as $error) {
278 | printf(
279 | "%s: %s\n%s\n\n",
280 | $error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning',
281 | $error->ShortMessage,
282 | $error->LongMessage
283 | );
284 | }
285 | }
286 | if ($response->Ack !== 'Failure' && isset($response->ActiveList)) {
287 | foreach ($response->ActiveList->ItemArray->Item as $item) {
288 | printf(
289 | "(%s) %s: %s %.2f\n",
290 | $item->ItemID,
291 | $item->Title,
292 | $item->SellingStatus->CurrentPrice->currencyID,
293 | $item->SellingStatus->CurrentPrice->value
294 | );
295 | }
296 | }
297 | $pageNum += 1;
298 | } while (isset($response->ActiveList) && $pageNum <= $response->ActiveList->PaginationResult->TotalNumberOfPages);
299 |
300 | ```
301 | > **Note:**
302 | > - There are lots for more example available at [Ebay SDK Examples](https://github.com/davidtsadler/ebay-sdk-examples).
303 | > - Follow above examples but read the Important note below.
304 |
305 | ## Important Note
306 | Using method 1 in both examples we did
307 | ```php
308 | use \Hkonnet\LaravelEbay\EbayServices;
309 | // Create the service object.
310 | $ebay_service = new EbayServices();
311 | $service = $ebay_service->createFinding();
312 | ```
313 | to get service object..
314 |
315 | Following methods are available to create services using `EbayServices` class.
316 |
317 | * createAccount(array $args = [])
318 | * createAnalytics(array $args = [])
319 | * createBrowse(array $args = [])
320 | * createBulkDataExchange(array $args = [])
321 | * createBusinessPoliciesManagement(array $args = [])
322 | * createFeedback(array $args = [])
323 | * createFileTransfer(array $args = [])
324 | * createFinding(array $args = [])
325 | * createFulfillment(array $args = [])
326 | * createHalfFinding(array $args = [])
327 | * createInventory(array $args = [])
328 | * createMarketing(array $args = [])
329 | * createMerchandising(array $args = [])
330 | * createMetadata(array $args = [])
331 | * createOrder(array $args = [])
332 | * createPostOrder(array $args = [])
333 | * createProduct(array $args = [])
334 | * createProductMetadata(array $args = [])
335 | * createRelatedItemsManagement(array $args = [])
336 | * createResolutionCaseManagement(array $args = [])
337 | * createReturnManagement(array $args = [])
338 | * createShopping(array $args = [])
339 | * createTrading(array $args = [])
340 |
341 | These services methods can be used to get appropriate service object to perform operations on Ebay.
342 |
343 | ## Author
344 |
345 | * **Haroon Khan** - *Initial work* - [hkonnet](https://github.com/hkonnet)
346 |
347 |
348 | ## License
349 |
350 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
351 |
352 | ## Acknowledgments
353 |
354 | * [David T. Sadler](https://github.com/davidtsadler) for his awesome Ebay SDK.
355 |
356 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hkonnet/laravel-ebay",
3 | "description": "This package is wrapper for php Ebay sdk for laravel to automate all the configurations and make the skd ready to use.",
4 | "type": "library",
5 | "keywords": ["ebay", "api", "sdk", "laravel", "laravel5", "php"],
6 | "license": "MIT",
7 | "require": {
8 | "php": ">=5.5",
9 | "dts/ebay-sdk-php": "~12.0|~13.0|~14.0|~15.0|~16.0|~17.0|~18.0"
10 | },
11 | "license": "MIT",
12 | "authors": [
13 | {
14 | "name": "Haroon Khan",
15 | "email": "hkonnet@gmail.com"
16 | }
17 | ],
18 | "autoload":{
19 | "psr-4": {
20 | "Hkonnet\\LaravelEbay\\": "src"
21 | }
22 | },
23 | "minimum-stability": "stable"
24 | }
25 |
--------------------------------------------------------------------------------
/src/Config/ebay.php:
--------------------------------------------------------------------------------
1 | env('EBAY_MODE', 'sandbox'),
18 |
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Site Id
23 | |--------------------------------------------------------------------------
24 | |
25 | | The unique numerical identifier for the eBay site your API requests are to be sent to.
26 | | For example, you would pass the value 3 to specify the eBay UK site.
27 | | A complete list of eBay site IDs is available
28 | |(http://developer.ebay.com/devzone/finding/Concepts/SiteIDToGlobalID.html).
29 | |
30 | |
31 | */
32 |
33 | 'siteId' => env('EBAY_SITE_ID','0'),
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | KEYS
38 | |--------------------------------------------------------------------------
39 | |
40 | | Get keys from EBAY. Create an app and generate keys.
41 | | (https://developer.ebay.com)
42 | | You can create keys for both sandbox and production also
43 | | User token can generated here.
44 | |
45 | */
46 |
47 | 'sandbox' => [
48 | 'credentials' => [
49 | 'devId' => env('EBAY_SANDBOX_DEV_ID'),
50 | 'appId' => env('EBAY_SANDBOX_APP_ID'),
51 | 'certId' => env('EBAY_SANDBOX_CERT_ID'),
52 | ],
53 | 'authToken' => env('EBAY_SANDBOX_AUTH_TOKEN'),
54 | 'oauthUserToken' => env('EBAY_SANDBOX_OAUTH_USER_TOKEN'),
55 | ],
56 | 'production' => [
57 | 'credentials' => [
58 | 'devId' => env('EBAY_PROD_DEV_ID'),
59 | 'appId' => env('EBAY_PROD_APP_ID'),
60 | 'certId' => env('EBAY_PROD_CERT_ID'),
61 | ],
62 | 'authToken' => env('EBAY_PROD_AUTH_TOKEN'),
63 | 'oauthUserToken' => env('EBAY_PROD_OAUTH_USER_TOKEN'),
64 | ]
65 | ];
--------------------------------------------------------------------------------
/src/Ebay.php:
--------------------------------------------------------------------------------
1 | config('ebay.'.config('ebay.mode').'.credentials'),
15 | 'siteId' => config('ebay.siteId'),
16 | 'sandbox' => $sandbox
17 | ];
18 |
19 | $this->config = $config;
20 | }
21 |
22 | function __call($name, $args)
23 | {
24 | if (strpos($name, 'create') === 0) {
25 | $service = 'create'.substr($name, 6);
26 | $configuration = isset($args[0]) ? $args[0] : [];
27 | return $this->sdk->$service($configuration);
28 | }
29 | }
30 |
31 | public function getAuthToken(){
32 | return config('ebay.'.config('ebay.mode').'.authToken');
33 | }
34 |
35 | /*
36 | * Return configurations from Config
37 | */
38 | public function getConfig($args=[]){
39 | $this->config['siteId'] = isset($args['siteId'])?$args['siteId']:$this->config['siteId'];
40 | return $this->config;
41 | }
42 | }
--------------------------------------------------------------------------------
/src/EbayServiceProvider.php:
--------------------------------------------------------------------------------
1 | publishes([
18 | __DIR__.'/Config/ebay.php' => config_path('ebay.php'),
19 | ], 'config');
20 |
21 | }
22 |
23 | /**
24 | * Register the application services.
25 | *
26 | * @return void
27 | */
28 | public function register()
29 | {
30 | // Config
31 | $this->mergeConfigFrom( __DIR__.'/Config/ebay.php', 'ebay');
32 |
33 | $this->app->singleton('ebay', function () {
34 | return new Ebay();
35 | });
36 | }
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/EbayServices.php:
--------------------------------------------------------------------------------
1 | getConfig($args);
15 | $this->sdk = new Sdk($config);
16 | }
17 |
18 | function __call($name, $args)
19 | {
20 | if (strpos($name, 'create') === 0) {
21 | $service = 'create'.substr($name, 6);
22 | $configuration = isset($args[0]) ? $args[0] : [];
23 | return $this->sdk->$service($configuration);
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/Facade/Ebay.php:
--------------------------------------------------------------------------------
1 |