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
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
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.
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:
- When an order is placed, data is received from the SnipCart eCommerce service, marshaled and forwarded to Ship Station.
- 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 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.
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.
Questions: Can Devin manually trigger this through the Ship Station API?
Article on webhook basics setting them up