ebay/ebay-simplifier

The Project Implemented to work with Ebay api endpoint,It reduces more time to people who are switched this area newly

v1.0.8 2020-07-01 06:37 UTC

This package is auto-updated.

Last update: 2020-07-01 06:42:12 UTC


README

The Package will make easy to handle ebay api calls

My Table of content

  1. Requirement
  2. Installation
  3. Developer Guide
    i. Instantiate the eBay Trading API object
    ii. getTokenStatus() method.
    iii. getItem() method.
    iv. getStore() method.
    v. getOrders() method.
    vi. addFixedPriceItem() method.
    vii. reviseFixedPriceItem() method
    viii. relistFixedPriceItem() method
    ix. reviseInventoryStatus() method
    x. completeSale() method
    xi. getEbayCategories() method
    xii. endFixedPriceItemRequest() method

01. Requirement

  1. PHP > 7.1
  2. Laravel 5.x | 6.x

02.Installation

Library can be installed with Composer.
  1. Install Composer to your local/development environment
  2. Run command composer require ebay/ebay-simplifier
  3. Import/Require Composer's autoloader by adding the following line on your code. require 'vendor/autoload.php';
  4. use namespace of the package use ebay\ebaySimplifier\EBayTradingApi;

03. Developer Guide

Following calls are mostly expected an associative array as parameter which needs to construct according specific eBay API calls. Refer the eBay Trading API Documentation while using each specific function.

No need to worry about XML root just construct inner key, value pairs correctly

Eg: Consider the Following Request XML
<?xml version="1.0" encoding="utf-8"?>
<GetStoreRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <RequesterCredentials>
    <eBayAuthToken>ABC...123</eBayAuthToken>
  </RequesterCredentials>
  <!-- Call-specific Input Fields -->
  <CategoryStructureOnly> boolean </CategoryStructureOnly>
  <LevelLimit> int </LevelLimit>
  <RootCategoryID> long </RootCategoryID>
  <UserID> UserIDType (string) </UserID>
  <!-- Standard Input Fields -->
  <ErrorLanguage> string </ErrorLanguage>
  <MessageID> string </MessageID>
  <Version> string </Version>
  <WarningLevel> WarningLevelCodeType </WarningLevel>
</GetStoreRequest>

Make an array simply as following

$post_data = [
    'CategoryStructureOnly' => 'bool',
    'LevelLimit' => 'int',
    'RootCategoryID' =>'long',
    'UserID' => 'string',
    'MessageID' => 'string',
    'Version' => 'string',
];

