Skip to main content
This page guides you through the steps to set up your Salesforce Composable Storefront integration with Adyen.

Salesforce Composable Storefront package

Use our Composable Storefront package for accepting payments

Before You Begin

Requirements

Before you begin, take into account the following requirements, limitations, and preparations.

Install-The-Cartridge

Step 1: Install the cartridge and import the metadata

The npm package for the Composable Storefront integration works together with a cartridge for the Salesforce Commerce Cloud (SFCC) cartridge. The companion cartridge extends your Salesforce Business Manager with additional functionality that lets you use Adyen features that are not supported by the Salesforce B2C Commerce API (SCAPI).
  • The metadata files in the cartridge handle the necessary configurations:
    • Payment configuration: Defines the Adyen payment processor, enabling card payments and various alternative payment methods.
    • System Object extensions: Extends standard objects like Basket, OrderPaymentInstrument, and PaymentTransaction to store Adyen-specific payment data.
    • Job schedules: Includes the jobs that processes pending webhooks, and the jobs that clean up the processed webhooks.
  • The cartridge creates custom SCAPI endpoints in the Business Manager to handle payment flows.
    • Notify endpoint: Receives the incoming Adyen webhook data and securely stores it in the Business Manager for later processing by the scheduled job.
    • Create Order endpoint: Creates an order and assigns it an order number, so that the number can be used when making a payment. This is required for gift card payments.
    • Get Order endpoint: Retrieves order details for an order when it is created.
  • The cartridge creates a custom SCAPI hook in the Business Manager that automatically generates and manages order numbers to prevent conflicts.
To set up the cartridge:
  1. Download the cartridge from our GitHub repository.
  2. In your cartridge’s root directory, create a dw.json file that includes the information required to establish a server connection and the code version that you want to upload your cartridge to. Read more about WebDAV authentication in the Salesforce documentation. Example dw.json file
  3. From your cartridge’s root directory, install Node modules using your command line.
  4. Run the following to generate output that is compatible with JavaScript ES5.
    The source files in the /src directory use modern Javascript ES6+ syntax and modern tooling that Salesforce Commerce Cloud does not natively support.
  5. To add new configuration items, import the predefined metadata:
    1. Open the adyen-salesforce-headless-commerce-pwa/metadata/site_import/sites/ folder.
    2. Rename the yourSiteId (RefArch) folder to the ID of your site in your Salesforce Business Manager.
    3. Open the adyen-salesforce-headless-commerce-pwa/metadata/site_import/jobs.xml file.
    4. Rename the site-id to the ID of your site in your Salesforce Business Manager.
    5. Zip the site_import folder.
    6. In the Business Manager, go to Administration > Site Development > Site Import & Export and import the zipped file.
  6. In the Business Manager, go to Administration > Sites > Manage Sites > [yourSite] > Settings.
  7. In the Cartridges box, enter int_adyen_PWA, to set up the cartridge path. Select Apply.

Build Pwa App

Step 2: Build your local PWA app

To use Adyen as the payment processor for your PWA app, you need to generate a new PWA project.
  1. Initiate the Salesforce PWA Kit starter project with the following command:
    The command-line interface guides you through the setup. While you set up your project, you are asked to link the generated retail app to a demo sandbox or your own sandbox.
  2. Only if you link the retail app to your own sandbox, enter the following details at the command prompt when creating the new app:
  3. Launch your retail app with the following command:

Install Package

Step 3: Install the Adyen package in your local PWA app

  1. In the root directory of your PWA app, install the Adyen Salesforce PWA npm package:
  2. In your PWA app, adjust the overrides/app/ssr.js file to import Adyen routes. You must import routes in the following order:
    1. Adyen routes. Add the following line:
    2. Default Salesforce routes.
    3. Custom routes. We recommend you integrate and test the package without customizations first.
  3. In the overrides/app folder of your Retail React app:
    1. Override the checkout/partials/payment.jsx file to render the AdyenCheckout component from the adyen-salesforce-pwa package. In the next step, you need to configure some required properties for the component.
      See the file in our example package on GitHub.
    2. Override the checkout/confirmation.jsx file to wrap the Salesforce checkout confirmation page with the AdyenCheckout and AdyenCheckoutProvider from the adyen-salesforce-pwa package. See how you can render the components in our GitHub.
    3. Create an error page and register it in routes.jsx as checkout/error. See the example error page on GitHub.
    4. Create a redirect page and register it in routes.jsx as checkout/redirect. See the example redirect page on GitHub.
    See the routes.jsxfile on GitHub to see how you can register pages.
  4. In your package.json file, add the following scripts:
  5. Run the integration:

