Strapi plugin logo for Shopify

Shopify

Integrate Shopify in your Strapi application.

Strapi Plugin Shopify

Build a Shopify application with Strapi.

Table Of Content

Requirements

Strapi v4 is required.

Installation

npm install --save strapi-plugin-shopify

Middlewares configuration

Webhooks are authenticated with HMAC calculated on the raw body, strapi::body middleware should be configured to pass the unparsed body as following:

1
2
3
4
5
6
{
  name: 'strapi::body',
  config: {
    includeUnparsed: true,
  },
},

If you want to serve an embedded app directly from Strapi you will find that default CSP policies will not allow to do that, strapi::security middleware should be configured as following (this configuration should be used only if you have problem with the embedded app iframe):

1
2
3
4
5
6
7
8
9
10
11
12
{
  name: 'strapi::security',
  config: {
    contentSecurityPolicy: {
      useDefaults: true,
      directives: {
        'frame-ancestors': null,
      },
    },
    frameguard: false,
  },
},

Shopify Configuration

The Shopify application should be configured as follow:

  • App URL should be set as https://your-domain.com/api/shopify
  • Allowed redirection URL(s) should have both
    • https://your-domain.com/api/shopify/install/callback
    • https://your-domain.com/api/shopify/auth/callback

Screenshot illustrating how to configure the Shopify application

Environment Variables

This plugin needs the following environment variables to work:

VariableExampleDescription
HOST_NAMEshop3.appthe host name of your app without the protocol (http or https)
SHOPIFY_API_KEY553536bf79ee112525f63aaf25df59f8the API key generated by Shopify
SHOPIFY_API_SECRET687b73300b570bdbe53220d84a18e23dthe API secret generated by Shopify
SHOPIFY_SCOPESread_locales,read_productsthe API scopes used by the application
SHOPIFY_APP_EMBEDDEDtruewhether the app is an embedded app or not
SHOPIFY_REDIRECT_URLhttps://shop3.app/homethe url where the user is redirect after authentication

Endpoints

This are the endpoints exposed by this plugin:

MethodPathDescription
GET/api/shopifythe entry point of the application, it handles installation and authentication
POST/api/shopify/webhooksthe default webhooks endpoint called by Shopify
GET/api/shopify/installthe installation endpoint, should not be called directly, use /api/shopify instead
GET/api/shopify/install/callbackthe installation callback endpoint, should be called only by Shopify
GET/api/shopify/auththe authentication endpoint, should not be called directly, use /api/shopify instead
GET/api/shopify/auth/callbackthe authentication callback endpoint, should be called only by Shopify
POST/api/shopify/auth/logoutthe logout endpoint, should be called to delete the Shopify session
GET/api/shopify/shopthis endpoint should be called to get the authenticated shop data
GET/api/shopify/plansthis endpoint should be called to get available subscription plans
GET/api/shopify/subscriptionthis endpoint should be called to get the shop subscription
POST/api/shopify/subscriptionthis endpoint should be called to create a shop subscription

Install now

npm install strapi-plugin-shopify

Last updated

10 days ago

Strapi Compatibility

4.4.5 and above

Author

github profile image for Shop3
Shop3

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.