ErrorLanguage and WarningLevel fields are set by default respectively en_US , High If wants to change default values can simply over ride by setting the those key, value pair on the array.
Note : RequesterCredentials with token will be set by constructer parameter. So just ignore it.

  1. Instantiate the eBay Trading API object
    try{
       $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
    }catch(Exception $e){
       print 'Error ' . $e->getMessage();
    }

    Note: Respectively token , devId, appId , certId, url, siteId are required for the constructor method.

  2. getTokenStatus() method.
    Method No Required any parameters. Method returns an array with respective key,value pair as an array.
          [
                   'http_code' => (int)_ _ _ _
                   'status' => (string)_ _ _ _
                   'response' => (array)_ _ _ _ _
          ]
    try{
        $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
        $tokenStatusResponse = $ebayTrading->getTokenStatus();
        print_r($tokenStatusResponse);
    }catch(Exception $e){
        print 'Error ' . $e->getMessage();
    }

    Sample Output :-

    Array(
        [http_code] => 200
        [status] => OK
        [response] => Array
            (
                [Timestamp] => 
                [Ack] => Success
                [Version] => 1123
                [Build] => 
                [TokenStatus] => Array
                    (
                        [Status] => Active
                        [EIASToken] => 
                        [ExpirationTime] => 
                    )
    
            )
    
    )
  3. getItem() method.
    The GetItem call returns listing data such as title, description, price information, user information, and so on, for the specified ItemID.

    Function requires a parameter. which may be
    (int/string) itemId or an associative array as postBody according eBay API Requirements.
    Eg :-

    try{
        $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
        $postBody = 178218224608;
        // --- OR ---
        $postBody = [
            'IncludeItemCompatibilityList' => (bool),
            'IncludeItemSpecifics' => (bool),
            'IncludeTaxTable' => (bool),
            'IncludeWatchCount' =>(bool),
            'ItemID' => (string),
            'VariationSpecifics' => [
                'NameValueList'=>[
        
                    ['Name' => (string),'Value' => (string)],
                    ['Name' => (string),'Value' => (string)]
                    ---------------------------------------more
                ]
                
            ],
            'MessageID' => (string)
        ];
    
        $response = $ebayTrading->getItem($postBody);
    
        print_r($response);
    }catch(Exception $e){
        print 'Error ' . $e->getMessage();
    }

    Sample Output :-

    Array
    (
        [http_code] => 200
        [status] => OK
        [response] => Array
            (
                [Timestamp] => 
                [Ack] => Success
                [Version] => 
                [Build] => 
                [Item] => Array
                    (
                        [AutoPay] => true
                        [BuyerProtection] => 
                        [BuyItNowPrice] => 0.0
                        [Country] => 
                        [Currency] => 
                        [GiftIcon] => 0
                        [HitCounter] => 
                        [ItemID] => 
                        [ListingDetails] => Array
                            (
                            )
    
                        [ListingDuration] => 
                        [ListingType] => FixedPriceItem
                        [Location] => 
                        [PaymentMethods] => PayPal
                        [PayPalEmailAddress] => example@gmail.com
                        [PrimaryCategory] => Array
                            (
                                [CategoryID] => 
                                [CategoryName] => 
                            )
    
                        [PrivateListing] => false
     // --------------------------- MORE --------------
    )
  4. getStore() method.
    Use this call to retrieve configuration information for the eBay store owned by the user specified with UserID. If you do not specify a UserID, the store configuration information is returned for the authenticated caller ( API DOCUMENTATION)

    Empty parameter or An Associative array as postBody according eBay API Requirement.
    Eg:

    try{
        $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
    
        $response = $ebayTrading->getItem();
        /** --- OR --- **/
       $postBody = [
       	'CategoryStructureOnly' => 
       	'LevelLimit' => 
       	'RootCategoryID' => 
       	'UserID' => 
        // ------------ More --------------
       ];
    
        $response = $ebayTrading->getStore();
    
        print_r($response);
    }catch(Exception $e){
        print 'Error ' . $e->getMessage();
    }

    Sample Output :-

    array (
      'Store' => 
      array (
        'CustomCategories' => 
        array (
          'CustomCategory' => 
          array (
            'CategoryID' => 'long',
            'ChildCategory' => 
            array (
              'CategoryID' => 'long',
              'ChildCategory' => 
              array (
                'CategoryID' => 'long',
                'ChildCategory' => 'StoreCustomCategoryType',
                'Name' => 'string',
                'Order' => 'int',
                '__text' => 'StoreCustomCategoryType',
              ),
              'Name' => 'string',
              'Order' => 'int',
              '__text' => 'StoreCustomCategoryType',
            ),
            'Name' => 'string',
            'Order' => 'int',
            '__text' => 'StoreCustomCategoryType',
          ),
          '__text' => 'StoreCustomCategoryArrayType',
        ),
    // ------------ More -----------------
  5. getOrders() method.

    GetOrders is the recommended call to use for order (sales) management. Use this call to retrieve all orders in which the authenticated caller is either the buyer or seller. The order types that can be retrieved with this call are discussed on eBay Documentation

    Expected an associative array as parameter for the function calling. Eg:

    try{
        $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
        $postBody = [
            'CreateTimeFrom' => 
            'CreateTimeTo' => 
            'OrderRole' => 
            // ------------ More --------------
           ];
    
        $response = $ebayTrading->getOrders($postBody);   
        print_r($response);
    }catch(Exception $e){
        print 'Error ' . $e->getMessage();
    }

    Sample Output :-

    [
        'HasMoreOrders' => ,
        'OrderArray' => [
                    'Order' =>[ 
                        'AdjustmentAmount' => [ 
                                    '@attributes' =>[
                                            'currencyID' => CurrencyCodeType,
                                                    ],
                                    '_value' =>  'Amount (double)'
                        ],
                        'AmountPaid' => [
                                          '@attributes' =>[
                                                          'currencyID' => CurrencyCodeType
                                                          ],
                                          '_value' => 'AmountType (double)'
                                        ],
                            ]
                         ],
        
        // ------------ More ---------------
    ];
  6. addFixedPriceItem() method.
    Use this call to define and list a new fixed-price item. This call returns the item ID for the new listing,
    plus an estimation of the fees the seller will incur for posting the listing (not including the Final Value Fee,
    which cannot be calculated until the listing has ended) (Detail From Documentation).

    Function requires a parameter as an associative array .

    try{
        $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
    
        $postBody = [
            'IncludeItemCompatibilityList' => (bool),
            'IncludeItemSpecifics' => (bool),
            'IncludeTaxTable' => (bool),
            'IncludeWatchCount' =>(bool),
            'ItemID' => (string),
            'VariationSpecifics' => [
                'NameValueList'=>[
        
                    ['Name' => (string),'Value' => (string)],
                    ['Name' => (string),'Value' => (string)]
                    ----------------------------more------------------
                ]
                
            ],
            'MessageID' => (string)
        ];
    
        $response = $ebayTrading->addFixedPriceItem($postBody);
    
        print_r($response);
    }catch(Exception $e){
        print 'Error ' . $e->getMessage();
    }

    Sample Output:

    array (
      'name' => 'AddFixedPriceItemResponse',
      'value' => '',
      'attr' => 
          array (
          ),
          'children' => 
              array (
                0 => 
                array (
                  'name' => 'Timestamp',
                  'value' => '2019-10-31T20:39:16.515Z',
                  'attr' => 
                  array (
                  ),
                  'children' => 
                  array (
                  ),
                ),
    // -----------More ------
  7. reviseFixedPriceItem() method
    Use this call to change the properties of a currently active fixed-price listing (including multi-variation listings). Documentation

    Please refer the documentation before construct the parameter array

    $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
    
            $postBody = [
            	'Item' => [
            	    'ItemID'=>110038081632	      
            		],
            	'Variations' => [
            	     'Variation'=>[
            		     'SKU'=>'RLauren_Wom_TShirt_Pnk_S',
            		     'StartPrice' => 14.99,
            		     'Quantity'=> 4,
            		     'VariationSpecifics' => [
            				'NameValueList' => [
            					[
            					'Name'=>'Color',
            					'Value' => Pink
            					],
            					[
            					'Name' => 'Size',
            					'Value' => 'S'
            					]
            				                   ],
            			                         ]
            		                ],
            // ------------More Variation-------------
            		            ] //variations end
            ];
        
                $response = $ebayTrading->reviseFixedPriceItem($postBody);
            
                print_r($response);
            }catch(Exception $e){
                print 'Error ' . $e->getMessage();
            }

    Sample Output:

    [
    	'Timestamp' => '2019-11-06T18:40:55.049Z',
    	'Ack'=>'Success',
    	'Version' => 1131,
    	'Build' => 'E1131_UNI_API5_19098188_R1',
    	'ItemID'=>110038081632,
    	'StartTime'=>'2019-11-06T18:40:55.049Z',
    	'Fees'=> [
    		 	'Fee'=>[
    				 [
    				  'Name' => 'AuctionLengthFee',
    				  'Fee'=>0.0
    				 ],
    				 [
    				  'Name' => 'BoldFee',
    				  'Fee'=>0.0
    				 ],
                                     [
    				  'Name' => 'BuyItNowFee',
    				  'Fee'=>0.0
    				 ],
    			       ]
    		 ]
    ];
  8. relistFixedPriceItem() method
    Use this call to relist a single fixed-price item or a single multi-item listing that has ended. The item may be relisted as it was originally defined, or the seller may change (Details Source)

    Function Requires an array as parameter Please refer the documentation before construct the array

    $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
    
            $post_data = [
            	'Item' => [
            	    'ItemID'=>110038081632	      
            		],
            	'Variations' => [
            	     'Variation'=>[
            		     'SKU'=>'RLauren_Wom_TShirt_Pnk_S',
            		     'StartPrice' => 14.99,
            		     'Quantity'=> 4,
            		     'VariationSpecifics' => [
            				'NameValueList' => [
            					[
            					'Name'=>'Color',
            					'Value' => Pink
            					],
            					[
            					'Name' => 'Size',
            					'Value' => 'S'
            					]
            				                   ],
            			                         ]
            		                ],
            // ------------More Variation-------------
            		            ] //variations end
            ];
        
                $response = $ebayTrading->relistFixedPriceItem($post_data);
            
                print_r($response);
            }catch(Exception $e){
                print 'Error ' . $e->getMessage();
            }

    Sample Output:

    [
    	'Category2ID' => '',
    	'CategoryID'=>'',
    	'DiscountReason' => '',
    	'EndTime' => '',
    	'Fees'=>[
            'Fee' => [
                
             ]       
        ],
    	// ---- More --- 
    ];
  9. reviseInventoryStatus() method
    This call enables a seller to change the price and/or quantity of up to four active, fixed-price listings. The fixed-price listing(s) to modify are ................... (Visit documentation page for more details)

    Function Requires an array as parameter. Please refer the documentation before construct the associative array

    $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
    
            $post_data = [
            	'InventoryStatus' => [
                        [
                            'ItemID'=>'',
                            'Quantity'=> '',
                        ],
                        [ 
                            'SKU'=>'',
                            'ItemID'=>'',
                            'Quantity'=>''
                        ]       
            	          
            		],
            // ------------More Variation-------------
            		            ] //variations end
            ];
        
                $response = $ebayTrading->reviseInventoryStatus($post_data);
                print_r($response);
            }catch(Exception $e){
                print 'Error ' . $e->getMessage();
            }

    Sample Output:

    Array
    (
        [ReviseInventoryStatusResponse] => Array
            (
         
                [Fees] => Array
                    (
               
                        [Fee] => Array
                            (
                                [#text] => Array
                                    (
                                        [0] => Array
                                            (
                                            )
    
                                        [1] => Array
                                            (
                                            )
    
                                        [2] => Array
                                            (
                                            )
    
                                        [3] => Array
                                            (
                                            )
    
                                    )
    
                                [Fee] => Array
                                    (
                                        [@attributes] => Array
                                            (
                                                [currencyID] => CurrencyCodeType
                                            )
    
                                        [_value] =>  AmountType (double)
                                    )
    
                                [Name] =>  string
                                [PromotionalDiscount] => Array
                                    (
                                        [@attributes] => Array
                                            (
                                                [currencyID] => CurrencyCodeType
                                            )
    
                                        [_value] =>  AmountType (double)
                                    )
    
                            )
    
                        [#comment] => Array
                            (
                            )
    
                        [ItemID] =>  ItemIDType (string)
                    )
    
                [InventoryStatus] => Array
                    (
                        [#text] => Array
                            (
                                [0] => Array
                                    (
                                    )
    
                                [1] => Array
                                    (
     //-------------------- More -----------------------
  10. completeSale() method
    This API call Use to do various tasks after the creation of a single line item or multiple line item order.

    **Function Requires an array. ** Please refer the documentation before construct the associative array

            $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
            $post_data = [  
                         'FeedbackInfo' => [
                                            'CommentText'=> 'Wonderful buyer!',
                                            'CommentType' => 'Positive',
                                            'TargetUse' => 'bestbuyerever',
                                            ],
                        
                         'ItemID' => 123438071240,
                         'TransactionID' => 0,
            // ---------- More ---------------
                        ];
        
                $response = $ebayTrading->completeSale($post_data);
                print_r($response);
            }catch(Exception $e){
                print 'Error ' . $e->getMessage();
            }

    Sample Output:

    Array
    (
                [Ack] =>  AckCodeType
                [Build] =>  string
                [CorrelationID] =>  string
                [Errors] => Array
                    (
                        
    
                        [ErrorClassification] =>  ErrorClassificationCodeType
                        [ErrorCode] =>  token
                        [ErrorParameters] => Array
                            (
                                [@attributes] => Array
                                    (
                                        [ParamID] => string
                                    )
    
                        
                                [Value] =>  string
                            )
    
                        [LongMessage] =>  string
                        [SeverityCode] =>  SeverityCodeType
                        [ShortMessage] =>  string
                    )
    
                [HardExpirationWarning] =>  string
                [Timestamp] =>  dateTime
                [Version] =>  string
            
    
    )
  11. getEbayCategories() method
    Use this call to retrieve the latest category hierarchy for the eBay site specified in the CategorySiteID property. By default, this is the site to which you submit the request. You can retrieve all categories on the site, or you can use CategoryParent to retrieve one particular category and its subcategories. The returned category list is contained in the CategoryArray property.

    **Function can be contain empty or an array as parameter. ** Please refer the documentation before construct the associative array

            $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
            $post_data = [  
                         'FeedbackInfo' => '',
                        
                         'ViewAllNodes' => (bool){default true},
                      
            // ---------- More ---------------
                        ];
        
                $response = $ebayTrading->getEbayCategories($post_data);
                    //OR
                 $response = $ebayTrading->getEbayCategories();
                    print_r($response);
            }catch(Exception $e){
                print 'Error ' . $e->getMessage();
            }

    Sample Output:

    Array
    (
                ['CategoryArray'] => [
                    'Category' => [
                        'AutoPayEnabled' => '',
                         'B2BVATEnabled' => '',
                         'BestOfferEnabled' => ''
                    ]
                ]
    
            //  `````   More   ````
    
    )
  12. endFixedPriceItemRequest() method Function require ItemID and optional params.
    	try{
    	     $ebayTrading = new EBayTradingApi($token,$devId,$appId,$certName,$url,$siteId);
                 $post_data = [  
    			     'EndingReason' => 'OtherListingError',
    
    			    ];
        
                $response = $ebayTrading->getEbayCategories($itemId ,$post_data);
                print_r($response);
            }catch(Exception $e){
                print 'Error ' . $e->getMessage();
            }