Vue Storefront is now Alokai! Learn More
Extend Get Payment Methods Request

Extend Get Payment Methods Request

The guide illustrates how to extend the request sent to Adyen

The get payment methods request to Adyen may be extended with custom attributes via the buildCustomGetPaymentMethodsAttributes 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 buildCustomGetPaymentMethodsAttributes 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: {
      // ...
      buildCustomGetPaymentMethodsAttributes(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 where you can find available properties to add to your payment requests.

Available params

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

export type BuildCustomGetPaymentMethodsAttributesParams = {
  payload: GetPaymentMethodsRequestPayload;
  payment: PaymentWithFields;
  cart: Cart;
  shopperLocale?: string;
  customerId?: string;
  order?: EncryptedOrderData;
};
PropertyAlways availableinfo
payload✅ YesAlready built payload that will be sent to the Adyen's POST /paymentMethods endpoint by setting it as a value of the getPaymentMethodsRequest 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.
shopperLocale❌ NoPassed from frontend via SDK.
customerId❌ NoAn ID of the current user in commercetools
order❌ NoAdyen Order object derived from cart's custom fields. Available only in case of the partial payment, starting from the second one.