Vue Storefront is now Alokai! Learn More
Commercetools: Configuration

Commercetools: Configuration

Adyen Commercetools Integration Configuration Options

Our Adyen commercetools has two parts: Middleware integration and SDK Module. See the configuration options for each below.

Middleware integration

Configuration interface

import { Client } from "@adyen/api-library";

export interface MiddlewareConfig {
  ctApi: {
    projectKey: string;
    clientId: string;
    clientSecret: string;
    scopes: Array<string>;
    authHost: string;
    apiHost: string;
  adyenApiKey: string;
  adyenEnvironment: "TEST" | "LIVE";
  adyenMerchantAccount: string;
  integrationName: string;
  origin: string;
  userSessionCookie?: string;
  partialPaymentTTL?: number;
  customOrderType?: string;
  buildCustomPaymentAttributes?: ((params: BuildCustomPaymentAttributesParams) => Promise<Record<string, any>>) | ((params: BuildCustomPaymentAttributesParams) => Record<string, any>);
  buildCustomAdyenClientParameters?: (params: { apiKey: string, environment: 'TEST' | 'LIVE' }) => ConstructorParameters<typeof Client>[0];
  onRedirectBack?: TOnRedirectBack

type TOnRedirectBack = (
  context: AdyenIntegrationContext,
  services: {
    ct: CommercetoolsService;
    adyen: AdyenService;
  cart: Cart,
  payment: PaymentWithFields
) => SyncOrAsync<string>;

type SyncOrAsync<T> = T | Promise<T>;

Configuration options:

ctApi.projectKey✅ YesThe project key of your commercetools project.
ctApi.clientId✅ YesThe client ID of your commercetools API client.
ctApi.clientSecret✅ YesThe client secret of your commercetools API client.
ctApi.scopes✅ YesThe scopes of your commercetools API client. It must contain manage_payments and manage_orders.
ctApi.authHost✅ YesThe commercetools authorization endpoint.
ctApi.apiHost✅ YesThe base URL of the commercetools API. It should contain only the base URL, without the path to the GraphQL endpoint. For example, https://.com/ instead of https://.com/vsf-ct-dev/graphql.
adyenApiKey✅ YesYour Adyen API Key
adyenEnvironment✅ YesAdyen's environment, available values are "TEST" or "LIVE"
adyenMerchantAccount✅ YesThe merchant account identifier you want to use for processing payments.
integrationName✅ YesName of the key containing adyen's integration object in the middleware.config.ts file
origin✅ YesBase URL of the frontend application
userSessionCookie⌥ optionalName of the session cookie, by default it's "vsf-commercetools-token".
partialPaymentTTL⌥ optionalTime after unfinished partial payment expires (in miliseconds)
customOrderType⌥ optionalKey of custom order type for storing partial payment's information. Use only if you had to extend already existing custom order type
buildCustomPaymentAttributes⌥ optionalFunction returning object that will be assigned to the payload sent to the Adyen's POST /payments endpoint.
buildCustomAdyenClientParameters⌥ optionalFunction returning object that will be passed to the constructor of Client from @adyen/api-library. Mostly all you need to is pass what you got in params and append liveEndpointUrlPrefix.
onRedirectBack⌥ optionalFunction called after coming back from redirect-based method. It has to return URL where an user will be redirected. It's also used to place an order after succesful payment.
onRedirectBackFailed⌥ optionalFunction called in catch block if onRedirectBack thrown an error. It has to return URL where an user will be redirected in that scenario.
enableHmacSignature⌥ optionalBoolean determining if endpoint for ORDER_CANCEL event should check HMAC signature
secretHmacKey⌥ optionalHMAC secret key used if enableHmacSignature is enabled

Example configuration for Commercetools

const middlewareConfig = {
  // ...
  adyen: {
    location: '@vsf-enterprise/adyen-commercetools-api/server',
    configuration: {
      ctApi: {
        apiHost: '<CT_HOST_URL>',
        authHost: '<CT_AUTH_URL>',
        projectKey: '<CT_PROJECT_KEY>',
        clientId: '<CT_CLIENT_ID>',
        clientSecret: '<CT_CLIENT_SECRET>',
        scopes: ['manage_payments:<ADYEN_PROJECT_IDENTIFIER>', 'manage_orders:<ADYEN_PROJECT_IDENTIFIER>']
      adyenApiKey: '<ADYEN_API_KEY>',
      adyenMerchantAccount: '<ADYEN_MERCHANT_ACCOUNT>',
      returnUrl: 'http://localhost/adyen-redirect-back',
      adyenCheckoutApiBaseUrl: '<ADYEN_CHECKOUT_API_BASE_URL>',
      adyenCheckoutApiVersion: 71,
      adyenEnvironment: 'TEST',
      integrationName: 'adyen', // Name of the key containing adyen's integration object in the middleware.config.ts file
      origin: 'https://my-alokai-frontend.local', // URL of frontend

SDK module

Configuration interface

type AdyenEnvironment =
  | "test"
  | "live";

 * Options for the SDK module.
interface Options {
   * The API URL of the Middleware Adyen commercetools
   * integration accessible from the browser.
  apiUrl: string;

   * Adyen's client key
  adyenClientKey: string;

   * Adyen's environment
  adyenEnvironment: AdyenEnvironment;

Example configuration for Commercetools

  apiUrl: 'http://localhost/api/adyen',
  adyenClientKey: 'test_***',
  adyenEnvironment: 'test',