Esempio n. 1
1
 /**
  * @param array $commandSubject
  * @return $this
  */
 public function execute(array $commandSubject)
 {
     $stateObject = \Magento\Payment\Gateway\Helper\SubjectReader::readStateObject($commandSubject);
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($commandSubject);
     $payment = $payment->getPayment();
     // do not let magento set status to processing
     $payment->setIsTransactionPending(true);
     // generateUrl
     $payment->setAdditionalInformation('payment_url', $this->_generatePaymentUrl($payment));
     // update status and state
     $stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
     $stateObject->setStatus($this->_adyenHelper->getAdyenAbstractConfigData('order_status'));
     $stateObject->setIsNotified(false);
     return $this;
 }
 /**
  * @param array $handlingSubject
  * @param array $response
  * @return $this
  */
 public function handle(array $handlingSubject, array $response)
 {
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
     /** @var OrderPaymentInterface $payment */
     $payment = $payment->getPayment();
     if (isset($response['resultCode'])) {
         $responseCode = $response['resultCode'];
     } else {
         // try to get response from response key (used for modifications
         if (isset($response['response'])) {
             $responseCode = $response['response'];
         } else {
             $responseCode = "";
         }
     }
     if (isset($response['pspReference'])) {
         $pspReference = $response['pspReference'];
     } else {
         $pspReference = "";
     }
     $type = 'Adyen Result response:';
     $comment = __('%1 <br /> authResult: %2 <br /> pspReference: %3 ', $type, $responseCode, $pspReference);
     if ($responseCode) {
         $payment->getOrder()->setAdyenResulturlEventCode($responseCode);
     }
     $payment->getOrder()->addStatusHistoryComment($comment);
     return $this;
 }
 /**
  * @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();
     $recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");
     if ($payment->getAdditionalInformation('customer_interaction')) {
         $shopperInteraction = "Ecommerce";
     } else {
         $shopperInteraction = "ContAuth";
     }
     $request['selectedRecurringDetailReference'] = $recurringDetailReference;
     $request['shopperInteraction'] = $shopperInteraction;
     // 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";
         }
     }
     return $request;
 }
 /**
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $order = $paymentDataObject->getOrder();
     return ['shopperIP' => $order->getRemoteIp()];
 }
 /**
  * Add delivery\billing details into request
  * 
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $order = $paymentDataObject->getOrder();
     $result = [];
     $billingAddress = $order->getBillingAddress();
     if ($billingAddress) {
         // filter housenumber from streetLine1
         $requestBilling = ["street" => $billingAddress->getStreetLine1(), "postalCode" => $billingAddress->getPostcode(), "city" => $billingAddress->getCity(), "houseNumberOrName" => 'NA', "stateOrProvince" => $billingAddress->getRegionCode(), "country" => $billingAddress->getCountryId()];
         // houseNumberOrName is mandatory
         if ($requestBilling['houseNumberOrName'] == "") {
             $requestBilling['houseNumberOrName'] = "NA";
         }
         $result['billingAddress'] = $requestBilling;
     }
     $shippingAddress = $order->getShippingAddress();
     if ($shippingAddress) {
         // filter housenumber from streetLine1
         $requestDelivery = ["street" => $shippingAddress->getStreetLine1(), "postalCode" => $shippingAddress->getPostcode(), "city" => $shippingAddress->getCity(), "houseNumberOrName" => 'NA', "stateOrProvince" => $shippingAddress->getRegionCode(), "country" => $shippingAddress->getCountryId()];
         // houseNumberOrName is mandatory
         if ($requestDelivery['houseNumberOrName'] == "") {
             $requestDelivery['houseNumberOrName'] = "NA";
         }
         $result['deliveryAddress'] = $requestDelivery;
     }
     return $result;
 }
 /**
  * @param array $buildSubject
  * @return mixed
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $payment = $paymentDataObject->getPayment();
     $order = $paymentDataObject->getOrder();
     $storeId = $order->getStoreId();
     $request = [];
     if ($this->adyenHelper->getAdyenCcConfigDataFlag('cse_enabled', $storeId)) {
         $request['additionalData']['card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data");
     } else {
         $requestCreditCardDetails = ["expiryMonth" => $payment->getCcExpMonth(), "expiryYear" => $payment->getCcExpYear(), "holderName" => $payment->getCcOwner(), "number" => $payment->getCcNumber(), "cvc" => $payment->getCcCid()];
         $cardDetails['card'] = $requestCreditCardDetails;
         $request = array_merge($request, $cardDetails);
     }
     /**
      * if MOTO for backend is enabled use MOTO as shopper interaction type
      */
     $enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
     if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE && $enableMoto) {
         $request['shopperInteraction'] = "Moto";
     }
     // if installments is set add it into the request
     if ($payment->getAdditionalInformation('number_of_installments') && $payment->getAdditionalInformation('number_of_installments') > 0) {
         $request['installments']['value'] = $payment->getAdditionalInformation('number_of_installments');
     }
     return $request;
 }
 /**
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $order = $paymentDataObject->getOrder();
     $storeId = $order->getStoreId();
     $merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
     return ["merchantAccount" => $merchantAccount];
 }
 /**
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $payment = $paymentDataObject->getPayment();
     $md = $payment->getAdditionalInformation('md');
     $paResponse = $payment->getAdditionalInformation('paResponse');
     return ["md" => $md, "paResponse" => $paResponse];
 }
Esempio n. 9
0
 /**
  * Create cancel_or_refund request
  * 
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $order = $paymentDataObject->getOrder();
     $payment = $paymentDataObject->getPayment();
     $pspReference = $payment->getCcTransId();
     return ["reference" => $order->getOrderIncrementId(), "originalReference" => $pspReference];
 }
 /**
  * @param array $handlingSubject
  * @param array $response
  */
 public function handle(array $handlingSubject, array $response)
 {
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
     /** @var OrderPaymentInterface $payment */
     $payment = $payment->getPayment();
     // set pspReference as lastTransId only!
     $payment->setLastTransId($response['pspReference']);
     // close transaction because you have cancelled the transaction
     $payment->setIsTransactionClosed(true);
     $payment->setShouldCloseParentTransaction(true);
 }
