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 dc96f655 authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

Merge pull request #441 from Adyen/develop

Release 4.0.3
parents ecd01eb1 5b82076d
...@@ -128,11 +128,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -128,11 +128,9 @@ class Redirect extends \Magento\Payment\Block\Form
if ($this->getPaymentMethodSelectionOnAdyen()) { if ($this->getPaymentMethodSelectionOnAdyen()) {
$url = 'https://test.adyen.com/hpp/select.shtml'; $url = 'https://test.adyen.com/hpp/select.shtml';
} else { } else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->_adyenHelper->doesPaymentMethodSkipDetails(
$this->_order->getPayment()->getAdditionalInformation('brand_code') $this->_order->getPayment()->getAdditionalInformation('brand_code')
) || $this->_adyenHelper->isPaymentMethodMolpayMethod( )
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)
) { ) {
$url = "https://test.adyen.com/hpp/skipDetails.shtml"; $url = "https://test.adyen.com/hpp/skipDetails.shtml";
} else { } else {
...@@ -148,11 +146,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -148,11 +146,9 @@ class Redirect extends \Magento\Payment\Block\Form
if ($this->getPaymentMethodSelectionOnAdyen()) { if ($this->getPaymentMethodSelectionOnAdyen()) {
$url = 'https://live.adyen.com/hpp/select.shtml'; $url = 'https://live.adyen.com/hpp/select.shtml';
} else { } else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->_adyenHelper->doesPaymentMethodSkipDetails(
$this->_order->getPayment()->getAdditionalInformation('brand_code') $this->_order->getPayment()->getAdditionalInformation('brand_code')
) || $this->_adyenHelper->isPaymentMethodMolpayMethod( )
$this->_order->getPayment()->getAdditionalInformation('brand_code')
)
) { ) {
$url = "https://live.adyen.com/hpp/skipDetails.shtml"; $url = "https://live.adyen.com/hpp/skipDetails.shtml";
} else { } else {
...@@ -335,16 +331,21 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -335,16 +331,21 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['shopper.lastName'] = trim($billingAddress->getLastname()); $formFields['shopper.lastName'] = trim($billingAddress->getLastname());
$formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone()); $formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone());
$street = $this->_adyenHelper->getStreet($billingAddress);
if (isset($street['name']) && $street['name'] != "") { if ($this->_adyenHelper->isSeparateHouseNumberRequired($billingAddress->getCountryId())) {
$formFields['billingAddress.street'] = $street['name']; $street = $this->_adyenHelper->getStreet($billingAddress);
}
if (isset($street['name']) && $street['name'] != "") {
$formFields['billingAddress.street'] = $street['name'];
}
if (isset($street['house_number']) && $street['house_number'] != "") { if (isset($street['house_number']) && $street['house_number'] != "") {
$formFields['billingAddress.houseNumberOrName'] = $street['house_number']; $formFields['billingAddress.houseNumberOrName'] = $street['house_number'];
} else {
$formFields['billingAddress.houseNumberOrName'] = "NA";
}
} else { } else {
$formFields['billingAddress.houseNumberOrName'] = "NA"; $formFields['billingAddress.street'] = implode(" ", $billingAddress->getStreet());
} }
if (trim($billingAddress->getCity()) == "") { if (trim($billingAddress->getCity()) == "") {
...@@ -384,18 +385,23 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -384,18 +385,23 @@ class Redirect extends \Magento\Payment\Block\Form
$shippingAddress = $this->_order->getShippingAddress(); $shippingAddress = $this->_order->getShippingAddress();
if ($shippingAddress) { if ($shippingAddress) {
$street = $this->_adyenHelper->getStreet($shippingAddress); if ($this->_adyenHelper->isSeparateHouseNumberRequired($shippingAddress->getCountryId())) {
$street = $this->_adyenHelper->getStreet($shippingAddress);
if (isset($street['name']) && $street['name'] != "") { if (isset($street['name']) && $street['name'] != "") {
$formFields['deliveryAddress.street'] = $street['name']; $formFields['deliveryAddress.street'] = $street['name'];
} }
if (isset($street['house_number']) && $street['house_number'] != "") { if (isset($street['house_number']) && $street['house_number'] != "") {
$formFields['deliveryAddress.houseNumberOrName'] = $street['house_number']; $formFields['deliveryAddress.houseNumberOrName'] = $street['house_number'];
} else {
$formFields['deliveryAddress.houseNumberOrName'] = "NA";
}
} else { } else {
$formFields['deliveryAddress.houseNumberOrName'] = "NA"; $formFields['deliveryAddress.street'] = implode(" ", $shippingAddress->getStreet());
} }
if (trim($shippingAddress->getCity()) == "") { if (trim($shippingAddress->getCity()) == "") {
$formFields['deliveryAddress.city'] = "NA"; $formFields['deliveryAddress.city'] = "NA";
} else { } else {
...@@ -420,6 +426,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -420,6 +426,7 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['deliveryAddress.country'] = trim($shippingAddress->getCountryId()); $formFields['deliveryAddress.country'] = trim($shippingAddress->getCountryId());
} }
} }
return $formFields; return $formFields;
} }
...@@ -433,6 +440,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -433,6 +440,7 @@ class Redirect extends \Magento\Payment\Block\Form
$currency = $this->_order->getOrderCurrencyCode(); $currency = $this->_order->getOrderCurrencyCode();
foreach ($this->_order->getAllVisibleItems() as $item) { foreach ($this->_order->getAllVisibleItems() as $item) {
/** @var $item \Magento\Sales\Model\Order\Item */
++$count; ++$count;
$numberOfItems = (int)$item->getQtyOrdered(); $numberOfItems = (int)$item->getQtyOrdered();
...@@ -446,7 +454,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -446,7 +454,8 @@ class Redirect extends \Magento\Payment\Block\Form
$item->getPriceInclTax(), $item->getPriceInclTax(),
$item->getTaxPercent(), $item->getTaxPercent(),
$numberOfItems, $numberOfItems,
$this->_order->getPayment() $this->_order->getPayment(),
$item->getId()
); );
} }
...@@ -469,7 +478,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -469,7 +478,8 @@ class Redirect extends \Magento\Payment\Block\Form
$itemVatAmount, $itemVatAmount,
$itemVatPercentage, $itemVatPercentage,
$numberOfItems, $numberOfItems,
$this->_order->getPayment() $this->_order->getPayment(),
"discount"
); );
} }
......
...@@ -115,7 +115,8 @@ class CaptureDataBuilder implements BuilderInterface ...@@ -115,7 +115,8 @@ class CaptureDataBuilder implements BuilderInterface
$invoiceItem->getPriceInclTax(), $invoiceItem->getPriceInclTax(),
$invoiceItem->getTaxPercent(), $invoiceItem->getTaxPercent(),
$numberOfItems, $numberOfItems,
$payment $payment,
$invoiceItem->getId()
); );
} }
......
...@@ -203,7 +203,8 @@ class RefundDataBuilder implements BuilderInterface ...@@ -203,7 +203,8 @@ class RefundDataBuilder implements BuilderInterface
$refundItem->getPriceInclTax(), $refundItem->getPriceInclTax(),
$refundItem->getTaxPercent(), $refundItem->getTaxPercent(),
$numberOfItems, $numberOfItems,
$payment $payment,
$refundItem->getId()
); );
} }
......
...@@ -70,7 +70,8 @@ class InstallmentValidator extends AbstractValidator ...@@ -70,7 +70,8 @@ class InstallmentValidator extends AbstractValidator
$fails = []; $fails = [];
$payment = $validationSubject['payment']; $payment = $validationSubject['payment'];
$quote = $this->session->getQuote(); $quote = $this->session->getQuote();
if ($quote) { $installmentsEnabled = $this->adyenHelper->getAdyenCcConfigData('enable_installments');
if ($quote && $installmentsEnabled) {
$grandTotal = $quote->getGrandTotal(); $grandTotal = $quote->getGrandTotal();
$installmentsAvailable = $this->adyenHelper->getAdyenCcConfigData('installments'); $installmentsAvailable = $this->adyenHelper->getAdyenCcConfigData('installments');
$installmentSelected = $payment->getAdditionalInformation('number_of_installments'); $installmentSelected = $payment->getAdditionalInformation('number_of_installments');
......
...@@ -1007,6 +1007,38 @@ class Data extends AbstractHelper ...@@ -1007,6 +1007,38 @@ class Data extends AbstractHelper
return false; return false;
} }
/**
* @param $paymentMethod
* @return bool
*/
public function isPaymentMethodOneyMethod($paymentMethod)
{
if (strpos($paymentMethod, 'facilypay_') !== false) {
return true;
}
return false;
}
/**
* @param $paymentMethod
* @return bool
*/
public function doesPaymentMethodSkipDetails($paymentMethod)
{
if ($this->isPaymentMethodOpenInvoiceMethod($paymentMethod) ||
$this->isPaymentMethodMolpayMethod($paymentMethod) ||
$this->isPaymentMethodOneyMethod($paymentMethod)
) {
return true;
}
return false;
}
/**
* @return mixed
*/
public function getRatePayId() public function getRatePayId()
{ {
return $this->getAdyenHppConfigData("ratepay_id"); return $this->getAdyenHppConfigData("ratepay_id");
...@@ -1099,6 +1131,7 @@ class Data extends AbstractHelper ...@@ -1099,6 +1131,7 @@ class Data extends AbstractHelper
* @param $taxPercent * @param $taxPercent
* @param $numberOfItems * @param $numberOfItems
* @param $payment * @param $payment
* @param null $itemId
* @return mixed * @return mixed
*/ */
public function createOpenInvoiceLineItem( public function createOpenInvoiceLineItem(
...@@ -1111,7 +1144,8 @@ class Data extends AbstractHelper ...@@ -1111,7 +1144,8 @@ class Data extends AbstractHelper
$priceInclTax, $priceInclTax,
$taxPercent, $taxPercent,
$numberOfItems, $numberOfItems,
$payment $payment,
$itemId = null
) { ) {
$description = str_replace("\n", '', trim($name)); $description = str_replace("\n", '', trim($name));
$itemAmount = $this->formatAmount($price, $currency); $itemAmount = $this->formatAmount($price, $currency);
...@@ -1135,7 +1169,8 @@ class Data extends AbstractHelper ...@@ -1135,7 +1169,8 @@ class Data extends AbstractHelper
$itemVatAmount, $itemVatAmount,
$itemVatPercentage, $itemVatPercentage,
$numberOfItems, $numberOfItems,
$payment $payment,
$itemId
); );
} }
...@@ -1187,7 +1222,8 @@ class Data extends AbstractHelper ...@@ -1187,7 +1222,8 @@ class Data extends AbstractHelper
$itemVatAmount, $itemVatAmount,
$itemVatPercentage, $itemVatPercentage,
$numberOfItems, $numberOfItems,
$payment $payment,
"shipping"
); );
} }
...@@ -1222,7 +1258,8 @@ class Data extends AbstractHelper ...@@ -1222,7 +1258,8 @@ class Data extends AbstractHelper
* @param $itemVatPercentage * @param $itemVatPercentage
* @param $numberOfItems * @param $numberOfItems
* @param $payment * @param $payment
* @return * @param null|int $itemId optional
* @return mixed
*/ */
public function getOpenInvoiceLineData( public function getOpenInvoiceLineData(
$formFields, $formFields,
...@@ -1233,9 +1270,16 @@ class Data extends AbstractHelper ...@@ -1233,9 +1270,16 @@ class Data extends AbstractHelper
$itemVatAmount, $itemVatAmount,
$itemVatPercentage, $itemVatPercentage,
$numberOfItems, $numberOfItems,
$payment $payment,
$itemId = null
) { ) {
$linename = "line" . $count; $linename = "line" . $count;
// item id is optional
if ($itemId) {
$formFields['openinvoicedata.' . $linename . '.itemId'] = $itemId;
}
$formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode; $formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode;
$formFields['openinvoicedata.' . $linename . '.description'] = $description; $formFields['openinvoicedata.' . $linename . '.description'] = $description;
$formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount; $formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount;
...@@ -1607,4 +1651,16 @@ class Data extends AbstractHelper ...@@ -1607,4 +1651,16 @@ class Data extends AbstractHelper
return $this->getAdyenCcVaultConfigDataFlag('active', $storeId); return $this->getAdyenCcVaultConfigDataFlag('active', $storeId);
} }
/**
* Checks if the house number needs to be sent to the Adyen API separately or as it is in the street field
*
* @param $country
* @return bool
*/
public function isSeparateHouseNumberRequired($country)
{
$countryList = ["nl", "de", "se", "no", "at", "fi", "dk"];
return in_array(strtolower($country), $countryList);
}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "4.0.2", "version": "4.0.3",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="4.0.2"> <module name="Adyen_Payment" setup_version="4.0.3">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
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