Vue Storefront is now Alokai! Learn More
Extend Payment Request

Extend Payment Request

The guide illustrates how to extend the request sent to Adyen

The payment request to Adyen may be extended with custom attributes via the buildCustomPaymentAttributes property, which is a function that returns the desired attributes along with their values. The attributes will be concatenated to the already built base payload.

The buildCustomPaymentAttributes can be added to the adyen.configuration object inside the middleware.config.js

The basic pattern is the same for all properties.

Here's an example:

middleware.config.js
{
  adyen: {
    // ...
    configuration: {
      // ...
      buildCustomPaymentAttributes(params) {
        return {
          nameofProperty: [
            "could",
            "be",
            "an",
            "array"
          ],
          additionalCustomProperty: {
            "now": "this one is an object"
          },
          thirdCustomProperty: "can also be a string"
        };
      }
    }
  }
}

Check the Adyen Doc section on Sessions where you can find available properties to add to your payment requests.

Available params

The first argument of the buildCustomPaymentAttributes function called params has the following type:

export type BuildCustomPaymentAttributesParams = {
  payload: CreateSessionRequestPayload;
  payment: PaymentWithFields;
  cart: Cart;
  shopperLocale?: string;
  customerId?: string;
};
PropertyAlways availableinfo
payload✅ YesAlready built payload that will be sent to the Adyen's POST /sessions endpoint by setting it as a value of the createSessionRequest custom field of the commercetools' payment object. This is what you are extending.
payment✅ YesA commercetools payment object with custom fields specified by commercetools-adyen-integration.
cart✅ YesA commercetools active cart of the current user.