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
middleware.config.js
export interface MiddlewareConfig {
ctApi: {
projectKey: string;
clientId: string;
clientSecret: string;
scopes: Array<string>;
authHost: string;
apiHost: string;
};
returnUrl: string | ((cart: Cart, payment: PaymentWithFields) => string);
adyenApiKey: string;
adyenMerchantAccount: string;
adyenCheckoutApiBaseUrl: string;
adyenCheckoutApiVersion?: number;
userSessionCookie?: string;
buildCustomPaymentAttributes?: ((params: BuildCustomPaymentAttributesParams) => Promise<Record<string, any>>) | ((params: BuildCustomPaymentAttributesParams) => Record<string, any>);
}
Configuration options:
Attribute | required | info |
---|---|---|
ctApi.projectKey | ✅ Yes | The project key of your commercetools project. |
ctApi.clientId | ✅ Yes | The client ID of your commercetools API client. |
ctApi.clientSecret | ✅ Yes | The client secret of your commercetools API client. |
ctApi.scopes | ✅ Yes | The scopes of your commercetools API client. It must contain manage_payments and manage_orders . |
ctApi.authHost | ✅ Yes | The commercetools authorization endpoint. |
ctApi.apiHost | ✅ Yes | The base URL of the commercetools API. It should contain only the base URL, without the path to the GraphQL endpoint. For example, https://<SHOP_DOMAIN>.com/ instead of https://<SHOP_DOMAIN>.com/vsf-ct-dev/graphql . |
returnUrl | ✅ Yes | The URL to which the shopper is redirected after the payment. |
adyenApiKey | ✅ Yes | Your Adyen API Key |
adyenMerchantAccount | ✅ Yes | The merchant account identifier you want to use for processing payments. |
adyenCheckoutApiBaseUrl | ✅ Yes | For sandbox, it has to be https://checkout-test.adyen.com , and for live it has to be https://{PREFIX}-checkout-live.adyenpayments.com/ , you can read more about it here - use only base URL from the linked document. |
adyenCheckoutApiVersion | ⌥ optional | The version of the Adyen Checkout API, by default it's 70 . |
userSessionCookie | ⌥ optional | Name of the session cookie, by default it's "vsf-commercetools-token" . |
buildCustomPaymentAttributes | ⌥ optional | Function returning object that will be assigned to the payload sent to the Adyen's POST /sessions endpoint. |
Example configuration
middleware.config.js
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>']
},
adyenMerchantAccount: '<ADYEN_MERCHANT_ACCOUNT>',
adyenCheckoutApiBaseUrl: 'https://checkout-test.adyen.com',
adyenApiKey: '<ADYEN_API_KEY>',
returnUrl: 'http://localhost/adyen-redirect-back'
}
},
}
Additional configuration
How to disable removeSensitiveData
for createSessionRequest
if it’s enabled in extension/notification modules' configuration?
To disable removeSensitiveData for createSessionRequest when it's enabled in the extension/notification modules, set it to false using buildCustomPaymentAttributes
in middleware.config.js
.
More context is available here.
middleware.config.js
const middlewareConfig = {
// ...
adyen: {
location: '@vsf-enterprise/adyen-commercetools-api/server',
configuration: {
// ...
buildCustomPaymentAttributes (context) {
return {
removeSensitiveData: false
}
},
// ...
}
},
}
SDK Module
Configuration interface
export interface Options {
apiUrl: string;
adyenClientKey: string;
adyenEnvironment: AdyenEnvironment;
}
type AdyenEnvironment =
| "test"
| "live"
| "live-au"
| "live-us"
| "live-apse";
Configuration options:
Attribute | required | info |
---|---|---|
apiUrl | ✅ Yes | The API URL of the Middleware Adyen commercetools integration accessible from the browser. |
adyenClientKey | ✅ Yes | An Adyen client key. It starts with test_ in sandbox mode. |
adyenEnvironment | ✅ Yes | Adyen environment. Choose one of values from the literal type AdyenEnvironment . |
Example configuration
import { initSDK, buildModule } from '@vsf-enterprise/sdk';
import { adyenCtModule } from '@vsf-enterprise/adyen-commercetools-sdk';
const sdkConfig = {
adyen: buildModule(
adyenCtModule,
{
apiUrl: 'http://localhost/api/adyen',
adyenClientKey: 'test_***',
adyenEnvironment: 'test'
}
)
};
export const sdk = initSDK(sdkConfig);