Update, Xmas 2021. Amazon have changed their page so the first tool -- the scraper -- no longer works. The file combiner should, though.
This repo contains two Ruby tools:
download_payment_reports.rbdownloads payment reports from Vendor Centralgenerate_import_file.rbprocesses them, and LSI files, so they can be imported into Consonance
If you use this code, please manually check the outputs. No guarantees are made and this code is provided as is.
Super early version! Please raise an issue with your problems. The AU country option in particular is untested!
Until such time as payment reports are available in their API, save time by automating the download of your digital payment reports from your vendor central account.
This code uses the Chrome browser to perform the actions you take on the Vendor Central website, just as you do when you log in and click the download links.
It doesn't download every file on the page, as you'll already have downloaded many of them. Instead, it inspects each file name, which has the date included. The code clicks on the files with a date in the filename that is greater than the date you give it. If you enter a date of 31/03/2017, the code will download all the files with the date 01/04/2017 and later.
It doesn't. The code inspects the HTML that is the Vendor Central website, so it knows what to click on. The code only ever looks as far as your own human eyeballs can.
- Download download_payment_reports.rb
cdto that folder- Run
ruby download_payment_reports.rb -hto check the gems are installed - If you need to install any dependencies, run
gem install <gemname>for the gems required in download_payment_reports.rb
- Download the file download_payment_reports.rb to your computer.
- Open Terminal.app on your computer, by pressing cmd+space bar, typing "Terminal" and pressing "Enter".
- Type
cdin the Terminal and press enter. - Type
mkdir payment-reports-codein the Terminal and press enter. - Type
cd payment-reports-codein the Terminal and press enter. - Open Finder. Navigate to where the download_payment_reports.rb downloaded to. Copy that file.
- In Finder, go to your new payment-reports-code folder (you could use the search bar in the Finder window) and paste the payment-reports.rb file into that folder.
- Back in the Terminal, type
lsand press enter. You should see the filenamedownload_payment_reports.rbappear. - Still in the Terminal, type
ruby download_payment_reports.rband press enter. You should see the message "Error: You have to provide at least an email and password. Typeruby download_payment_reports.rb -hfor help."
If you have got this far, it's working! If not, try the following.
- In the Terminal, type
gem install selenium-webdriverand press enter. This will run for a while. If you seeError installing selenium-webdriverplease raise an issue. - When it's done, in the Terminal, type
gem install capybaraand press enter. This will run for a while. - When it's done, in the Terminal, type
gem install uriand press enter. This will run for a while. - When it's done, in the Terminal, type
gem install byebugand press enter. This will run for a while. - When it's done, in the Terminal, type
gem install optparseand press enter. This will run for a while. - Still in the Terminal, type
ruby download_payment_reports.rband press enter. You should see the message "Error: You have to provide at least an email and password. Typeruby download_payment_reports.rb -hfor help."
If that's still not working, try the following:
- In the Terminal, type
which rubyand raise an issue on this GitHub repo, pasting in this info.
- In the Terminal, type
ruby download_payment_reports.rb -hand press enter. Follow the instructions for downloading the correct reports.
TODO: more instructions
- Put the files you want to tranform into the /files folder
- Run
ruby generate_import_file.rbwith options e.g.ruby generate_import_file.rb --channel UKH -d GBP -i 2022-09-30