Shopify Connector — Mule 4

Shyam Raj Prasad
10 min readMay 7, 2022

--

Shopify Introduction

Shopify is a complete commerce platform that lets you start, grow, and manage a business. It is completely cloud-based and hosted, which means you don’t have to worry about upgrading or maintaining software or web servers. This gives you the flexibility to access and run your business from anywhere with an internet connection.

The Shopify connector for Anypoint enables users to integrate their applications with Shopify using the Anypoint Platform and seamlessly orchestrate the flow of data between Shopify and their CRM, marketing, or other cloud-based applications.

Common Use Cases For the Shopify Connector

  • Syncing a new customer’s information when they place an order
  • Storing information when a new order is placed through a client’s Shopify store
  • Managing items when new products are created in Shopify

Shopify Connector Connection Types

Shopify Connector uses the following authentication methods:

  • Basic Auth: Uses a username and password for authentication.
  • OAuth2: Delegates user authentication to the service hosting the user account.

Shopify Account Setup

  1. Go to Shopify for free trial account creation, https://www.shopify.in/free-trial. Click on a free trial and provide the below information to create accounts.

2. Set up your account and add your address in the Shopify account setup.

3. Go to apps and click on Develop apps button. Create an app, and provide some app names.

4. Click on configure admin API scopes.

5. Add below admin scopes for admin API integration and save it. Shopify connector is mainly used for read or write operations on customers, orders, and products.

6. Go to configuration and verify the scopes.

7. Go to the API credentials tab and click on the install app.

8. After installing the app, you will see the admin API access token screen.

9. When you click the reveal token once and save this password in a secure place, it will be the Shopify connector password.

10. On the same page, you will find all the Shopify credentials, which will be required for Shopify mulesoft connector.

Shopify Mulesoft Integration

  • Mule Project: Create a mule project named mulesoft-shopify-integration
  • Add Shopify Module: Go to mule palette, search Shopify in exchange and add Shopify connector.
  • Application Properties: Create an application properties file under src/main/resources and add the below properties.
shopify.shop=${shopify.shop}
shopify.username=${shopify.username}
shopify.password=${shopify.password}

These three variables will be passed from the runtime environment or you can replace these credentials in the above file. All these three properties can be found in the 10th step of the Shopify account setup.

  • Configuration Properties: Go to global settings and add configuration properties
  • Shopify Configuration: Go to global settings and Shopify connector configuration.
  • HTTP Listener Configuration: Go to global Elements settings, and add HTTP listener configuration with default settings.
  • Globals Configuration: After adding all configuration, global file will be looks like as below:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:shopify="http://www.mulesoft.org/schema/mule/shopify"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/shopify http://www.mulesoft.org/schema/mule/shopify/current/mule-shopify.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<shopify:config name="Shopify_Connector_Config" doc:name="Shopify Connector Config" doc:id="340eb796-b74a-45f2-b898-24b1c11aad9e" >
<shopify:basic-auth-connection username="${shopify.username}" password="${shopify.password}" baseUri="https://${shopify.shop}.myshopify.com"/>
</shopify:config>
<configuration-properties doc:name="Configuration properties" doc:id="14ff1361-27ab-4527-bb54-d97475fcda75" file="application.properties" />
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="5b4fd97b-670c-4bd1-a70a-cbe9f2f696e3" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
</mule>
  • Shopify Customer Config: Create a new mule configuration file for Shopify customers and add all the endpoints in this file. Below customer endpoints are available in Shopify.
  • Update customer config: update customer config with the below content, it will have all the endpoints of the customer.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:sockets="http://www.mulesoft.org/schema/mule/sockets"
