An Unusual Shopify Fulfillment Pattern

| 2 min read

A merchant recently ordered up a fulfillment App for his Shopify stores selling various items based out of Australia. The standard pattern I use was in order whereby an App polls for new orders booked in the shops twice daily, parses the orders and then rewrites them in a format suitable for the third-party logistics company to perform the actual fulfillment.

The IT company in question prompted me on how we would exchange the CSV data files and I presented my usual answer which is "any way you want". From past development over the years my list of exchange methods used includes FTP, sFTP, REST, Dropbox, EDI, SOAP (gag!) and plain jane email attachments. I presented this list and they responded that FTP would be fine as long as I could nail down an IP for my service. That is problematic as I utilize the cloud for hosting my Apps and in this case, my SaaS provider Heroku is not the easiest service to use with a nailed down IP.

I suggested we try HTTP and REST whereby I could POST the CSV data to their web service instead of FTP. That seemed to go over well and I waited for the URL to POST the Shopify data to. To be fair I also mentioned that as long as the endpoint could be tested via cURl or some other tool like Chrome's REST App I was happy.

I was surprised when I received an email pointing me to the HTTP service I requested. I was a little confused since it was a .jsp or Java Server Page URL but I tried it anyway. It turned out to be a static file uploader page! That was definitely not in my shortlist of expectations from the IT provider. I informed them that a file uploader was problematic as this process of fulfilling orders does not involve a human being browsing directories for files and locating one followed by pressing a submit button.

Learn something new every day though. It turns out that with a carefully crafted cUrl command you can indeed use a static file uploading script to exchange data. The key is that curl will accept a file and an URL and then assign it to the multi-part form on the static page and submit. For example:

file = '/tmp/fizzbuzz.csv'
result = system("curl --form 'file=@#{file}' http://www.thirdpartylogistics.com/secret/santa/motorhead/upload.jsp")

The result comes back after a few seconds as OK (or not) from the result of shelling out and using cUrl from my Ruby app. At Heroku I can use the /tmp filesystem for a use like this so it makes some sense. The IT company informed me that this all worked fine.

So the takeaway from this is that cUrl is perfectly adequate as an exchange mechanism when faced with using a static upload service. The IT company is happy since the uploaded files are going to a protected sandbox on their systems and not directly into a sensitive zone of their in-house processing.

Now we just work out the reverse process where they provide me with the Shopify order ID and a tracking number and the loop is closed for this merchant. They can spent their time and efforts on marketing and other important aspects of their business without worrying about manually processing and fulfilling their orders, nor about informing their customers about the status and tracking of orders.