Skip to content

Commit

Permalink
[ECP-8788] Use default value for recurringProcessingModel if it's null
Browse files Browse the repository at this point in the history
  • Loading branch information
candemiralp committed Jan 16, 2024
1 parent eaa06ec commit ccf0a2d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Gateway/Request/RecurringVaultDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@

namespace Adyen\Payment\Gateway\Request;

use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\StateData;
use Adyen\Payment\Helper\Vault;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
use Adyen\Payment\Model\Ui\AdyenHppConfigProvider;
use Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider;
use Magento\Framework\Exception\LocalizedException;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Request\BuilderInterface;
Expand All @@ -26,18 +29,26 @@ class RecurringVaultDataBuilder implements BuilderInterface
*/
private $stateData;

public function __construct(StateData $stateData)
{
/**
* @var Config
*/
private $configHelper;

public function __construct(
StateData $stateData,
Config $configHelper
) {
$this->stateData = $stateData;
$this->configHelper = $configHelper;
}

/**
* @param array $buildSubject
* @return array
* @throws LocalizedException
*/
public function build(array $buildSubject)
{
$requestBody = [];
/** @var PaymentDataObject $paymentDataObject */
$paymentDataObject = SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
Expand All @@ -53,6 +64,15 @@ public function build(array $buildSubject)
// For now this will only be used by tokens created trough adyen_hpp payment methods
if (array_key_exists(Vault::TOKEN_TYPE, $details)) {
$requestBody['recurringProcessingModel'] = $details[Vault::TOKEN_TYPE];
} else if ($paymentMethod->getCode() === AdyenCcConfigProvider::CC_VAULT_CODE ||
$paymentMethod->getCode() === AdyenOneclickConfigProvider::CODE) {
$requestBody['recurringProcessingModel'] = $this->configHelper->getCardRecurringType(
$order->getStoreId()
);
} else if ($paymentMethod->getCode() === AdyenHppConfigProvider::class ) {
$requestBody['recurringProcessingModel'] = $this->configHelper->getAlternativePaymentMethodTokenType(
$order->getStoreId()
);
}

/*
Expand Down

0 comments on commit ccf0a2d

Please sign in to comment.