Closed gurpreetspineor closed 7 years ago
I have checked that Yesterday but couldn't find the solution.
Here is my code:
$config = Config::get('ebayconfig');
$service = new Services\FulfillmentService([
'apiVersion' => Services\FulfillmentService::API_VERSION,
'siteId' => Constants\SiteIds::US,
'authorization' => $config['sandbox']['oauthUserToken'],
'sandbox' => true
]);
$updateOrders = new Types\ShippingFulfillment();
$updateOrders->fulfillmentId = "FullFillMentId";
$updateOrders->lineItems[] = new Types\LineItemReference();
$updateOrders->lineItems->lineItemId = "LineItemID";
$updateOrders->lineItems->quantity = 1;
$updateOrders->shipmentTrackingNumber = "TrackingNumber";
$updateOrders->shippedDate = "2017-06-02T00:00:00";
$updateOrders->shippingCarrierCode = "Carrier Code";
$response = $service->createAShippingFulfillment($updateOrders);
This code throw below error: Type error: Argument 1 passed to DTS\eBaySDK\Fulfillment\Services\FulfillmentService::createAShippingFulfillment() must be an instance of DTS\eBaySDK\Fulfillment\Types\CreateAShippingFulfillmentRestRequest, instance of DTS\eBaySDK\Fulfillment\Types\ShippingFulfillment given, called in /var/www/html/amazon/app/Http/Controllers/EbayFulfillment.php on line 40
Please help me solve this issue. Many thanks in advance.
i never used the fulfillment api, sorry. "CompleteSale" from the TradingAPI always worked perfect for setting shipping infos.
The example below has been adapted from the sample in the documentation for Create a Shipping Fulfillment.
use \DTS\eBaySDK\Fulfillment\Services;
use \DTS\eBaySDK\Fulfillment\Types;
use \DTS\eBaySDK\Fulfillment\Enums;
$service = new Services\FulfillmentService([
'authorization' => $config['sandbox']['oauthUserToken'],
'sandbox' => true
]);
$request = new Types\CreateAShippingFulfillmentRestRequest();
$request->orderId = '6498414015!260000000562911';
$request->lineItems[] = new Types\LineItemReference([
'lineItemId' => '6254458011',
'quantity' => 1
]);
$request->shippedDate = '2016-07-20T00:00:00.000Z';
$request->shippingCarrierCode = 'USPS';
$request->trackingNumber = '910453194076740012';
$response = $service->createAShippingFulfillment($request);
printf("\nStatus Code: %s\n\n", $response->getStatusCode());
if (isset($response->errors)) {
foreach ($response->errors as $error) {
printf(
"%s: %s\n%s\n\n",
$error->errorId,
$error->message,
$error->longMessage
);
}
}
if ($response->getStatusCode() === 201) {
// Location code for the newly created shipping fulfillment resource, including its fulfillment ID
echo $response->getHeader('location');
}
Thanks for help. I used "Complete Sale" Trading API. Here is code $config = Config::get('ebayconfig');
$service = new Services\TradingService([
'apiVersion' => Services\TradingService::API_VERSION,
'siteId' => Constants\SiteIds::US,
'credentials' => $config['sandbox']['credentials'],
'sandbox' => false
]);
$args = array(
"ShipmentTrackingNumber" => "sdfd5f465f4d6sf",
"ShippingCarrierUsed" => "USPS",
);
$shippingArgs = array(
"EstimatedDeliveryDate" => "2017-06-02T00:00:00.000Z",
"Status" => "Shipped"
);
$orderDetail = array(
'ItemID' => '110199505180',
'Quantity' => 1
);
$shipment = new Types\ShipmentType($shippingArgs);
$shipment->ShipmentLineItem = new Types\ShipmentLineItemType();
$shipment->ShipmentLineItem->LineItem[] = new Types\LineItemType($orderDetail);
The code is working fine but I stuck on last step. How I can send the final request. I checked "Services\TradingService" file, there is no one function exist to finally submit above object.
To get the orders, I used $service->getOrders($getOrders);
But for update tracking detail which one function needs to call like "getOrders()" from Trading Service. https://github.com/davidtsadler/ebay-sdk-php/blob/master/src/Trading/Services/TradingService.php Thanks
@gurpreetspineor i guess best is, to look to the examples, too.
everything you do with any other call, should be exact the same ;)
@michabbb If you check the "endItems" function here https://github.com/davidtsadler/ebay-sdk-php/blob/master/src/Trading/Services/TradingService.php#L645
It parameter calling to "EndItemsRequestType" class.
But I used "ShipmentType" so we can't use another function to call the service. The function parameter should same as object of "ShipmentType" class.
@davidtsadler I checked this code multiple times but it throw Application error: [errorId] => 30500 [domain] => API_FULFILLMENT [category] => APPLICATION [message] => System error.
I am just close to the result but couldn't find the final request function. Thanks
@gurpreetspineor i didn´t want to confuse you, you should use the code david send here. i only showed you an alternative with a different API (trading), and this works different. if you work with "CompleteSale" you first have to create a new CompleteSaleRequestType
- put all your stuff into this (but of course not as array, you have use objects) - then you can use the call completeSale. its up 2 you, whats best for your needs.
@michabbb Thank you for help. You are right, "ShipmentType" will work to update Shipping detail. The problem is , Final request function missing for "ShipmentType" in TradingService file.So the library needs to update.
@davidtsadler I checked Fulfillment API request on Ebay Explore, It throw same error as you above mentioned code. Please check screenshot.
@gurpreetspineor a 500 error should remind you, to check the basics. you should check if any other call inside the fulfillment api works... maybe you made something very basic wrong like authorization... or you missed brackets, check your json, if its valid... and never show your token to the public ;)
@gurpreetspineor found this
The Create a Shipping Fulfillment call can occasionally return an HTTP 500 error due to an internal server issue. However, in some cases this call may succeed if you issue it once more after receiving this error.
but i don´t know if that has anything todo with your problem....
@davidtsadler Please can you let me know how I can send final request ? after this code
$shippingArgs = array(
"EstimatedDeliveryDate" => "2017-06-02T00:00:00.000Z",
"Status" => "Shipped"
);
$orderDetail = array(
'ItemID' => '110199505180',
'Quantity' => 1
);
$shipment = new Types\ShipmentType($shippingArgs);
$shipment->ShipmentLineItem = new Types\ShipmentLineItemType();
$shipment->ShipmentLineItem->LineItem[] = new Types\LineItemType($orderDetail);
I checked https://github.com/davidtsadler/ebay-sdk-php/blob/master/src/Trading/Services/TradingService.php but no function exist to send the final call for "ShipmentType". Please help me It can solve my problem. Thanks
@gurpreetspineor David already gave you a full example with code, what's the problem?
@michabbb That code return below error: [errorId] => 30500 [domain] => API_FULFILLMENT [category] => APPLICATION [message] => System error. Thanks
@gurpreetspineor you should try a raw request without this SDK to determine if the ebay api is working as expected. If you don't get an error, get the raw request from this SDK and compare them. There is also a professional ebay developer support you can contact via your eBay developer account.
I want to update order shipping information using this Ebay API class. https://github.com/davidtsadler/ebay-sdk-php/blob/master/src/Fulfillment/Types/ShippingFulfillment.php
I think we need only OAuth to post order data. Can you please provide me example of code ?