xmlns:shopify="http://www.mulesoft.org/schema/mule/shopify"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/shopify http://www.mulesoft.org/schema/mule/shopify/current/mule-shopify.xsd
http://www.mulesoft.org/schema/mule/sockets http://www.mulesoft.org/schema/mule/sockets/current/mule-sockets.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<flow name="customersCountFlow" doc:id="b83fbc3b-8bbb-441a-8c63-6188e8bdac93" >
<http:listener doc:name="Listener" doc:id="1a4e2406-c1d2-4063-a62d-b2acf9edf209" config-ref="HTTP_Listener_config" path="/customers/count"/>
<shopify:customer-count doc:name="Customer Count" doc:id="b6642f29-9da3-4d8b-8375-2da416fb2ac2" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="customersCreateFlow" doc:id="128743fe-4ddb-4495-849e-9ec58e179868" >
<http:listener doc:name="Listener" doc:id="78cd8fb8-f967-4585-a1ea-5381f232744e" config-ref="HTTP_Listener_config" path="/customers" allowedMethods="POST"/>
<shopify:customer-create doc:name="Customer Create" doc:id="c651da04-13bc-4d0c-aa6b-d50ebbbab834" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="customersActivateFlow" doc:id="9b91d085-14e4-4fc1-a086-1074bd3386b7" >
<http:listener doc:name="Listener" doc:id="04b99d5b-18ba-4ff4-ad73-2f7c2ef598c9" config-ref="HTTP_Listener_config" path="/customers/{customerId}/activate"/>
<shopify:customer-create-account-activation-url customerIdUriParam="#[attributes.uriParams.customerId]" doc:name="Customer Create Account Activation Url" doc:id="91bbb52e-e07d-4399-a27a-5f4c4b8bed60" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="customersGetFlow" doc:id="1d5973e1-3e51-46e5-92d2-25abffc485e8" >
<http:listener doc:name="Listener" doc:id="964ca40c-a1a4-4506-b9a1-b846d7b70fe0" config-ref="HTTP_Listener_config" path="/customers/{customerId}"/>
<shopify:customer-get customerIdUriParam="#[attributes.uriParams.customerId]" doc:name="Customer Get" doc:id="7ef732e0-16c3-497b-bbd1-9306a3013475" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="customersGetListFlow" doc:id="5c190181-d0c0-4125-b3d0-a3808171d50b" >
<http:listener doc:name="Listener" doc:id="20d43533-d874-496d-858c-518a196cdae1" config-ref="HTTP_Listener_config" path="/customers" allowedMethods="GET"/>
<shopify:customer-list doc:name="Customer List" doc:id="af64ae58-1db9-4e09-8f5d-a24c0c6a2f70" config-ref="Shopify_Connector_Config"/>
<ee:transform doc:name="Transform Message" doc:id="eefeea0e-04ce-4643-890d-97e11cfd0247" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="customersListOrders" doc:id="f67c0415-dadb-4456-b472-f5b9a36b9fab" >
<http:listener doc:name="Listener" doc:id="8464f673-b122-48a1-86c0-41dbee7717f3" config-ref="HTTP_Listener_config" path="/customers/{customerId}/orders"/>
<shopify:customer-list-orders customerIdUriParam="#[attributes.uriParams.customerId]" doc:name="Customer List Orders" doc:id="52fd689b-ebc1-4ea3-bdb0-46c1dbc550ba" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="customersSearch" doc:id="9a1b890b-5e7b-4659-953f-5f124685895c">
<http:listener doc:name="Listener" doc:id="2bca384e-edf5-40f8-ac0d-3bf9a8debca5" config-ref="HTTP_Listener_config" path="/customers/search"/>
<shopify:customer-search doc:name="Customer Search" doc:id="e8e4fd69-01e7-41fa-8f06-9ddc1de0187c" config-ref="Shopify_Connector_Config" queryQueryParam="#[attributes.queryParams.query]"/>
</flow>
<flow name="customersSendAccountInvite" doc:id="a996eba3-b747-4db2-bc17-02a5816f6431" >
<http:listener doc:name="Listener" doc:id="85805c61-2910-4c7f-848b-d8fc1c772469" config-ref="HTTP_Listener_config" path="/customers/{customerId}/invite"/>
<shopify:customer-send-account-invite customerIdUriParam="#[attributes.uriParams.customerId]" doc:name="Customer Send Account Invite" doc:id="7d283351-cfbc-42ab-aa7b-ab87377251b4" config-ref="Shopify_Connector_Config" />
</flow>