Configure

Step 4: Configure the checkout component

The AdyenCheckout component requires certain properties. You can use optional properties to customize your integration. On the overrides/app/checkout/partials/payment.jsx page, where you render the AdyenCheckout component, configure the following properties. Example AdyenCheckout configuration

Back Button

Step 5 (Optional): Handle the browser back button

For a better user experience when shoppers navigate away from a redirect payment page, you can implement the following hooks:
  • useHandleBackNavigation: This hook handles the cleanup when a shopper uses the browser’s back button to navigate from a redirect payment page back to the checkout page, to prevent orphaned orders and ensure proper state management.
    The flow is as follows: The hook detects the navigation change and automatically calls the backend cleanup endpoint. This fails any pending Salesforce orders and recreates the basket. The shopper can return to the checkout later without conflicts.
  • useCheckoutErrorRecovery: This hook detects checkout failures, refetches the basket, and forces a clean remount of the AdyenCheckout component.
    The flow is as follows: When a payment fails, the backend automatically fails the Salesforce order, creates a new basket with the same items, and redirects to /checkout?newBasketId={newBasketId}. The hook detects the newBasketId and automatically navigates to /checkout?error=true, refetches the basket with the newly created basket data, and increments adyenCheckoutKey to force a clean remount. The shopper sees a clean checkout state with the recreated basket.
Implementing these hooks is recommended. They work with the standard checkout flow as well as the express checkout flow. To implement these hooks:
  1. Import the hooks.
  2. To handle the back navigation cleanup, add useHandleBackNavigation to your checkout page component, specifying the following properties for this hook:
  3. To handle checkout error recovery, add useCheckoutErrorRecovery to your payment component, specifying the following properties for this hook:
    The useCheckoutErrorRecovery hook returns the following:

Set Up Locales

Step 6: Set up locales in your PWA app

The config/default.js file in the PWA Retail React app contains the locale definitions for your sites. You need to update this file with the locales you want to support in your Salesforce Commerce Cloud site:
  1. In the PWA Retail React app package, go to the config/default.js file.
  2. Set the following fields: See the PWA integration with the Adyen package on GitHub to see an example locale configuration.
  3. In the config/default.js file, change the local attribute from none to query_param or path to display the locale in the URL.
  4. Only if you defined the alias field for locales, in the config/default.js file, remove the comment markers for siteAliases, and provide the aliases for your sites.

Generate Api Key

Step 7: Generate an Adyen API Key

If you already have an SFCC integration with Adyen using Store Front Reference Architecture (SFRA) or SiteGenesis, you do not have to generate a new API Key and you can skip this step. To connect your PWA store to the Adyen APIs, you need to generate an API key in your Adyen Customer Area and add it to the package configuration when you set environment variables in a later step.
  1. Log in to your Customer Area and select your Company account.
  2. Go to Developers > API credentials.
  3. Select the Payments or Platforms tab, depending on your integration type.
  4. Select the credential username.
  5. Under Server settings > Authentication select the API key tab.
  6. Select Generate API key.
  7. Select the copy icon **and store your API key securely in your system. You cannot copy the API key again after you leave the page.
  8. Select Save changes.

Webhooks

Step 8: Set up webhooks

Adyen uses webhooks to inform your Salesforce Commerce Cloud store of payment status changes. In Salesforce Commerce Cloud, webhooks are stored as custom objects that get processed by scheduled jobs. The jobs and custom objects are set by the int_adyen_PWA cartridge that you installed. You first need to set up webhooks in the Adyen Customer Area, then you can configure the jobs to process the webhooks in Salesforce.

Set up webhooks in the Customer Area

  1. In your Customer Area, go to Developers >  Webhooks. If you want to configure webhooks for a merchant account, switch to that merchant account.
  2. Select **Webhook.
  3. From the list of webhooks, next to Standard webhook, select Add.
  4. Under General, configure the following:
  5. Under Server configuration, configure the following:
  6. Under Security, configure the following:
  7. Under Events settings, select the checkbox for the OFFER_CLOSED event code.
  8. If the Additional settings section is available, optionally select the additional information you want to receive in this webhook. Some webhook types do not support more than one event code, so this section does not appear.
  9. Select Save configuration.
