Skip to content

Commit

Permalink
[ECP-8891] Update the usage of isWalletPaymentMethod function (#2437)
Browse files Browse the repository at this point in the history
  • Loading branch information
candemiralp authored Jan 24, 2024
1 parent 0884073 commit cc88740
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions Helper/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\View\Asset\Repository;
Expand All @@ -29,7 +30,6 @@
use Magento\Payment\Helper\Data as MagentoDataHelper;
use Magento\Payment\Model\MethodInterface;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\Data\PaymentMethodInterface;
use Magento\Sales\Model\Order;
use Adyen\Payment\Helper\Data as AdyenDataHelper;
use Magento\Store\Model\ScopeInterface;
Expand Down Expand Up @@ -380,21 +380,6 @@ protected function addExtraConfigurationToPaymentMethods(
return $paymentMethodsExtraDetails;
}

public function isWalletTxVariant(string $notificationPaymentMethod): bool
{
$walletPaymentMethods = [
'googlepay',
'paywithgoogle',
'wechatpayWeb',
'amazonpay',
'applepay',
'wechatpayQR',
'alipay',
'alipay_hk'
];
return in_array($notificationPaymentMethod, $walletPaymentMethods);
}

public function isWalletPaymentMethod(MethodInterface $paymentMethodInstance): bool
{
return boolval($paymentMethodInstance->getConfigData('is_wallet'));
Expand Down Expand Up @@ -627,12 +612,18 @@ public function isAutoCapture(Order $order, string $notificationPaymentMethod):

public function compareOrderAndWebhookPaymentMethods(Order $order, Notification $notification): bool
{
// For cards, it can be 'VI', 'MI',... For alternatives, it can be 'ideal', 'directEbanking',...
$orderPaymentMethod = $order->getPayment()->getCcType();
$paymentMethodInstance = $order->getPayment()->getMethodInstance();

if ($this->isAlternativePaymentMethod($paymentMethodInstance)) {
$orderPaymentMethod = $this->getAlternativePaymentMethodTxVariant($paymentMethodInstance);
} else {
$orderPaymentMethod = $order->getPayment()->getCcType();
}

$notificationPaymentMethod = $notification->getPaymentMethod();

// Returns if the payment method is wallet like wechatpayWeb, amazonpay, applepay, paywithgoogle
$isWalletPaymentMethod = $this->isWalletTxVariant($orderPaymentMethod);
$isWalletPaymentMethod = $this->isWalletPaymentMethod($paymentMethodInstance);
$isCardPaymentMethod = $order->getPayment()->getMethod() === 'adyen_cc' || $order->getPayment()->getMethod() === 'adyen_oneclick';

// If it is a wallet method OR a card OR the methods match exactly, return true
Expand Down

0 comments on commit cc88740

Please sign in to comment.