Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

add one item to ebay #1

Closed
hyptos opened this issue Jul 15, 2014 · 4 comments
Closed

add one item to ebay #1

hyptos opened this issue Jul 15, 2014 · 4 comments
Assignees

Comments

@hyptos
Copy link

hyptos commented Jul 15, 2014

Hi,

I'm openning this in order to have an example to create a product on ebay via your API.

I saw your example there : https://github.com/davidtsadler/ebay-sdk-trading/issues/1#issuecomment-35777796

I updated your code to the current API (refactoring names only)

I don't know why I got this error because even though I injected the token like you shows us on the tutorial :/

L'en-tête "X-EBAY-API-APP-NAME" n'existe pas.
L'en-tête "X-EBAY-API-DEV-NAME" n'existe pas.
L'en-tête "X-EBAY-API-CERT-NAME" n'existe pas.

It says that headers "X-EBAY-API-HERP-NAME" doesn't exist.

Here is the code I use

require '/vendor/autoload.php';

use \DTS\eBaySDK\Trading\Services\TradingService;
use \DTS\eBaySDK\Trading\Types as Types;
use \DTS\eBaySDK\Trading\Enums as Enums;
use \DTS\eBaySDK\Constants\SiteIds;
use \DTS\eBaySDK\HttpClient\HttpClient;

// Instantiate a service.
$service = new TradingService(array(
      'apiVersion' => 873,
      'siteId' => SiteIds::FR
  ));


$requesterCredentials = new Types\CustomSecurityHeaderType();
$requesterCredentials->eBayAuthToken = $config['production']['userToken'];

$item = new Types\ItemType();

$item->Site = 'FR';

$item->ListingType = 'Chinese';
$item->ListingDuration = 'Days_10';
$item->Quantity = 1;
$item->StartPrice = new Types\AmountType(array('value' => 100.99, 'currencyID' => 'EUR'));
$item->ReservePrice = new Types\AmountType(array('value' => 100.99, 'currencyID' => 'EUR'));
$item->BuyItNowPrice = new Types\AmountType(array('value' => 100.99, 'currencyID' => 'EUR'));

$item->Title = 'Example 4';
$item->Description = 'Example 4';
$item->SKU = 'L1';
$item->Currency = 'EUR';
$item->Country ='FR';
$item->Location = 'Rhone';
$item->PostalCode = '69000';

$picture = new Types\PictureDetailsType();
$picture->GalleryType = Enums\GalleryTypeCodeType::C_GALLERY;
$picture->ExternalPictureURL[] = 'http://dl.dropbox.com/u/25261546/t%20shirts/white.jpg';
$item->PictureDetails = $picture;

$primaryCategory = new Types\CategoryType();
$primaryCategory->CategoryID = '29792';
$item->PrimaryCategory = $primaryCategory;

$item->ConditionID = 1000;

$itemSpecifics = new Types\NameValueListArrayType();

$specific = new Types\NameValueListType();
$specific->Name = 'Subject';
$specific->Value[] = 'Fiction & Literature';
$itemSpecifics->NameValueList[] = $specific;

$specific = new Types\NameValueListType();
$specific->Name = 'Topic';
$specific->Value[] = 'Fantasy';
$itemSpecifics->NameValueList[] = $specific;

$specific = new Types\NameValueListType();
$specific->Name = 'Format';
$specific->Value[] = 'MP3 CD';
$itemSpecifics->NameValueList[] = $specific;

$specific = new Types\NameValueListType();
$specific->Name = 'Length';
$specific->Value[] = 'Unabridged';
$itemSpecifics->NameValueList[] = $specific;

$specific = new Types\NameValueListType();
$specific->Name = 'Language';
$specific->Value[] = 'English';
$itemSpecifics->NameValueList[] = $specific;

$specific = new Types\NameValueListType();
$specific->Name = 'Country of Manufacture';
$specific->Value[] = 'United States';
$itemSpecifics->NameValueList[] = $specific;

$item->ItemSpecifics = $itemSpecifics;

$item->PaymentMethods = array('VisaMC', 'PayPal');
$item->PayPalEmailAddress = 'herpderp@gmail.com';
$item->DispatchTimeMax = 3;

$shippingDetails = new Types\ShippingDetailsType();
$shippingDetails->ShippingType = 'Flat';
$shippingDetails->PaymentInstructions = 'Praesent sagittis ornare.';

$shippingService = new Types\ShippingServiceOptionsType();
$shippingService->ShippingServicePriority = 1;
$shippingService->ShippingService = 'Other' ;
$shippingService->ShippingServiceCost = new Types\AmountType(array('value' => 0.00, 'currencyID' => 'EUR'));
$shippingService->ShippingServiceAdditionalCost= new Types\AmountType(array('value' => 0.00, 'currencyID' => 'EUR'));
$shippingService->FreeShipping = true;
$shippingDetails->ShippingServiceOptions[] = $shippingService;