<flow name="customersUpdate" doc:id="6a00fe76-63ef-4658-842c-79f9f6205568" >
<http:listener doc:name="Listener" doc:id="ea184328-c70e-44d3-b7ae-c73c1f969347" config-ref="HTTP_Listener_config" path="/customers/{customerId}" allowedMethods="PUT"/>
<shopify:customer-update customerIdUriParam="#[attributes.uriParams.customerId]" doc:name="Customer Update" doc:id="79dbca85-7da0-4ba2-97b0-cf514334a761" config-ref="Shopify_Connector_Config"/>
</flow>
</mule>
  • Orders Config: Create a new mule configuration file for Shopify orders. Add the below configuration for this.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:shopify="http://www.mulesoft.org/schema/mule/shopify"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/shopify http://www.mulesoft.org/schema/mule/shopify/current/mule-shopify.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<flow name="orderCancel" doc:id="cf8916c8-c25e-4a6f-a75e-7cb1c8935b45" >
<http:listener doc:name="Listener" doc:id="f179e8ac-9543-41f9-a8ff-9ea8daa768be" config-ref="HTTP_Listener_config" path="/orders/{orderId}/cancel" allowedMethods="POST"/>
<shopify:order-cancel orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Order Cancel" doc:id="0d4f9909-5607-45e1-bd02-4583c288c562" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="ordersClose" doc:id="172d7a4d-790b-42d2-ad52-996e9ce6d728" >
<http:listener doc:name="Listener" doc:id="f63dc536-92bd-433a-8a62-3b864ea7fb00" config-ref="HTTP_Listener_config" path="/orders/{orderId}/close" allowedMethods="POST"/>
<shopify:order-close orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Order Close" doc:id="410666e5-5447-49a0-9669-feae119f8033" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="ordersCreate" doc:id="b49e56b4-97dc-49d6-96fa-f15d9ea8d658" >
<http:listener doc:name="Listener" doc:id="ab87368e-5879-4230-9474-cea1c41daf39" config-ref="HTTP_Listener_config" path="/orders" allowedMethods="POST"/>
<shopify:order-create doc:name="Order Create" doc:id="bc81bebc-78c2-476d-894e-5e61a3187fad" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="ordersDelete" doc:id="6ff7324e-533a-4a13-a343-c6176520e633" >
<http:listener doc:name="Listener" doc:id="24ede3ce-ca08-4da0-8b99-d9d087f0c5ab" config-ref="HTTP_Listener_config" path="/orders/{orderId}" allowedMethods="DELETE"/>
<shopify:order-delete orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Order Delete" doc:id="ec7e737c-c390-4d05-805c-7daba24bd1b5" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="ordersGet" doc:id="5d88b523-0417-4a6f-803a-a62d8ea6c88a" >
<http:listener doc:name="Listener" doc:id="c22f914a-7185-431d-99d2-1cb90b3f52e6" config-ref="HTTP_Listener_config" path="/orders/{orderId}" allowedMethods="GET"/>
<shopify:order-get orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Order Get" doc:id="c53bb173-f46b-4a1e-8ecc-6f1cba12846b" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="ordersList" doc:id="208a1e16-f80d-44fe-be0f-7265aeeba741" >
<http:listener doc:name="Listener" doc:id="ccfce5f5-69da-4e8f-b81c-06efe311ac7c" config-ref="HTTP_Listener_config" path="/orders" allowedMethods="GET"/>
<shopify:order-list doc:name="Order List" doc:id="b0a76d6b-4ad9-44e2-8dd3-b05bb8f6ab73" config-ref="Shopify_Connector_Config"/>
<ee:transform doc:name="Transform Message" doc:id="02e0ca73-40ff-48a0-979d-1c1b8d7d1aee" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="ordersReopen" doc:id="df8c4a29-988a-4b8c-9d8b-7833e3cb2d49" >
<http:listener doc:name="Listener" doc:id="285ecea0-ab54-47f6-a25a-367a4d874087" config-ref="HTTP_Listener_config" path="/orders/{orderId}/open"/>
<shopify:order-reopen orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Order Reopen" doc:id="bfb6bc51-0e51-4192-9f5d-19cb609fef63" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="ordersUpdate" doc:id="aaf3823c-eec4-4158-bd6d-4eb2a20b0197" >
<http:listener doc:name="Listener" doc:id="a56454e6-19e8-4bf1-b52e-84e60b43ad8d" config-ref="HTTP_Listener_config" path="/orders/{orderId}" allowedMethods="PUT"/>
<shopify:order-update orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Order Update" doc:id="08a93882-80a2-4da5-a991-a99c75bab115" config-ref="Shopify_Connector_Config"/>
</flow>
</mule>
  • Product Config: Create a new mule configuration file for Shopify Products. Add the below configuration for this.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:shopify="http://www.mulesoft.org/schema/mule/shopify"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/shopify http://www.mulesoft.org/schema/mule/shopify/current/mule-shopify.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<flow name="productsCount" doc:id="81fa0568-4681-4d94-91ff-390c5bfbb081" >
