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 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: MakePaymentRequestPayload;
payment: PaymentWithFields;
cart: Cart;
origin: string;
customerId?: string;
balance?: Balance;
};
Property | Always available | info |
---|---|---|
payload | ✅ Yes | Already built payload that will be sent to the Adyen's POST /payment endpoint by setting it as a value of the makePaymentRequest 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. |
origin | ✅ Yes | Base URL of the frontend application |
customerId | ❌ No | An ID of the current user in commercetools |
balance | ❌ No | Balance of partial payment that has been used to adjust amount planned of commercetools payment object |