Fixes Adyen payment methods response + endpoint errors

This commit is contained in:
olivermrbl
2020-08-25 17:24:31 +02:00
parent ee00bd27e4
commit 5fa8e40f94
2 changed files with 14 additions and 5 deletions

View File

@@ -36,7 +36,16 @@ export default async (req, res) => {
region.currency_code
)
res.status(200).json({ paymentMethods: data })
// Adyen does not behave 100% correctly in regards to allowed methods
// Therefore, we sanity filter before sending them to the storefront
const { paymentMethods, groups } = data
const methods = paymentMethods.filter((pm) =>
allowedMethods.includes(pm.type)
)
res
.status(200)
.json({ paymentMethods: { paymentMethods: methods, groups } })
} catch (err) {
throw err
}

View File

@@ -24,7 +24,7 @@ class AdyenService extends BaseService {
})
this.adyenPaymentApi = axios.create({
baseURL: "https://pal-test.adyen.com/pal/servlet/Payment/v53",
baseURL: "https://pal-test.adyen.com/pal/servlet/Payment/v52",
headers: {
"Content-Type": "application/json",
"x-API-key": this.options_.api_key,
@@ -154,7 +154,7 @@ class AdyenService extends BaseService {
const { pspReference, amount } = data
try {
const captured = this.adyenPaymentApi.post("/capture", {
const captured = await this.adyenPaymentApi.post("/capture", {
originalReference: pspReference,
modificationAmount: amount,
merchantAccount: this.options_.merchant_account,
@@ -187,7 +187,7 @@ class AdyenService extends BaseService {
const { pspReference, amount } = data
try {
return this.adyenPaymentApi.post("/capture", {
return this.adyenPaymentApi.post("/refund", {
originalReference: pspReference,
merchantAccount: this.options_.merchant_account,
modificationAmount: amount,
@@ -206,7 +206,7 @@ class AdyenService extends BaseService {
const { pspReference } = paymentData
try {
return this.adyenPaymentApi.post("/capture", {
return this.adyenPaymentApi.post("/cancel", {
originalReference: pspReference,
merchantAccount: this.options_.merchant_account,
})