Cloudflare Worker webhook that creates a shipment in Unifaun for orders in Shopify. Features:
- Able to create the shipment with customs information.
- Able to add many customs information lines for one product (e.g. in the case of bundled products).
It is recommended to install this worker as a webhook receiver for the Order fulfillment
event. In this case shipments will be created in Unifaun when orders are marked as fulfilled
.
HS (customs) codes for the products included in the order are configured using tags. Add HS codes by adding one or many tags in the following format:
HS:[COUNTRY]:[STATNO]:[SUBSTATNO1?]:[SUBSTATNO2?]:[CONTENTS]:[COUNT?]:[WEIGHT?]
The tag should always begin with HS:
and then list the properties in the specified order. Properties with a ?
suffix are optional, but please still include the required :
separators. Count is assumed to be one if left blank.
Please use a period .
as a decimal point for the weight.
Example of a tag specifying 22 counts of baby clothes (note that SUBSTATNO2 and weight is left blank):
HS:FI:61112090:2000::Baby clothes set:22
If the bundle includes many products that have the same HS code, you can add them using COUNT. If there are many different HS codes within the same bundle, just add as many HS tags as you need.
You need to create a "Private app" in order to get credentials for reading product tags. The only permission needed is the "Product" permission, which gives the needed read_products
scope.
Also, you need to create a webhook for the Order fulfillment
event. The endpoint should be the URL of the published Cloudflare worker, e.g. https://unifaun-shopify.reima.workers.dev
.
Publishing is done with Wrangler using a GitHub Action. The following environment variables need to be set on the worker (via the Workers web UI or via wrangler):
UNIFAUN_TOKEN
: Unifaun API tokenUNIFAUN_SENDER
: Unifaun Sender ID to send the shipment fromUNIFAUN_SERVICE
: Service code for specifying which shipping service to useSHOPIFY_WEBHOOK_SECRET
: Shopify webhook secretSHOPIFY_BASIC_AUTH
: Shopify basic auth tokenSHOPIFY_SHOP
: Shopify shop name
VSCode preferred. In order to bundle the worker, you need Deno and in order to publish you need Wrangler.