This repository showcases an integration example of some features and capabilities of Adyen Payments integration with Salesforce Composable Storefront (PWA) for B2C Commerce.
Before you start this demo, make sure that:
- You have created an Adyen Test Account
- You have a Salesforce sandbox connected to your Salesforce Commerce Cloud (SFCC) instance. You can create an on-demand sandbox.
- You have set up your sites and SLAS for Composable Storefront.
- You have set up and know where to find configuration values for your local environment.
You can run this demo in 2 ways: using an Open Source online workspace (Gitpod) or on your local machine.
⚠️ Important Notice: This application is not intended for production use. While the application demonstrates key functionalities, it has not been developed with the robustness, security, compatibility, and scalability necessary for production environments.
Quick online demo with Gitpod
- Get your Test API credentials ready. Don't have an Adyen API Key? Log in to your Customer Area, Go to Developers > API credentials, and create a set of API Credendials for your integration.
- Get all the required environment variables below, append the value of
COMMERCE_API_SITE_ID
with all Adyen environment variable names. For example, if yourCOMMERCE_API_SITE_ID
isRefArch
, yourADYEN_API_KEY
should beRefArch_ADYEN_API_KEY
. Go to gitpod account variables and add all required variables. This is a one-time setup.
RefArch_ADYEN_API_KEY="YOUR_ADYEN_API_KEY"
RefArch_ADYEN_MERCHANT_ACCOUNT="YOUR_ADYEN_MERCHANT_ACCOUNT"
RefArch_ADYEN_CLIENT_KEY="YOUR_ADYEN_CLIENT_KEY"
COMMERCE_API_CLIENT_ID="YOUR_MRT_COMMERCE_API_CLIENT_ID"
COMMERCE_API_ORG_ID="YOUR_MRT_COMMERCE_API_ORG_ID"
COMMERCE_API_SHORT_CODE="YOUR_MRT_COMMERCE_API_SHORT_CODE"
COMMERCE_API_SITE_ID="RefArch"
COMMERCE_API_DEFAULT_SITE="RefArch"
SCAPI_URL="*.api.commercecloud.salesforce.com"
OCAPI_URL="*-123.sandbox.xx00.dx.commercecloud.salesforce.com"
ENVIRONMENT_ID="YOUR_MRT_ENVIRONMENT_ID"
PROJECT_ID="adyen-salesforce-pwa-demo"
- To setup webhooks, add the following variables to Gitpod. (Set scope:
adyen-examples/*
)
RefArch_ADYEN_WEBHOOK_USER="YOUR_ADYEN_WEBHOOK_USERNAME"
RefArch_ADYEN_WEBHOOK_PASSWORD="YOUR_ADYEN_WEBHOOK_PASSWORD"
RefArch_ADYEN_HMAC_KEY="YOUR_ADYEN_HMAC_KEY"
- Optional additional variables;
COMMERCE_API_CLIENT_ID_PRIVATE="YOUR_COMMERCE_API_CLIENT_ID"
COMMERCE_API_CLIENT_SECRET="YOUR_COMMERCE_API_CLIENT_SECRET"
SFCC_REALM_ID="YOUR_SFCC_REALM_ID"
SFCC_INSTANCE_ID="YOUR_SFCC_INSTANCE_ID"
SFCC_OAUTH_SCOPES="sfcc.orders sfcc.orders.rw"
- In the Customer Area, add
https://*.gitpod.io
to the list of Allowed Origins associated with the Client Key to make sure the UI can load the Drop-in and Components - In the redirect field of SLAS UI Admin Client settings, append a
|
character followed byhttps://*.gitpod.io/callback
http://127.0.0.1:3000/callback|http://localhost:3000/callback|https://*.mobify-storefront.com/callback|https://*.gitpod.io/callback
- Click the button below
- Click Continue to open with the default Gitpod Workspace.
You can run this demo on your local machine.
- Node v18 or later
- npm v9 or later
git clone https://github.com/adyen-examples/adyen-salesforce-pwa-headless-demo.git
- Create a
./.env
file with your environment variables.
- Copy the
./.env.example
file and rename the file to .env.
- Set the variables in the .env file. Replace
YOUR_SITE_ID
in the variables with your Salesforce Site ID, this value is identical to the value you have forCOMMERCE_API_SITE_ID
f.e.RefArch_ADYEN_API_KEY
whereRefArch
is your Site ID.
It is required to specify the domain or URL of the web applications that will make requests to Adyen.
In the Customer Area add http://localhost:3000
to the list of Allowed Origins associated with the Client Key.
npm install
npm run start
Visit http://localhost:3000/ to view storefront and make a test payment.
Try out the different payment methods with our test card numbers and other payment method details.
In the Customer Area under the Developers → Webhooks
section, create a new Standard webhook
.
A good practice is to set up basic authentication, copy the generated HMAC Key and set it as an environment variable. The application will use this to verify the HMAC signatures.
Make sure the webhook is enabled, so it can receive notifications.
This demo provides a simple webhook implementation exposed at /api/webhooks/notifications
that shows you how to receive, validate and consume the webhook payload.
The following webhooks events
should be enabled:
- AUTHORISATION
To make sure that the Adyen platform can reach your application, we have written a Webhooks Testing Guide that explores several options on how you can easily achieve this (e.g. running on localhost or cloud).
We commit all our new features directly into our GitHub repository. Feel free to request or suggest new features or code changes yourself as well!
Find out more in our Contributing guidelines.
MIT license. For more information, see the LICENSE file in the root directory.