Newsletter Subscriptions
This guide explains how to integrate a custom newsletter subscription service into SCAYLE's Checkout. By following the steps, you can:
- Determine if a customer is already subscribed
- Handle subscription status updates
If you're using Emarsys or Mailchimp, an add-on is available to handle this step automatically.
Prerequisites
Before you begin, you need to build the following components:
- Middleware to check subscription status and handle the subscription webhook.
- An HTTP endpoint that can receive subscription status requests and respond accordingly.
- Configuration in the SCAYLE Panel to enable the subscription check and webhook handling.
Integration Flow
newsletter-subscribed
webhook to your service.Build Newsletter Subscription Check Endpoint
You need to provide an HTTP service that:
- Can handle the usual load of your shop.
- Accepts requests from SCAYLE networks.
If you want to limit incoming traffic by IP address, your SCAYLE Account Manager can provide more information about our networks.
Endpoint Specification
- Method: GET
Headers
Authorization
: Basic auth (credentials need to be added to the Newsletter Subscription Configuration).X-Shop-Id
: The current shop-country ID.
Query Parameters
Parameter | Type | Description |
---|---|---|
customerId | integer | The current customer ID |
emailHash | string | The current customer email hash |
customerReferenceKey | string | The current customer reference key |
Response
- Status Codes:
- 200 – Subscription status in response body
- 401 – Authentication failed
- 404 – Subscription not found
Response Body Example
{
"status": "subscribed"
}
Status Descriptions
Status | Description | Result |
---|---|---|
open | Subscription does not exist | Display checkbox |
subscribed | Subscription exists | Don’t display |
confirmed | Subscription was confirmed | Don’t display |
OpenAPI Specification
An example OpenAPI specification that can be customized is available for download:
Download Newsletter-Subscription-API.yaml
Configure Subscription Check Endpoint in SCAYLE
The Subscription Check Endpoint Configuration can be set via the SCAYLE Panel:
- Go to Settings ➜ Imports & Jobs ➜ Imports.
- Create a new Shop Import inside Checkout Configurations.
- Provide the following Field as
configuration_key
file and upload the configuration:- newsletter.subscriptionCheck.password
- newsletter.subscriptionCheck.username
- newsletter.subscriptionCheckEndpoint.endpoint
Create a Newsletter-Subscribed Webhook
You can create a newsletter-subscribed
webhook in the SCAYLE Panel:
- Go to Settings ➜ Webhooks ➜ Admin Webhooks.
- Enter the following:
- Version – For example:
1
- Event Name – Select
newsletter-subscribed
- URL – The URL that will be called when the webhook is triggered
- Version – For example:
- Click SAVE
Alternatively, you can add a newsletter-subscribed
webhook using the Admin API.
Enable Subscription Checkbox on the Frontend
- Go to Settings ➜ Checkout ➜ Configurations.
- Navigate to Dynamic Field ➜ Payment Options and Enable Area.
- Create a new checkbox field:
- Name:
newsletterSignUp
- Name:
- Save the configuration.
The subscription checkbox is now enabled in the checkout frontend.