Esempio n. 11
0
 /**
  * Add shopper data into request
  * 
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $order = $paymentDataObject->getOrder();
     $billingAddress = $order->getBillingAddress();
     $customerEmail = $billingAddress->getEmail();
     $realOrderId = $order->getOrderIncrementId();
     $customerId = $order->getCustomerId();
     $shopperReference = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId;
     return ["shopperEmail" => $customerEmail, "shopperReference" => $shopperReference];
 }
Esempio n. 12
0
 /**
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $order = $paymentDataObject->getOrder();
     $payment = $paymentDataObject->getPayment();
     $fullOrder = $payment->getOrder();
     $currencyCode = $fullOrder->getOrderCurrencyCode();
     $amount = $fullOrder->getGrandTotal();
     $amount = ['currency' => $currencyCode, 'value' => $this->adyenHelper->formatAmount($amount, $currencyCode)];
     return ["amount" => $amount, "reference" => $order->getOrderIncrementId(), "fraudOffset" => "0"];
 }
Esempio n. 13
0
 /**
  * Create capture request
  * 
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject);
     $payment = $paymentDataObject->getPayment();
     $pspReference = $payment->getCcTransId();
     $currency = $payment->getOrder()->getOrderCurrencyCode();
     //format the amount to minor units
     $amount = $this->adyenHelper->formatAmount($amount, $currency);
     $modificationAmount = ['currency' => $currency, 'value' => $amount];
     return ["modificationAmount" => $modificationAmount, "reference" => $payment->getOrder()->getIncrementId(), "originalReference" => $pspReference];
 }
Esempio n. 14
0
 /**
  * @param array $commandSubject
  * @return $this
  */
 public function execute(array $commandSubject)
 {
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($commandSubject);
     $stateObject = \Magento\Payment\Gateway\Helper\SubjectReader::readStateObject($commandSubject);
     // do not send email
     $payment = $payment->getPayment();
     $payment->getOrder()->setCanSendNewEmailFlag(false);
     // update status and state
     $stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
     $stateObject->setStatus($this->_adyenHelper->getAdyenAbstractConfigData('order_status'));
     $stateObject->setIsNotified(false);
     return $this;
 }
 /**
  * @param array $buildSubject
  * @return mixed
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $payment = $paymentDataObject->getPayment();
     $request = [];
     // set brand to sepa
     $request['selectedBrand'] = "sepadirectdebit";
     // add bankDetails into request
     $bankAccount = ['iban' => $payment->getAdditionalInformation("iban"), 'ownerName' => $payment->getAdditionalInformation("account_name"), 'countryCode' => $payment->getAdditionalInformation("country")];
     $request['bankAccount'] = $bankAccount;
     return $request;
 }
 /**
  * @param array $handlingSubject
  * @param array $response
  */
 public function handle(array $handlingSubject, array $response)
 {
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
     /** @var OrderPaymentInterface $payment */
     $payment = $payment->getPayment();
     // set pspReference as lastTransId only!
     $payment->setLastTransId($response['pspReference']);
     /**
      * close current transaction because you have capture the goods
      * but do not close the authorisation becasue you can still cancel/refund order
      */
     $payment->setIsTransactionClosed(true);
     $payment->setShouldCloseParentTransaction(false);
 }
 /**
  * @param array $handlingSubject
  * @param array $response
  */
 public function handle(array $handlingSubject, array $response)
 {
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
     /** @var OrderPaymentInterface $payment */
     $payment = $payment->getPayment();
     foreach ($response as $singleResponse) {
         // set pspReference as lastTransId only!
         $payment->setLastTransId($singleResponse['pspReference']);
     }
     /**
      * close current transaction because you have refunded the goods
      * but only on full refund close the authorisation
      */
     $payment->setIsTransactionClosed(true);
     $closeParent = !(bool) $payment->getCreditmemo()->getInvoice()->canRefund();
     $payment->setShouldCloseParentTransaction($closeParent);
 }
 /**
  * @param array $handlingSubject
  * @param array $response
  */
 public function handle(array $handlingSubject, array $response)
 {
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
     /** @var OrderPaymentInterface $payment */
     $payment = $payment->getPayment();
     // set transaction not to processing by default wait for notification
     $payment->setIsTransactionPending(true);
     // no not send order confirmation mail
     $payment->getOrder()->setCanSendNewEmailFlag(false);
     // set pspReference as transactionId
     $payment->setCcTransId($response['pspReference']);
     $payment->setLastTransId($response['pspReference']);
     // set transaction
     $payment->setTransactionId($response['pspReference']);
     // do not close transaction so you can do a cancel() and void
     $payment->setIsTransactionClosed(false);
     $payment->setShouldCloseParentTransaction(false);
 }
 /**
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     $result = [];
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $payment = $paymentDataObject->getPayment();
     // Needs to change when oneclick,cc using facade impl.
     $paymentMethodCode = $payment->getMethodInstance()->getCode();
     $storeId = null;
     if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
         $storeId = $payment->getOrder()->getStoreId();
     }
     $recurringType = $this->adyenHelper->getAdyenAbstractConfigData('recurring_type', $storeId);
     // set the recurring type
     $recurringContractType = null;
     if ($recurringType) {
         if ($paymentMethodCode == \Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider::CODE) {
             /*
              * For ONECLICK look at the recurringPaymentType that the merchant
              * has selected in Adyen ONECLICK settings
              */
             if ($payment->getAdditionalInformation('customer_interaction')) {
                 $recurringContractType = \Adyen\Payment\Model\RecurringType::ONECLICK;
             } else {
                 $recurringContractType = \Adyen\Payment\Model\RecurringType::RECURRING;
             }
         } else {
             if ($paymentMethodCode == \Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CODE) {
                 if ($payment->getAdditionalInformation("store_cc") == "" && ($recurringType == "ONECLICK,RECURRING" || $recurringType == "RECURRING")) {
                     $recurringContractType = \Adyen\Payment\Model\RecurringType::RECURRING;
                 } elseif ($payment->getAdditionalInformation("store_cc") == "1") {
                     $recurringContractType = $recurringType;
                 }
             } else {
                 $recurringContractType = $recurringType;
             }
         }
     }
     if ($recurringContractType) {
         $recurring = ['contract' => $recurringContractType];
         $result['recurring'] = $recurring;
     }
     return $result;
 }
 /**
  * @param array $buildSubject
  * @return mixed
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $payment = $paymentDataObject->getPayment();
     $order = $paymentDataObject->getOrder();
     $storeId = $order->getStoreId();
     $request = [];
     $request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number");
     $request['selectedBrand'] = $payment->getAdditionalInformation("boleto_type");
     $shopperName = ['firstName' => $payment->getAdditionalInformation("firstname"), 'lastName' => $payment->getAdditionalInformation("lastname")];
     $request['shopperName'] = $shopperName;
     $deliveryDays = (int) $this->adyenHelper->getAdyenBoletoConfigData("delivery_days", $storeId);
     $deliveryDays = !empty($deliveryDays) ? $deliveryDays : 5;
     $deliveryDate = date("Y-m-d\\TH:i:s ", mktime(date("H"), date("i"), date("s"), date("m"), date("j") + $deliveryDays, date("Y")));
     $request['deliveryDate'] = $deliveryDate;
     return $request;
 }
Esempio n. 21
0
 /**
  * @param array $commandSubject
  * @return $this
  */
 public function execute(array $commandSubject)
 {
     $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($commandSubject);
     $stateObject = \Magento\Payment\Gateway\Helper\SubjectReader::readStateObject($commandSubject);
     // do not send email
     $payment = $payment->getPayment();
     $order = $payment->getOrder();
     $order->setCanSendNewEmailFlag(false);
     // update customer based on additionalFields
     if ($payment->getAdditionalInformation("gender")) {
         $order->setCustomerGender(\Adyen\Payment\Model\Gender::getMagentoGenderFromAdyenGender($payment->getAdditionalInformation("gender")));
     }
     if ($payment->getAdditionalInformation("dob")) {
         $order->setCustomerDob($payment->getAdditionalInformation("dob"));
     }
     if ($payment->getAdditionalInformation("telephone")) {
         $order->getBillingAddress()->setTelephone($payment->getAdditionalInformation("telephone"));
     }
     // update status and state
     $stateObject->setState(\Magento\Sales\Model\Order::STATE_NEW);
     $stateObject->setStatus($this->_adyenHelper->getAdyenAbstractConfigData('order_status'));
     $stateObject->setIsNotified(false);
     return $this;
 }