The package implements the AUTHORISATION webhook by default. If you want to receive webhooks for more payment events, you can customize your integration after you have successfully deployed your application in MRT and completed testing without any customizations. You cannot test Adyen webhooks on localhost.

Configure scheduled jobs in Salesforce

Webhooks are stored in Salesforce Commerce Cloud as custom object instances to be processed by scheduled jobs. After the metadata import, a scheduled job with ID Process is added to the Salesforce Business Manager > Administration > Operations > Jobs. This scheduled job has two steps that you can check under Job Steps.
  • Process – Processes the webhook and updates the payment status of the order.
  • Clean – Deletes the custom object instance, once it has been processed.
To optimize the processing of your instances, we recommend that you set the frequency of this scheduled job to 1 minute:
  1. Go to the Schedule and History tab for the Process scheduled job.
  2. Set Trigger to Recurring Interval.
  3. In the Run Time pane, set Amount to 1, and Interval to Minutes.

Deploy In Managed Runtime

Step 9: Deploy your application in Managed Runtime

Salesforce’s Managed Runtime (MRT) provides the infrastructure to deploy, host, and monitor your PWA Kit application. Managed Runtime only supports applications created from a PWA Kit template and has a separate admin dashboard. Before you can use MRT and Runtime Admin, Salesforce must enable it for your organization. To enable MRT and Runtime Admin for your organization, reach out to your Salesforce account team. When building your storefront, keep the constraints of MRT environments in mind.

1. Create a new project in Managed Runtime

Follow the steps to create a project in Runtime Admin. Use the following details for your project:

2. Set up the MRT environment

Set up an environment to separate your production storefront from other storefronts, such as development or testing storefronts. Refer to environments in Salesforce docs to learn more about environments.
  • Follow the steps to create an environment in Salesforce Docs.
    Name: use your Sandbox Org ID to easily identify an environment that belongs to a sandbox, and to create variables correctly for each environment.
    Region: we recommend to set your MRT region to the same region that your Salesforce sandbox uses.
    Your Composable Storefront integration with Adyen can only have one region connected to one MRT organization, one SFCC site, and one Adyen Customer Area account.

3. Set the environment variables

  1. In your MRT environment, navigate to your project by selecting your Organization and Project.
  2. Select Environment Variables.
  3. Specify the values for the following variables: When a variable contains YOUR_SITE_ID, replace it with the same value as your Commerce API site ID.
When going live, you need to update some variables you have entered with values from your live Customer Area.

(Optional) Pass configuration through the Adyen options object

Adyen Salesforce PWA v4.3.0 and later support passing the Adyen configuration as a plain JavaScript options object to registerAdyenEndpoints in your ssr.js override, as an alternative to environment variables. This is useful when:
  • Your configuration is loaded from a managed config store rather than process.env.
  • A single hosting environment serves multiple Salesforce Commerce Cloud sites with different Adyen merchant accounts or preferences.
  • You want to flip a setting per site without redeploying with new environment variables.
The two sources can be mixed. Existing deployments that rely only on environment variables continue to work without any change.

Resolution priority

For each configuration key, the first non-undefined value wins, in this order:
  1. options[<siteId>_<KEY>] — site-specific option.
  2. process.env[<siteId>_<KEY>] — site-specific environment variable.
  3. options[<KEY>] — global option.
  4. process.env[<KEY>] — global environment variable.
Only the keys listed in Supported keys are read. Other keys are ignored, so you cannot accidentally leak unrelated values into the Adyen configuration.

Pass the options object to registerAdyenEndpoints

In your Retail React App overrides/app/ssr.js, pass an adyenOptions object as the fourth argument to registerAdyenEndpoints. The keys in the object use the same names as the corresponding environment variables. Pass an options object to registerAdyenEndpoints
You can also mix the options object with environment variables. For example, keep secrets such as ADYEN_API_KEY and ADYEN_HMAC_KEY in environment variables, and use the options object only for non-secret per-site overrides such as ADYEN_NATIVE_3DS.

Supported keys

To scope any of these keys to a single site, prefix the key with <siteId>_, for example RefArch_ADYEN_API_KEY. Never log the options object as is. It can carry secrets such as ADYEN_API_KEY, ADYEN_HMAC_KEY, and ADYEN_WEBHOOK_PASSWORD. Treat the values like environment variables and inject them from a secret manager at runtime.

