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;
};
Property | Always available | info |
---|---|---|
payload | ✅ Yes | Already 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 | ✅ Yes | A commercetools payment object with custom fields specified by commercetools-adyen-integration. |
cart | ✅ Yes | A commercetools active cart of the current user. |
shopperLocale | ❌ No | A locale of the current user passed optionally when calling createSession SDK method. |
customerId | ❌ No | An ID of the current user in commercetools |