<http:listener doc:name="Listener" doc:id="08308c4e-5ac0-460a-a19b-34e5df93df50" config-ref="HTTP_Listener_config" path="/products/count" allowedMethods="GET"/>
<shopify:product-count doc:name="Product Count" doc:id="49081087-1cbb-468a-95df-9a7a14096e10" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsCreate" doc:id="bd00c01b-55f7-404f-b79f-4ded2f1ba818" >
<http:listener doc:name="Listener" doc:id="5721a740-4e0a-41ce-90e6-a3f63c7c5e10" config-ref="HTTP_Listener_config" path="/products" allowedMethods="POST"/>
<shopify:product-create doc:name="Product Create" doc:id="42c819a6-3c13-4562-9f96-e4845399ef6d" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsDelete" doc:id="a5772ff1-c744-433c-9baa-0ad578e8836f" >
<http:listener doc:name="Listener" doc:id="ff0a7660-bce7-4435-b6d8-b5d33079cac8" config-ref="HTTP_Listener_config" path="/products/{productId}" allowedMethods="DELETE"/>
<shopify:product-delete productIdUriParam="#[attributes.uriParams.productId]" doc:name="Product Delete" doc:id="36e46c09-de1c-4fc2-ac52-e00ee5ede6d1" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsGet" doc:id="a62676b9-2b86-4e66-8185-de3150ef9e12" >
<http:listener doc:name="Listener" doc:id="f4e4949d-f45c-4c6e-9bde-91f0bb785ec6" config-ref="HTTP_Listener_config" path="/products/{productId}" allowedMethods="GET"/>
<shopify:product-get productIdUriParam="#[attributes.uriParams.productId]" doc:name="Product Get" doc:id="f02412d7-ca2e-475d-bf7b-c424ace0fe30" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsList" doc:id="41bdf50f-4261-49bb-be00-ce9123d1f84b" >
<http:listener doc:name="Listener" doc:id="4de70422-4807-4039-aca7-427a84addd38" config-ref="HTTP_Listener_config" path="/products" allowedMethods="GET"/>
<shopify:product-list doc:name="Product List" doc:id="f5d2de7d-2fbc-467f-b30c-2ecc4e178215" config-ref="Shopify_Connector_Config"/>
<ee:transform doc:name="Transform Message" doc:id="882ae48f-55e0-4f1b-b094-d9a717fb3ebf" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="productsUpdate" doc:id="41d1383d-3832-4ab2-971c-5135b9428549" >
<http:listener doc:name="Listener" doc:id="312504df-4965-42fb-8fd7-8bcc459c6c04" config-ref="HTTP_Listener_config" path="/products/{productId}" allowedMethods="PUT"/>
<shopify:product-update productIdUriParam="#[attributes.uriParams.productId]" doc:name="Product Update" doc:id="96fa1917-bca4-46a6-8325-0e6a147b250d" config-ref="Shopify_Connector_Config"/>
</flow>
</mule>
  • Product Variant Config: Create a new mule configuration file for Shopify Products variant. Add the below configuration for this.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:shopify="http://www.mulesoft.org/schema/mule/shopify"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/shopify http://www.mulesoft.org/schema/mule/shopify/current/mule-shopify.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<flow name="productsVariantCount" doc:id="31e8391e-b8ca-4fa2-a2ef-a5df038b3326" >