4. Deploy your project to MRT

To run your application, you must deploy your application to MRT and to the environment you have set up. You also need a Personal MRT API Key.
  1. Follow the steps to generate a Personal MRT API key in Salesforce Docs.
  2. In your Retail React App, save your credentials:
  3. Push your build to MRT:
  4. Follow the steps to deploy the bundle in Salesforce Docs to the environment you have created.

Import Country Region List

Step 10 (Optional): Import the Adyen country/region list

Salesforce allows you to add your list of countries/regions for shipping. Optionally, you can use our default list. To use our country/region list, in your PWA Retail React app, import the Adyen countrylist and export it as SHIPPING_COUNTRY_CODES in the constants.js file:

Level 2 3 Data

Step 11 (Optional): Send Level 2/3 data for cards

Optional Sending Level 2 or Level 3 Enhanced Scheme Data allows you to cut your interchange rates on US domestic transactions by up to 90 basis points. At the same time, your shoppers see additional information about their purchase on their credit card statement. Not all businesses can submit Level 2/3 data. Refer to What is Enhanced Scheme Data? for more information. Sending Level 2/3 data is supported from v4.3.0 of the Adyen Salesforce PWA package. To send Level 2/3 data, add the following environment variables to your Managed Runtime environment: Replace YOUR_SITE_ID with the same value as your Commerce API site ID.

Donations

Step 12 (Optional): Set up donations with Adyen Giving

After a successful payment, you can show the shopper one or more active donation campaigns on the order confirmation page. The shopper can contribute to a charity using the same payment method that authorized the purchase, without re-entering payment details. Donations are supported only for payment methods that return a donationToken on /payments or /payments/details, for example cards and several APMs. Gift cards are not supported. Adyen Giving is supported from v4.3.0 of the Adyen Salesforce PWA package.

1. Configure Adyen Giving

  1. In your test Customer Area, create and activate a donation campaign for the merchant account used by your storefront. The campaign currency must match your storefront’s checkout currency.
  2. Subscribe your standard webhook to the DONATION event so that Salesforce Commerce Cloud receives the notification when Adyen settles the donation.
No additional environment variables are required. The integration reuses the Adyen API key and client key that you already configured.

2. Add the donation component to the order confirmation page

The Adyen Salesforce PWA package exposes an AdyenDonations React component that loads the active campaigns, renders the AdyenWeb Donation widget for each campaign, and submits the donation against the order’s payment instrument.
  1. Import the component:
  2. On your order confirmation page, render AdyenDonations only when the order has a non-gift-card payment instrument that carries a c_donationToken. Specify the following properties:
    The component calls GET /api/adyen/donationCampaigns to load active campaigns and POST /api/adyen/donations to submit the donation. On a successful donation, the backend clears c_donationToken on the payment instrument so the widget is not offered again on a page reload.

3. Test your integration

  1. Create and activate a test donation campaign in your test Customer Area.
  2. Place a test order using a test card that supports donations.
  3. On the order confirmation page, select a donation amount and confirm the donation.
  4. Verify that you receive the DONATION webhook for the donation.
When you are ready to go live with Adyen Giving, create and activate a live donation campaign in your live Customer Area and enable the Adyen Giving merchant webhook.

Migrate pages

If you already have an SFCC integration with Adyen using Store Front Reference Architecture (SFRA) or SiteGenesis, you need to migrate your store pages. If you do not have an SFCC integration with Adyen already, you can start testing. You can perform Phased Headless Rollouts to migrate your SFRA or SiteGenesis pages in a phased approach. The Adyen package uses version 8 of the Retail React App with template extensibility. To filter out links to non-PWA kit pages, you can override the overrides/app/routes.jsx file. Salesforce has sample code on GitHub that shows how to override. If you are migrating the checkout page last, you need to route traffic to your SFRA checkout page from your PWA integration. To learn how to apply routing, refer to Salesforce Docs.

Test

Testing

After you have installed and configured the package, use our test cards to test payments. Check the status of test payments in your Customer Area > Transactions > Payments.

Next steps

Set up payment methods

Required. Set up the payment methods that you want to offer in your Salesforce Composable Storefront.

Customize

Check our customization guide to learn how you can modify your integration..