*/ $item->ReturnPolicy = new Types\ReturnPolicyType(); $item->ReturnPolicy->ReturnsAcceptedOption = 'ReturnsAccepted'; $item->ReturnPolicy->RefundOption = 'MoneyBack'; $item->ReturnPolicy->ReturnsWithinOption = 'Days_14'; $item->ReturnPolicy->ShippingCostPaidByOption = 'Buyer'; /** * Finish the request object. */ $request->Item = $item; /** * Send the request to the AddFixedPriceItem service operation. * * For more information about calling a service operation, see: * http://devbay.net/sdk/guides/getting-started/#service-operation */ $response = $service->addFixedPriceItem($request); /** * Output the result of calling the service operation. * * For more information about working with the service response object, see: * http://devbay.net/sdk/guides/getting-started/#response-object */ if (isset($response->Errors)) { foreach ($response->Errors as $error) { printf("%s: %s\n%s\n\n", $error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning', $error->ShortMessage, $error->LongMessage); } } if ($response->Ack !== 'Failure') { printf("The item was listed to the eBay Sandbox with the Item number %s\n", $response->ItemID); }
public function addFixedPriceListing($listingItem) { $request = new Types\AddFixedPriceItemRequestType(); $request->RequesterCredentials = new Types\CustomSecurityHeaderType(); $request->RequesterCredentials->eBayAuthToken = $this->token; //$item = new Types\ItemType(); // bad coding // $item->Country = 'AU'; // $item->Currency = 'AUD'; // $item->ListingDuration = Enums\ListingDurationCodeType::C_GTC; // $item->ListingType = Enums\ListingTypeCodeType::C_FIXED_PRICE_ITEM; // $item->ConditionID = 1000; // $item->DispatchTimeMax = 1; // $item->ReturnPolicy = new Types\ReturnPolicyType(); // $item->ReturnPolicy->ReturnsAcceptedOption = 'ReturnsAccepted'; // $item->ReturnPolicy->RefundOption = 'MoneyBack'; // $item->ReturnPolicy->ReturnsWithinOption = 'Days_14'; // $item->ReturnPolicy->ShippingCostPaidByOption = 'Buyer'; // $item->ShippingDetails = new Types\ShippingDetailsType(); // $item->ShippingDetails->ShippingType = Enums\ShippingTypeCodeType::C_FLAT; // // $item->Quantity = (int)$listingItem->qty; // $item->StartPrice = new Types\AmountType(array('value' => (double)$listingItem->price));; // $item->BestOfferDetails = new Types\BestOfferDetailsType(); // //return var_dump($listingItem->bestOffer); // if($listingItem->bestOffer!="false"){ // $item->BestOfferDetails->BestOfferEnabled = true; // $item->ListingDetails = new Types\ListingDetailsType(); // $item->ListingDetails->BestOfferAutoAcceptPrice = new Types\AmountType(array('value' => (double)$listingItem->bestOffer[0])); // $item->ListingDetails->MinimumBestOfferPrice = new Types\AmountType(array('value' => (double)$listingItem->bestOffer[1])); // }else{ // $item->BestOfferDetails->BestOfferEnabled = false; // } // // $item->PrimaryCategory = new Types\CategoryType(); // $item->PrimaryCategory->CategoryID = $listingItem->primaryCate; // $item->Title = $listingItem->title; // $item->Description = "<![CDATA[" . $listingItem->description . "]]>"; // //$item->Description = "test"; // $item->SKU = $listingItem->sku; // $item->Location = $listingItem->location; // $item->PictureDetails = new Types\PictureDetailsType(); // $item->PictureDetails->GalleryType = Enums\GalleryTypeCodeType::C_GALLERY; // $item->PictureDetails->PictureURL = $listingItem->picture; // $item->PaymentMethods = array( // 'PayPal' // ); // $item->PayPalEmailAddress = $listingItem->paypal; // $shippingService = new Types\ShippingServiceOptionsType(); // $shippingService->ShippingServicePriority = 1; // $shippingService->ShippingService = $listingItem->shippingService; // if($listingItem->shippingCost=="true"){ // $shippingService->FreeShipping = true; // }else{ // $shippingService->ShippingServiceCost = new Types\AmountType(array('value' => (double)$listingItem->shippingCost[0])); // $shippingService->ShippingServiceAdditionalCost = new Types\AmountType(array('value' => (double)$listingItem->shippingCost[1])); // } // // $item->ShippingDetails->ShippingServiceOptions[] = $shippingService; $item = $this->buildItem($listingItem); $request->Item = $item; //$service = $this->tradingServiceInit(); $service = new Services\TradingService(array('apiVersion' => EbayApi::COMPATABILITY_LEVEL, 'siteId' => EbayApi::SITE_ID, 'authToken' => $this->token, 'devId' => EbayApi::DEV_ID, 'appId' => EbayApi::APP_ID, 'certId' => EbayApi::CERT_ID)); $result['itemID'] = "123"; //$result['error'][] = "123"; //$result['error'][] = "fail"; return $result; $response = $service->addFixedPriceItem($request); $result = []; if (isset($response->Errors)) { foreach ($response->Errors as $error) { $result['error'][] = $error->ShortMessage; $result['error'][] = $error->LongMessage; } } if ($response->Ack !== 'Failure') { $result['itemID'] = $response->ItemID; } return $result; }