Skip to content

Commit

Permalink
Fix payment methods retrieving when API key expires
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijaIv committed Nov 7, 2023
1 parent 0716e16 commit 3c0819c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/adyenofficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ public function hookPaymentOptions(array $params): array
if ($cart->id_address_delivery !== "0" && $cart->id_address_invoice !== "0" &&
$cart->id_carrier !== "0" && $storeService->checkStoreConnection($store)) {
$config = \AdyenPayment\Classes\Services\CheckoutHandler::getPaymentCheckoutConfig($params['cart']);

if (!$config->isSuccessful()) {
return [];
}

$availablePaymentMethods = \AdyenPayment\Classes\Services\CheckoutHandler::getAvailablePaymentMethods(
$config
);
Expand Down
5 changes: 3 additions & 2 deletions src/classes/Services/CheckoutHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace AdyenPayment\Classes\Services;

use Address as PrestaAddress;
use Adyen\Core\BusinessLogic\AdminAPI\Response\TranslatableErrorResponse;
use Adyen\Core\BusinessLogic\CheckoutAPI\CheckoutAPI;
use Adyen\Core\BusinessLogic\CheckoutAPI\CheckoutConfig\Request\PaymentCheckoutConfigRequest;
use Adyen\Core\BusinessLogic\CheckoutAPI\CheckoutConfig\Response\PaymentCheckoutConfigResponse;
Expand Down Expand Up @@ -35,13 +36,13 @@ class CheckoutHandler
/**
* @param PrestaCart $cart
*
* @return PaymentCheckoutConfigResponse
* @return PaymentCheckoutConfigResponse | TranslatableErrorResponse
*
* @throws InvalidCurrencyCode
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
public static function getPaymentCheckoutConfig(PrestaCart $cart): PaymentCheckoutConfigResponse
public static function getPaymentCheckoutConfig(PrestaCart $cart)
{
$currency = new PrestaCurrency($cart->id_currency);
$addressInvoice = new PrestaAddress($cart->id_address_invoice);
Expand Down

0 comments on commit 3c0819c

Please sign in to comment.