davidtsadler / ebay-sdk-examples

Several examples of using the eBay SDK for PHP
http://devbay.net
Apache License 2.0
184 stars 100 forks source link

Setting up Return Policy RestockingFeeValueOption & Standard Shipping - error value is not valid. #40

Closed BillDavid07 closed 7 years ago

BillDavid07 commented 7 years ago

Hi David, I am currently on process of adding shipping and return policy details, but when i try to post the item to ebay i got an error saying invalid value.

Here's the sample code.

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

            $shippingDetails = new TTypes\ShippingDetailsType();
            $shippingDetails->ShippingType = 'Flat';

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

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

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

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

            $item->ShippingDetails = $shippingDetails;
            /**
             * The return policy.
             * Returns are accepted.
             * A refund will be given as money back.
             * The buyer will have 14 days in which to contact the seller after receiving the item.
             * The buyer will pay the return shipping cost.
             */
            $item->ReturnPolicy = new TTypes\ReturnPolicyType();
            $item->ReturnPolicy->ReturnsAcceptedOption = 'ReturnsAccepted';
            $item->ReturnPolicy->RefundOption = 'MoneyBack';
            $item->ReturnPolicy->ReturnsWithinOption = 'Days_30';
            $item->ReturnPolicy->ShippingCostPaidByOption = 'Buyer';
            $item->ReturnPolicy->RestockingFeeValueOption = '15%';

            /**
             * Finish the request object.
             */
            $request->Item = $item;

Thanks in advance! Jerome

davidtsadler commented 7 years ago

You have to look up the correct value to use for the RestockingFeeValueOption via GeteBayDetails. For the US the values are probably going to be NoRestockingFee, Percent_10, Percent_15, Percent_20

I have a page that displays some of the values returned from calling GeteBayDetails. Don't rely on it to much as it requires me to keep it up to date. It's always best to call GeteBayDetails to ensure the latest values are been used.

BillDavid07 commented 7 years ago

Thanks David! I really appreciate it. cheers!