Skip to main content

Shopify

Shopify event integrations receive webhook callbacks from a Shopify store and trigger handler functions as orders, customers, products, and fulfillments change. Use them to sync order data with external systems, keep customer records up to date, or automate fulfillment workflows without polling the Shopify Admin API.

note

The Shopify webhook listener must be reachable from the internet. For local development, use a tunneling tool such as ngrok to create a public URL for your local port. In production, deploy the integration to a publicly accessible host.

After starting the integration, register the webhook in your Shopify admin under Settings > Notifications > Webhooks (or via the Admin API), pointing the webhook URL to https://<your-host> with the topic that matches the event handlers you implement (for example, orders/create). Use the same API secret key configured in Shopify as the listener's apiSecretKey, which the listener uses to verify the X-Shopify-Hmac-SHA256 signature on incoming requests.

Creating a Shopify service​

Service and listener configuration​

Listener configuration (shopify:ListenerConfig):

FieldDescriptionDefault
apiSecretKeyThe Shopify app's API secret key, viewable under Webhooks in the Shopify admin dashboard. Used to verify the HMAC signature Shopify sends with each webhook request.Required

Listener initialization:

listener shopify:Listener shopifyListener = new (listenerConfig, 8090);

shopify:Listener accepts a ListenerConfig record and an optional port number (defaults to 8090). The listener starts an HTTP server on that port to receive Shopify webhook callbacks.

A single Shopify integration can declare multiple services on the same listener — one per resource type (orders, customers, products, fulfillments) — to handle the topics that matter to your integration.

Event handlers​

The ballerinax/trigger.shopify package exposes one service type per Shopify resource. Attach the service types you need to a shopify:Listener and implement only the handlers relevant to your integration.

OrdersService handlers​

HandlerTriggered when
onOrdersCreateA new order is created
onOrdersUpdatedAn existing order is updated
onOrdersPaidAn order is marked as paid
onOrdersFulfilledAn order is fully fulfilled
onOrdersPartiallyFulfilledAn order is partially fulfilled
onOrdersCancelledAn order is cancelled

CustomersService handlers​

HandlerTriggered when
onCustomersCreateA new customer record is created
onCustomersUpdateAn existing customer record is updated
onCustomersEnableA customer account is enabled
onCustomersDisableA customer account is disabled
onCustomersMarketingConsentUpdateA customer's marketing consent status changes

ProductsService handlers​

HandlerTriggered when
onProductsCreateA new product is created
onProductsUpdateAn existing product is updated

FulfillmentsService handlers​

HandlerTriggered when
onFulfillmentsCreateA new fulfillment is created for an order
onFulfillmentsUpdateAn existing fulfillment is updated

What's next​