We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 84a7b6ff authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

PW-1784 Missing shopperInteraction for Recurring BA payments (#547)

parent 72ea16e7
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Gateway\Request;
use Adyen\Payment\Observer\AdyenOneclickDataAssignObserver;
use Magento\Payment\Gateway\Request\BuilderInterface;
class OneclickAuthorizationDataBuilder implements BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
/**
* CaptureDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public function __construct(\Adyen\Payment\Helper\Data $adyenHelper)
{
$this->adyenHelper = $adyenHelper;
}
/**
* @param array $buildSubject
* @return mixed
*/
public function build(array $buildSubject)
{
$request = [];
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment();
// If ccType is set use this. For bcmc you need bcmc otherwise it will fail
$request['paymentMethod']['type'] = "scheme";
if ($variant = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::VARIANT)) {
$request['paymentMethod']['type'] = $variant;
}
if ($securityCode = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::ENCRYPTED_SECURITY_CODE)) {
$request['paymentMethod']['encryptedSecurityCode'] = $securityCode;
}
$payment->unsAdditionalInformation(AdyenOneclickDataAssignObserver::ENCRYPTED_SECURITY_CODE);
if ($payment->getAdditionalInformation('customer_interaction')) {
$shopperInteraction = "Ecommerce";
} else {
$shopperInteraction = "ContAuth";
}
$request['shopperInteraction'] = $shopperInteraction;
$request['paymentMethod']['recurringDetailReference'] = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE);
// if it is a sepadirectdebit set selectedBrand to sepadirectdebit in the case of oneclick
if ($payment->getCcType() == "sepadirectdebit") {
$request['selectedBrand'] = "sepadirectdebit";
}
/*
* For recurring Ideal and Sofort needs to be converted to SEPA
* for this it is mandatory to set selectBrand to sepadirectdebit
*/
if (!$payment->getAdditionalInformation('customer_interaction')) {
if ($payment->getCcType() == "directEbanking" || $payment->getCcType() == "ideal") {
$request['selectedBrand'] = "sepadirectdebit";
}
}
// if installments is set add it into the request
if ($payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0) {
$request['installments']['value'] = $payment->getAdditionalInformation(AdyenOneclickDataAssignObserver::NUMBER_OF_INSTALLMENTS);
}
return $request;
}
}
......@@ -363,7 +363,7 @@ class Requests extends AbstractHelper
/**
* @param $request
* @param $payment
* @param $storeId
* @param $storeIdbuildCCData
* @return mixed
*/
public function buildCCData($request = [], $payload, $storeId, $areaCode)
......@@ -409,6 +409,15 @@ class Requests extends AbstractHelper
$request['paymentMethod']['recurringDetailReference'] = $recurringDetailReference;
}
// set customerInteraction
$recurringContractType = $this->adyenHelper->getAdyenOneclickConfigData('recurring_payment_type');
if (!empty($payload['method']) && $payload['method'] == 'adyen_oneclick'
&& $recurringContractType == \Adyen\Payment\Model\RecurringType::RECURRING) {
$request['shopperInteraction'] = "ContAuth";
} else {
$request['shopperInteraction'] = "Ecommerce";
}
/**
* if MOTO for backend is enabled use MOTO as shopper interaction type
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment