From 1d948fbdd97c1b1d212545a2862f660de1176f44 Mon Sep 17 00:00:00 2001 From: hossam Date: Wed, 24 Jan 2024 11:29:09 +0100 Subject: [PATCH] [ECP-8715] Update to model based PHP Library --- Model/GetAdyenPaymentMethodsByProduct.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Model/GetAdyenPaymentMethodsByProduct.php b/Model/GetAdyenPaymentMethodsByProduct.php index 998e842..97c0847 100644 --- a/Model/GetAdyenPaymentMethodsByProduct.php +++ b/Model/GetAdyenPaymentMethodsByProduct.php @@ -3,11 +3,13 @@ namespace Adyen\ExpressCheckout\Model; +use Adyen\Model\Checkout\PaymentMethodsRequest; use Adyen\Payment\Helper\ChargedCurrency; use Adyen\Payment\Helper\Config; use Adyen\Payment\Helper\Data; use Adyen\Payment\Model\AdyenAmountCurrency; use Adyen\Payment\Model\AdyenAmountCurrencyFactory; +use Adyen\Service\Checkout\PaymentsApi; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Quote\Api\Data\CartInterface; @@ -106,16 +108,15 @@ public function execute( "amount" => [ "value" => (float) $adyenAmountCurrency->getAmount(), "currency" => $currencyCode - ] + ], + "store" => $store->getId() ]; - $adyenClient = $this->adyenHelper->initializeAdyenClient( - $store->getId() - ); - $service = $this->adyenHelper->createAdyenCheckoutService($adyenClient); - $response = $service->paymentMethods( - $paymentMethodRequest, - $store - ); + $adyenClient = $this->adyenHelper->initializeAdyenClient($store->getId()); + $service = new PaymentsApi($adyenClient); + + $responseObj = $service->paymentMethods(new PaymentMethodsRequest($paymentMethodRequest)); + $response = (array)$responseObj->jsonSerialize(); + if (!$response) { return []; }