Esempio n. 22
0
 /**
  * @param array $buildSubject
  * @return array
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject);
     $order = $paymentDataObject->getOrder();
     $payment = $paymentDataObject->getPayment();
     $pspReference = $payment->getCcTransId();
     $currency = $payment->getOrder()->getOrderCurrencyCode();
     $storeId = $order->getStoreId();
     $merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
     $grandTotal = $payment->getOrder()->getGrandTotal();
     // check if it contains a split payment
     $orderPaymentCollection = $this->orderPaymentCollectionFactory->create()->addFieldToFilter('payment_id', $payment->getId());
     // partial refund if multiple payments check refund strategy
     if ($orderPaymentCollection->getSize() > 1) {
         $refundStrategy = $this->adyenHelper->getAdyenAbstractConfigData('split_payments_refund_strategy', $order->getStoreId());
         $ratio = null;
         if ($refundStrategy == "1") {
             // Refund in ascending order
             $orderPaymentCollection->addPaymentFilterAscending($payment->getId());
         } elseif ($refundStrategy == "2") {
             // Refund in descending order
             $orderPaymentCollection->addPaymentFilterDescending($payment->getId());
         } elseif ($refundStrategy == "3") {
             // refund based on ratio
             $ratio = $amount / $grandTotal;
             $orderPaymentCollection->addPaymentFilterAscending($payment->getId());
         }
         // loop over payment methods and refund them all
         $result = [];
         foreach ($orderPaymentCollection as $splitPayment) {
             // could be that not all the split payments need a refund
             if ($amount > 0) {
                 if ($ratio) {
                     // refund based on ratio calculate refund amount
                     $modificationAmount = $ratio * ($splitPayment->getAmount() - $splitPayment->getTotalRefunded());
                 } else {
                     // total authorised amount of the split payment
                     $splitPaymentAmount = $splitPayment->getAmount() - $splitPayment->getTotalRefunded();
                     // if rest amount is zero go to next payment
                     if (!$splitPaymentAmount > 0) {
                         continue;
                     }
                     // if refunded amount is greather then split payment amount do a full refund
                     if ($amount >= $splitPaymentAmount) {
                         $modificationAmount = $splitPaymentAmount;
                     } else {
                         $modificationAmount = $amount;
                     }
                     // update amount with rest of the available amount
                     $amount = $amount - $splitPaymentAmount;
                 }
                 $modificationAmountObject = ['currency' => $currency, 'value' => $this->adyenHelper->formatAmount($modificationAmount, $currency)];
                 $result[] = ["modificationAmount" => $modificationAmountObject, "reference" => $payment->getOrder()->getIncrementId(), "originalReference" => $splitPayment->getPspreference(), "merchantAccount" => $merchantAccount];
             }
         }
     } else {
         //format the amount to minor units
         $amount = $this->adyenHelper->formatAmount($amount, $currency);
         $modificationAmount = ['currency' => $currency, 'value' => $amount];
         $result = [["modificationAmount" => $modificationAmount, "reference" => $payment->getOrder()->getIncrementId(), "originalReference" => $pspReference, "merchantAccount" => $merchantAccount]];
     }
     return $result;
 }
Esempio n. 23
0
 /**
  * Reads payment from subject
  *
  * @param array $subject
  * @return PaymentDataObjectInterface
  */
 public function readPayment(array $subject)
 {
     return Helper\SubjectReader::readPayment($subject);
 }
 /**
  * @param array $validationSubject
  * @return \Magento\Payment\Gateway\Validator\ResultInterface
  */
 public function validate(array $validationSubject)
 {
     $response = \Magento\Payment\Gateway\Helper\SubjectReader::readResponse($validationSubject);
     $paymentDataObjectInterface = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($validationSubject);
     $payment = $paymentDataObjectInterface->getPayment();
     $payment->setAdditionalInformation('3dActive', false);
     $isValid = true;
     $errorMessages = [];
     // validate result
     if ($response && isset($response['resultCode'])) {
         switch ($response['resultCode']) {
             case "Authorised":
                 $payment->setAdditionalInformation('pspReference', $response['pspReference']);
                 break;
             case "Received":
                 $payment->setAdditionalInformation('pspReference', $response['pspReference']);
                 // set additionalData
                 if (isset($response['additionalData']) && is_array($response['additionalData'])) {
                     $additionalData = $response['additionalData'];
                     if (isset($additionalData['boletobancario.dueDate'])) {
                         $payment->setAdditionalInformation('dueDate', $additionalData['boletobancario.dueDate']);
                     }
                     if (isset($additionalData['boletobancario.expirationDate'])) {
                         $payment->setAdditionalInformation('expirationDate', $additionalData['boletobancario.expirationDate']);
                     }
                     if (isset($additionalData['boletobancario.url'])) {
                         $payment->setAdditionalInformation('url', $additionalData['boletobancario.url']);
                     }
                 }
                 break;
             case "RedirectShopper":
                 $payment->setAdditionalInformation('3dActive', true);
                 $payment->setAdditionalInformation('pspReference', $response['pspReference']);
                 $issuerUrl = $response['issuerUrl'];
                 $paReq = $response['paRequest'];
                 $md = $response['md'];
                 if (!empty($paReq) && !empty($md) && !empty($issuerUrl)) {
                     $payment->setAdditionalInformation('issuerUrl', $response['issuerUrl']);
                     $payment->setAdditionalInformation('paRequest', $response['paRequest']);
                     $payment->setAdditionalInformation('md', $response['md']);
                 } else {
                     $isValid = false;
                     $errorMsg = __('3D secure is not valid.');
                     $this->adyenLogger->error($errorMsg);
                     $errorMessages[] = $errorMsg;
                 }
                 break;
             case "Refused":
                 if ($response['refusalReason']) {
                     $refusalReason = $response['refusalReason'];
                     switch ($refusalReason) {
                         case "Transaction Not Permitted":
                             $errorMsg = __('The transaction is not permitted.');
                             break;
                         case "CVC Declined":
                             $errorMsg = __('Declined due to the Card Security Code(CVC) being incorrect. Please check your CVC code!');
                             break;
                         case "Restricted Card":
                             $errorMsg = __('The card is restricted.');
                             break;
                         case "803 PaymentDetail not found":
                             $errorMsg = __('The payment is REFUSED because the saved card is removed. Please try an other payment method.');
                             break;
                         case "Expiry month not set":
                             $errorMsg = __('The expiry month is not set. Please check your expiry month!');
                             break;
                         default:
                             $errorMsg = __('The payment is REFUSED.');
                             break;
                     }
                 } else {
                     $errorMsg = __('The payment is REFUSED.');
                 }
                 // this will result the specific error
                 throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
                 break;
             default:
                 $errorMsg = __('Error with payment method please select different payment method.');
                 throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
                 break;
         }
     } else {
         $errorMsg = __('Error with payment method please select different payment method.');
         throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
     }
     return $this->createResult($isValid, $errorMessages);
 }