$shippingService = new Types\ShippingServiceOptionsType();
$shippingService->ShippingServicePriority = 2;
$shippingService->ShippingService = 'USPSParcel';
$shippingService->ShippingServiceCost = new Types\AmountType(array('value' => 2.00, 'currencyID' => 'EUR'));
$shippingDetails->ShippingServiceOptions[] = $shippingService;

$shippingService = new Types\InternationalShippingServiceOptionsType();
$shippingService->ShippingServicePriority = 1;
$shippingService->ShippingService = 'USPSFirstClassMailInternational';
$shippingService->ShippingServiceCost = new Types\AmountType(array('value' => 3.00, 'currencyID' => 'EUR'));
$shippingService->ShipToLocation[] = 'Worldwide';
$shippingDetails->InternationalShippingServiceOption[] = $shippingService;

$shippingService = new Types\InternationalShippingServiceOptionsType();
$shippingService->ShippingServicePriority = 2;
$shippingService->ShippingService = 'USPSPriorityMailInternational';
$shippingService->ShippingServiceCost = new Types\AmountType(array('value' => 4.00, 'currencyID' => 'EUR'));
$shippingService->ShipToLocation = array(
  'Americas',
  'CA',
  'AU',
  'Europe',
  'JP'
);
$shippingDetails->InternationalShippingServiceOption[] = $shippingService;

$shippingDetails->ExcludeShipToLocation = array(
  'Alaska/Hawaii',
  'US Protectorates',
  'APO/FPO',
  'DZ',
  'AZ'
);

$salesTax = new Types\SalesTaxType();
$salesTax->SalesTaxState = 'AL';
$salesTax->SalesTaxPercent = 19.600;
$salesTax->ShippingIncludedInTax = true;
$shippingDetails->SalesTax = $salesTax;

$item->ShippingDetails = $shippingDetails;

$buyerRequirements = new Types\BuyerRequirementDetailsType();
$buyerRequirements->ShipToRegistrationCountry = true;
$item->BuyerRequirementDetails = $buyerRequirements;

$item->SellerProfiles = new Types\SellerProfilesType();
$item->SellerProfiles->SellerReturnProfile = new Types\SellerReturnProfileType();
$item->SellerProfiles->SellerReturnProfile->ReturnProfileID = 5000897000;

$request = new Types\AddItemRequestType();
$request->RequesterCredentials = $requesterCredentials;
$request->Item = $item;

$response = $service->addItem($request);

if ($response->Ack === 'Failure') {
  foreach ($response->Errors as $error) {
      echo $error->ShortMessage."\n";
  }
}
else {
    $itemId = $response->ItemId;

    echo $itemId."\n";

    $request = new Types\GetItemRequestType();
    $request->RequesterCredentials = $requesterCredentials;
    $request->ItemId = $itemId;
    $response = $service->getItem($request);

}

Some help would be nice even though I feel stupid because it's an authentification problem.

@hyptos
Copy link
Author

hyptos commented Jul 15, 2014

OK I was creating the object $service in the wrong way

$service = new TradingService(array(
      'apiVersion' => 873,
      'siteId' => SiteIds::FR,
      'authToken' => $config['production']['userToken'],
      'devId' => $config['production']['devId'],
      'appId' => $config['production']['appId'],
      'certId' => $config['production']['certId'],
  ));

and also

$item->Site = Enums\SiteCodeType::C_FRANCE;

Now it's fine except I am not able to ship with US selection which is normal 👍

I will edit this post with the full good code

Nice job man for the API

@davidtsadler davidtsadler self-assigned this Jul 16, 2014
@hyptos hyptos closed this as completed Jul 17, 2014
@davidtsadler
Copy link
Owner

Bonjour Antoine,

I will look at getting an AddItem example written in the next few days. It's been on my todo list for a while so I should really get it done.

Kind Regards,
David

@hyptos
Copy link
Author

hyptos commented Jul 17, 2014

Hi,

Well, I got it working after a few tries :)

But I'm looking forward to your examples, especially the AddItems one.

Regards,

@3zzy
Copy link

3zzy commented Feb 6, 2015

Bumped into the same issue, lost several hours then finally found this thread, thanks! 👍

@ghost ghost mentioned this issue Nov 22, 2016
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 19, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 19, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 19, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 23, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 23, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 23, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 25, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 25, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 25, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 26, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 26, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 26, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 26, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 26, 2018
ortodesign pushed a commit to ortodesign/ebay-sdk-examples that referenced this issue Jan 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants