jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
398 stars 185 forks source link

setSellerOrderId and set consignment #228

Closed balicekt closed 2 years ago

balicekt commented 2 years ago

Hi,

I found that is possible use $order->setSellerOrderId("xxx") when I use this function I think is not automatically posted to Amazon. What is necessary to call after use $order->setSellerOrderId("xxx") to get visible seller order Id on amazon website?

And is there also any function for set consignment? Or is necessary use Feed API?

Thank you for help.

Tomas

jlevers commented 2 years ago

the setSellerOrderId method (and any other setter method on a model class) just changes the value in the model -- it doesn't change anything on Amazon's end. The only operations that cause changes on Amazon are the API class methods.

balicekt commented 2 years ago

OK @jlevers, thank you for answer it helped me. And can you just help me what API should I use? Because in OrdersApi are not any functions for this. So I guess to use feedsApi? Is that correct?

Thank you Tomas

jlevers commented 2 years ago

Are you trying to set the merchant order ID? Because you can't change the Amazon order ID (which is in 3-7-7 format, e.g. 111-2222222-3333333). For the merchant order ID, I believe you can do that through one of the feeds, yes.

balicekt commented 2 years ago

Yes what I mean is change merchant order ID. Now trying to get information from SP-API Amazon support what Feed Type to use. For below operations.

1) upload invoice to order 2) set seller order ID 3) set consignment information to amazon order

I trying upload invoice with FeedType::POST_INVOICE_CONFIRMATION_DATA but getting below error:

"errors": [ { "code": "InvalidInput", "message": "Invalid request parameters", "details": "" } ] }

But there is problem that no details are presented in error message. So with no detail is very hard to find out what is wrong. Is this behaviour normal with Amazon SP-API?

jlevers commented 2 years ago

Yeah, they often don't provide much detail. If you show your code, I might be able to tell you why you're getting the error.

balicekt commented 2 years ago

Here is my code for invoice:

$apiInstance = new FeedsApi($this->getConfig());

$feedType = FeedType::POST_INVOICE_CONFIRMATION_DATA;
$createFeedDocSpec = new CreateFeedDocumentSpecification(['content_type' => $feedType['contentType']]);
$feedDocumentInfo = $apiInstance->createFeedDocument($createFeedDocSpec);
$docToUpload = new Document($feedDocumentInfo, $feedType);
$docToUpload->upload(file_get_contents(__DIR__.'/../../../www/temp/zz.pdf'));

$body = new CreateFeedSpecification();
$body->setFeedOptions(
    [
        "DocumentType" => "Invoice",
        "InvoiceNumber" => "322000108",
        "OrderId" => "302-6835795-7417162",
        "TotalAmount" => 17.00,
        "TotalVATAmount" => 2.71
    ]
);

$body->setFeedType('UPLOAD_VAT_INVOICE'); //when use UPLOAD_VAT_INVOICE I don't get error but no invoice shows in seller central in this order. When use:  $body->setFeedType($feedType['name']); I get error I showed above
$body->setInputFeedDocumentId($feedDocumentInfo->getFeedDocumentId());
$body->setMarketplaceIds(self::MARKETPLACE_IDS);

$result = $apiInstance->createFeed($body);
jlevers commented 2 years ago

I'm not sure UPLOAD_VAT_REQUEST is a valid SP API report type -- it's not in the report type documentation anywhere. I recommend opening a support case with Amazon to ask them how to use that report with the SP API.

balicekt commented 2 years ago

Yes I just did and they told me SP-API doesnt support upload invoiced yet. Only one way how to do is use MWS