Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoice Upload Feed does not work #147

Open
danielecr opened this issue Dec 3, 2020 · 1 comment
Open

Invoice Upload Feed does not work #147

danielecr opened this issue Dec 3, 2020 · 1 comment
Assignees

Comments

@danielecr
Copy link
Contributor

rif. #116

Describe the bug
Document upload does not work

please reopen #116

  • A clear and concise description of what the bug is.

the url is wrong. The api reply user not allowed. See #116

  • Which Amazon MWS Marketplace are you using?
    All

  • Most Important, Is this working with the Amazon Scratchpad?
    not testable.

Add you Amazon MWS Request

What Response are you receiving?

nothing
@danielecr
Copy link
Contributor Author

I found a way.
First of all the host must be setted, and currently documentation does not provide any details about amazonMws.setHost() call
There is no information about setContentType() also ...

There are a lot of set[thing]() method, but there is no setSocket() function, I would like to use amazonMws.setSocket(http), or amazonMws.setSocket(httpmock), and provide some mock for testing. I found something good in this code, but unit tests are not real unit test, the .spec.js test everything from request to the end of handling of response, that is generally called functional tests.

To split those parts the code should be splitted from AmazonMwsResource.js, and really that source file is too much big.

@bhushankumarl , You ask to contributor to run all tests before making a pull request, but the tests must be ran against a real alive amazon api, and this is a real problem if you want the tests to be automatic (you should inject SellerId, auth key, private key, ... and where does the automatic test get this data?)

Tests must be automatic, so tests as of now are not usable.

There are a number of option to mock http, like nock, https://github.com/nock/nock, I do not know it, but maybe there are other things that could be used.

OK. I Stop here the code review. I come back to "how to submit document":

        let host = hostbycountry(PlatformCountry);
        amazonMws.setHost(host);
        amazonMws.setContentType('application/octet-stream');
        const mwsRequestData = {
            Version: '2009-01-01',
            Action: 'SubmitFeed',
            FeedType: '_UPLOAD_VAT_INVOICE_',
            PurgeAndReplace: 'false',
            FeedContent: docData,
            SellerId: 'merchantid',
            MWSAuthToken: 'mws_auth_token',
            'MarketplaceIdList.Id.1': 'marketplaceid',
            FeedOptions: 'metadata:orderid=....'
        };
        return amazonMws.feeds.submit(mwsRequestData)

Something to note:

  • SellerId and Merchant are synonyms.
  • PurgeAndReplace is a string
  • FeedOptions is a string in the format specified in https://m.media-amazon.com/images/G/03/B2B/invoice-uploader-developer-documentation.pdf
  • hostbycountry() here is a function that return the host as listed in https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html , by the country code of the merchant (the sellerId), not the marketplace! this means that the SellerId and AuthToken is paired with the platform, even if the merchant is selling in another country, but MarketplaceIdList.Id.1 is the marketplace where the order is placed (where the good was sold).
  • amazonMws.setContentType('application/octet-stream'), because it is not an 'x-www-form-urlencoded', it is an upload instead, this should be automatic, maybe, but I solved it without touching the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants