Giter VIP home page Giter VIP logo

order-tracking's Introduction

Ship Station Relay Automation

Overview

This application bill be built with Spring Boot and is designed to be run as a REST service. Data will be sent from the Snipcart service to the REST service. The REST controller will invoke a method on business service object that will use the Ship Station API to asynchronously (but sequentially) create the customer record* and then create the invoice record.

When Ship Station prints the shipping labels, a webhook will POST a link to SSA providing a URL that can be used to retreive information about the orders[?] and tracking numbers. The REST service will invoke a GET using the provided URL to obtain the data. That data will be marshalled according to AfterShip requirements and will be POSTED[?] to AfterShip.

On order Creation Snipcart -> SSA -> Ship Station(client)

On label printing (through ShipStation On Shipping Webhook) Ship Station -> SSA (access url) SSA GET -> ShipStation (data) SSA -> AfterShip


Useful Links

Code

https://www.concretepage.com/spring-5/spring-resttemplate-postforobject

https://www.baeldung.com/spring-resttemplate-post-json

shipstation.com

  • AKA: ship-station-relay
  • formerly known as: shopify-square-automation
  • deployed to Heroku through: /home/dean/projects/java/rest/heroku-only-production/delta8ship2

History

The original project was created strictly to enable payments for orders generated by SnipCart and invoked by a web hook and handled through the "Square API". It was known then as shopify-square-automation . Later this was rendered unneeded when other payments were approved. The application then run on Digital Ocean was eventually shut down.

Later, the SnipCart webhook "trigger" was useful for sending data to ShipStation. At this time the application was renamed to ship-station-relay. At this time the project was moved to [[Heroku]]. See notes below Shortly after that, handling of a webhook from ShipStation was added to relay data to AfterShip.

June 28, 2022 Other payment methods were revoked so we need to start using the Square API agan.


Deployment

I realized today that I didn't remember how to make changes in the production deployment on [[Heroku]]. I'm now reconstructing how this is done. These are my notes for future reference.

The Heroku environment is deployed by hosting a git repository on Heroku. See [[Heroku]] for details on this.

I'm using a very unusual mechanism for development and deployment at this time and I should probably change it... but not today.

Development is done using Eclipse. The project directory is located at: /home/dean/projects/java/rest/ship-station-relay

Because Heroku requires everything (including API secrets) to be pushed to the heroku repository, and because I want to maintain a separate (safert) directory on GitHub, Heroku deployment is actually done from this one: /home/dean/projects/java/rest/heroku-only-production/delta8ship2

The downside to this is once testing is complete in the development directory I have to manually transfer changes to the heroku-only dir.


This API performs Three separate functions. the /ssa end point receives data from the SnipCart webhook. It processes the payment and notifies ShipStation of order shipping details.

the /shipped endpoint receives shipping data from ShipStation and relays it to AfterShip.

The ShipStatioon processing:

  1. When an order is placed, data is received from the SnipCart eCommerce service, marshaled and forwarded to Ship Station.
  2. When Ship Station prints the shipping label, data will be received, marshaled and forwarded to AfterShip.

For planning my API interface on the Ship Station side I need to research the API setup and use. The focus of these notes is the

On Order Shipped Webhook

On Order Shipped is a bit of a misnomer since it is triggered when the order label is printed.

Setup and basics Use the article in Resources to set up the target URL to post to /shipped. This should be the same url as the existing heroku url currently set up for /ssa. Ask Devin to see how we set this up for the /ssa endpoint

I made a copy of the existing SSA API java application renamed to Ship Station Relay. We'll keep the existing application in place until we've tested the replacement. This should let us deply both applications. I'll temporarily disable the "save new order" part until we're ready to take down the existing application.

Q. Is the same API key used for all calls to the SSAPI? A. - If you already have API keys, do NOT generate new ones. Instead, copy your existing key and secret.

Using the Webhook

When a webhook is triggered, ShipStation makes an API POST call to the target URL. On Order Shipped response will contain something like this.

{
    "resource_url":"https://ssapiX.shipstation.com/shipments?storeID=123456&batchId=12345678",
    "resource_type":"SHIP_NOTIFY"
}

To use the webhook payload, you must make an API GET call to the ShipStation REST API that uses the resource_url as the endpoint.

Note: the reference to the batchId implies there may be more than one order processed.

Questions: Can Devin manually trigger this through the Ship Station API?

Resources

Ship Station API article

Article on webhook basics setting them up


order-tracking's People

Contributors

witcradg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.