We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 8fc0d954 authored by alexandros's avatar alexandros Committed by attilak

Remove unused properties CheckoutDataBuilder.

parent 208c740f
...@@ -25,28 +25,29 @@ namespace Adyen\Payment\Gateway\Request; ...@@ -25,28 +25,29 @@ namespace Adyen\Payment\Gateway\Request;
use Magento\Payment\Gateway\Request\BuilderInterface; use Magento\Payment\Gateway\Request\BuilderInterface;
use Adyen\Payment\Observer\AdyenHppDataAssignObserver; use Adyen\Payment\Observer\AdyenHppDataAssignObserver;
use Adyen\Payment\Observer\AdyenBoletoDataAssignObserver;
class CheckoutDataBuilder implements BuilderInterface class CheckoutDataBuilder implements BuilderInterface
{ {
/** /**
* @var \Adyen\Payment\Helper\Data * @var \Adyen\Payment\Helper\Data
*/ */
private $adyenHelper; private $adyenHelper;
/** /**
* @var \Magento\Store\Model\StoreManagerInterface * @var \Magento\Store\Model\StoreManagerInterface
*/ */
private $storeManager; private $storeManager;
/** /**
* @var \Magento\Checkout\Model\Session * @var \Magento\Checkout\Model\Session
*/ */
private $checkoutSession; private $checkoutSession;
/** /**
* @var \Magento\Quote\Model\Quote * @var \Magento\Quote\Model\Quote
*/ */
private $quote; private $quote;
/** /**
* @var \Magento\Tax\Model\Config * @var \Magento\Tax\Model\Config
...@@ -88,17 +89,17 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -88,17 +89,17 @@ class CheckoutDataBuilder implements BuilderInterface
$order = $payment->getOrder(); $order = $payment->getOrder();
$request = []; $request = [];
// do not send email // do not send email
$order->setCanSendNewEmailFlag(false); $order->setCanSendNewEmailFlag(false);
$request['paymentMethod']['type'] = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE); $request['paymentMethod']['type'] = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE);
// Additional data for payment methods with issuer list // Additional data for payment methods with issuer list
if ($payment->getAdditionalInformation(AdyenHppDataAssignObserver::ISSUER_ID)) { if ($payment->getAdditionalInformation(AdyenHppDataAssignObserver::ISSUER_ID)) {
$request['paymentMethod']['issuer'] = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::ISSUER_ID); $request['paymentMethod']['issuer'] = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::ISSUER_ID);
} }
$request['returnUrl'] = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK) . 'adyen/process/result'; $request['returnUrl'] = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK) . 'adyen/process/result';
// Additional data for open invoice payment // Additional data for open invoice payment
if ($payment->getAdditionalInformation("gender")) { if ($payment->getAdditionalInformation("gender")) {
...@@ -108,8 +109,8 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -108,8 +109,8 @@ class CheckoutDataBuilder implements BuilderInterface
$request['paymentMethod']['personalDetails']['gender'] = $payment->getAdditionalInformation("gender"); $request['paymentMethod']['personalDetails']['gender'] = $payment->getAdditionalInformation("gender");
} }
if ($payment->getAdditionalInformation("dob")) { if ($payment->getAdditionalInformation("dob")) {
$order->setCustomerDob($payment->getAdditionalInformation("dob")); $order->setCustomerDob($payment->getAdditionalInformation("dob"));
$request['paymentMethod']['personalDetails']['dateOfBirth']= $this->adyenHelper->formatDate($payment->getAdditionalInformation("dob"), 'Y-m-d') ; $request['paymentMethod']['personalDetails']['dateOfBirth']= $this->adyenHelper->formatDate($payment->getAdditionalInformation("dob"), 'Y-m-d') ;
} }
...@@ -119,14 +120,14 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -119,14 +120,14 @@ class CheckoutDataBuilder implements BuilderInterface
$request['paymentMethod']['personalDetails']['telephoneNumber']= $payment->getAdditionalInformation("telephone"); $request['paymentMethod']['personalDetails']['telephoneNumber']= $payment->getAdditionalInformation("telephone");
} }
// Additional data for sepa direct debit // Additional data for sepa direct debit
if ($payment->getAdditionalInformation("ownerName")) { if ($payment->getAdditionalInformation("ownerName")) {
$request['paymentMethod']['sepa.ownerName']= $payment->getAdditionalInformation("ownerName"); $request['paymentMethod']['sepa.ownerName'] = $payment->getAdditionalInformation("ownerName");
} }
if ($payment->getAdditionalInformation("ibanNumber")) { if ($payment->getAdditionalInformation("ibanNumber")) {
$request['paymentMethod']['sepa.ibanNumber']= $payment->getAdditionalInformation("ibanNumber"); $request['paymentMethod']['sepa.ibanNumber'] = $payment->getAdditionalInformation("ibanNumber");
} }
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE) $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
...@@ -177,80 +178,81 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -177,80 +178,81 @@ class CheckoutDataBuilder implements BuilderInterface
); );
$request['deliveryDate'] = $deliveryDate; $request['deliveryDate'] = $deliveryDate;
}
$order->setCanSendNewEmailFlag(true);
}
return $request; return $request;
} }
/** /**
* @param $formFields * @param $formFields
* @return mixed * @return mixed
*/ */
protected function getOpenInvoiceData($order) protected function getOpenInvoiceData($order)
{ {
$formFields = [ $formFields = [
'lineItems' => [] 'lineItems' => []
]; ];
$currency = $this->quote->getCurrency(); $currency = $this->quote->getCurrency();
$discountAmount = 0; $discountAmount = 0;
foreach ($this->quote->getAllVisibleItems() as $item) { foreach ($this->quote->getAllVisibleItems() as $item) {
$numberOfItems = (int)$item->getQtyOrdered(); $numberOfItems = (int)$item->getQtyOrdered();
// Summarize the discount amount item by item // Summarize the discount amount item by item
$discountAmount += $item->getDiscountAmount(); $discountAmount += $item->getDiscountAmount();
$priceExcludingTax = $item->getPriceInclTax() - $item->getTaxAmount(); $priceExcludingTax = $item->getPriceInclTax() - $item->getTaxAmount();
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'amountExcludingTax' => $priceExcludingTax, 'amountExcludingTax' => $priceExcludingTax,
'taxAmount' => $item->getTaxAmount(), 'taxAmount' => $item->getTaxAmount(),
'description' => $item->getName(), 'description' => $item->getName(),
'id' => $item->getId(), 'id' => $item->getId(),
'quantity' => $item->getQty(), 'quantity' => $item->getQty(),
'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'), 'taxCategory' => $item->getProduct()->getAttributeText('tax_class_id'),
'taxPercentage' => $item->getTaxPercent() 'taxPercentage' => $item->getTaxPercent()
]; ];
} }
// Discount cost // Discount cost
if ($discountAmount != 0) { if ($discountAmount != 0) {
$description = __('Total Discount'); $description = __('Total Discount');
$itemAmount = $this->adyenHelper->formatAmount($discountAmount, $currency); $itemAmount = $this->adyenHelper->formatAmount($discountAmount, $currency);
$itemVatAmount = "0"; $itemVatAmount = "0";
$itemVatPercentage = "0"; $itemVatPercentage = "0";
$numberOfItems = 1; $numberOfItems = 1;
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'amountExcludingTax' => $itemAmount, 'amountExcludingTax' => $itemAmount,
'taxAmount' => $itemVatAmount, 'taxAmount' => $itemVatAmount,
'description' => $description, 'description' => $description,
'quantity' => $numberOfItems, 'quantity' => $numberOfItems,
'taxCategory' => 'None', 'taxCategory' => 'None',
'taxPercentage' => $itemVatPercentage 'taxPercentage' => $itemVatPercentage
]; ];
} }
// Shipping cost // Shipping cost
if ($this->quote->getShippingAddress()->getShippingAmount() > 0 || $this->quote->getShippingAddress()->getShippingTaxAmount() > 0) { if ($this->quote->getShippingAddress()->getShippingAmount() > 0 || $this->quote->getShippingAddress()->getShippingTaxAmount() > 0) {
$priceExcludingTax = $this->quote->getShippingAddress()->getShippingAmount() - $this->quote->getShippingAddress()->getShippingTaxAmount(); $priceExcludingTax = $this->quote->getShippingAddress()->getShippingAmount() - $this->quote->getShippingAddress()->getShippingTaxAmount();
$taxClassId = $this->taxConfig->getShippingTaxClass($this->storeManager->getStore()->getId()); $taxClassId = $this->taxConfig->getShippingTaxClass($this->storeManager->getStore()->getId());
$formFields['lineItems'][] = [ $formFields['lineItems'][] = [
'amountExcludingTax' => $priceExcludingTax, 'amountExcludingTax' => $priceExcludingTax,
'taxAmount' => $this->quote->getShippingAddress()->getShippingTaxAmount(), 'taxAmount' => $this->quote->getShippingAddress()->getShippingTaxAmount(),
'description' => $order->getShippingDescription(), 'description' => $order->getShippingDescription(),
'quantity' => 1, 'quantity' => 1,
'taxPercentage' => $this->quote->getShippingAddress()->getShippingTaxAmount() 'taxPercentage' => $this->quote->getShippingAddress()->getShippingTaxAmount()
]; ];
} }
return $formFields; return $formFields;
} }
} }
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