<http:listener doc:name="Listener" doc:id="56c696af-c4b3-4f93-8dd2-3ca7d2d9054d" config-ref="HTTP_Listener_config" path="/products/{productId}/variants/count" allowedMethods="GET"/>
<shopify:product-variant-count productIdUriParam="#[attributes.uriParams.productId]" doc:name="Product Variant Count" doc:id="88184ba2-c733-456c-afbd-e952587d625a" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsVariantCreate" doc:id="246cb027-3ee1-4c7d-8d2b-d57ff00bb71c" >
<http:listener doc:name="Listener" doc:id="70f68807-e830-4177-997a-2f6ceeb66d21" config-ref="HTTP_Listener_config" path="/products/{productId}/variants" allowedMethods="POST"/>
<shopify:product-variant-create productIdUriParam="#[attributes.uriParams.productId]" doc:name="Product Variant Create" doc:id="4f502ce3-cfa7-4e55-b651-02459bb0e22c" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsVariantDelete" doc:id="fb29046e-791e-4041-9e24-15fc7c80cef6" >
<http:listener doc:name="Listener" doc:id="5e7e808c-9e7d-416e-9bbe-ff9fb1edb6eb" config-ref="HTTP_Listener_config" path="/products/{productId}/variants/{variantId}" allowedMethods="DELETE"/>
<shopify:product-variant-delete productIdUriParam="#[attributes.uriParams.productId]" variantIdUriParam="#[attributes.uriParams.variantId]" doc:name="Product Variant Delete" doc:id="0a9d318d-6a96-4416-919b-1be3e2894f48" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsVariantGet" doc:id="bd5d2453-26cf-433c-9e60-d6e9e3011406" >
<http:listener doc:name="Listener" doc:id="9ce696dd-d747-4539-aeab-6eea9a1afad3" config-ref="HTTP_Listener_config" path="/variants/{variantId}"/>
<shopify:product-variant-get variantIdUriParam="#[attributes.uriParams.variantId]" doc:name="Product Variant Get" doc:id="d4160ff1-1ca2-4d69-bb9b-2794370e3443" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="productsVariantList" doc:id="91d6f3f8-7fb8-457b-8c98-c6d10a52fb97" >
<http:listener doc:name="Listener" doc:id="68d3dff9-680c-4345-ae3d-4bd6abc2072f" config-ref="HTTP_Listener_config" path="/products/{productId}/variants" allowedMethods="GET"/>
<shopify:product-variant-list productIdUriParam="#[attributes.uriParams.productId]" doc:name="Product Variant List" doc:id="f79a25d0-8dac-4380-8f28-951f376a618a" config-ref="Shopify_Connector_Config"/>
<ee:transform doc:name="Transform Message" doc:id="591b739f-620e-49d8-ba6f-b59edc8629db" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="productsVariantUpdate" doc:id="df06f0c4-299e-4de6-888b-a088325b8b09" >
<http:listener doc:name="Listener" doc:id="18360298-b413-4c0c-943e-9ffcc64f4977" config-ref="HTTP_Listener_config" path="/variants/{variantId}" allowedMethods="PUT"/>
<shopify:product-variant-update variantIdUriParam="#[attributes.uriParams.variantId]" doc:name="Product Variant Update" doc:id="88a9e5cb-a0b1-4f1d-aef9-bde41aeefd53" config-ref="Shopify_Connector_Config"/>
</flow>
</mule>
  • Transactions Config: Create a new mule configuration file for Shopify Products variant. Add the below configuration for this.
<?xml version="1.0" encoding="UTF-8"?><mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:shopify="http://www.mulesoft.org/schema/mule/shopify"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/shopify http://www.mulesoft.org/schema/mule/shopify/current/mule-shopify.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<flow name="transactionsCount" doc:id="cb72cd2c-95b7-4653-acc0-05b625c2eb1d" >
<http:listener doc:name="Listener" doc:id="066334c4-39b3-4801-85b6-b06be3e684c3" config-ref="HTTP_Listener_config" path="/orders/{orderId}/transactions" allowedMethods="GET"/>
<shopify:transaction-count orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Transaction Count" doc:id="832affd4-1bf7-4729-a34d-b202f5e27977" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="transactionsCreate" doc:id="dd683fb5-660a-4275-8fdf-ae8cb8130ef2" >
<http:listener doc:name="Listener" doc:id="46fda561-a7c4-4441-90f4-1cbd34c722b0" config-ref="HTTP_Listener_config" path="/orders/{orderId}/transactions" allowedMethods="POST"/>
<shopify:transaction-create orderIdUriParam="0" doc:name="Transaction Create" doc:id="246f0470-4a6c-4bf2-93a5-6b25ff87f20d" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="transactionsGet" doc:id="808435ac-b83c-4424-949c-21df51b59e17" >
<http:listener doc:name="Listener" doc:id="c1ff1555-2907-4f22-bf67-3fca42e10d98" config-ref="HTTP_Listener_config" path="/orders/{orderId}/transactions/{transactionId}"/>
<shopify:transaction-get orderIdUriParam="#[attributes.uriParams.orderId]" transactionIdUriParam="#[attributes.uriParams.transactionId]" doc:name="Transaction Get" doc:id="44598554-79c1-4cc4-a5ae-de5c086b5551" config-ref="Shopify_Connector_Config"/>
</flow>
<flow name="transactionsList" doc:id="b0b9032d-b78e-4026-b730-b8ad7618ae6a" >
<http:listener doc:name="Listener" doc:id="32ef0084-38e9-406e-a619-337c6fd264d5" config-ref="HTTP_Listener_config" path="/orders/{orderId}/transactions"/>
<shopify:transaction-list orderIdUriParam="#[attributes.uriParams.orderId]" doc:name="Transaction List" doc:id="b6361b79-882f-4a62-ae89-12611056a0aa" config-ref="Shopify_Connector_Config"/>
<ee:transform doc:name="Transform Message" doc:id="6d2e199d-734b-47e3-89b4-c1ccf3e526a9" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="unauthorize" doc:id="5e575001-449c-4638-a18a-908c9e3546e6" >
<http:listener doc:name="Listener" doc:id="3e4c5948-3b5c-4e36-a3c0-6f92cd15f0fb" config-ref="HTTP_Listener_config" path="/shopify/unauthorize/{ownerId}"/>
<shopify:unauthorize doc:name="Unauthorize" doc:id="4ca4e1ba-2a8a-4c82-a00e-00a0eb4a7ed8" config-ref="Shopify_Connector_Config" resourceOwnerId="#[attributes.uriParams.ownerId]"/>
</flow>
</mule>

Running Mule Application

We are done with all configurations, make sure you have added the credentials either in the runtime configuration or you can add the credentials in the application.properties file.

Now run the application and hit some of the get endpoints. You can also log in to your Shopify account and create some products and customers. After adding some customers and products, let’s hit a few endpoints and see the results. You can try other endpoints also.

  • Customer list
curl --location --request GET 'http://localhost:8081/customers'
  • Product list:
curl --location --request GET 'http://localhost:8081/products'

Shopify Admin REST API

Below Shopify admin rest API is used in Shopify connector.

In this article, we have integrated Shopify with the mule application.

Note: For orders and transactions API, we have to select a basic plan. Please deactivate your account before the trial ends otherwise you will be charged.

GitHub Repo

References:

--

--

Shyam Raj Prasad
Shyam Raj Prasad

Written by Shyam Raj Prasad

Engineering Leader at Tricon Infotech Private Limited | Mulesoft Certified Developer and Architect

No responses yet