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

Merge pull request #602 from Adyen/develop

Release 5.1.0
parents 3590a809 f57578c5
......@@ -391,6 +391,18 @@ class Result extends \Magento\Framework\App\Action\Action
$request["details"] = $response;
if (!empty($this->_session->getLastRealOrder()) &&
!empty($this->_session->getLastRealOrder()->getPayment()) &&
!empty($this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation("details"))
) {
$details = $this->_session->getLastRealOrder()->getPayment()->getAdditionalInformation("details");
$key = array_search('returnUrlQueryString', $details[0]);
if ($key !== false) {
$request["details"] = array("returnUrlQueryString" => http_build_query($response));
}
}
try {
$response = $service->paymentsDetails($request);
} catch(\Adyen\AdyenException $e) {
......
......@@ -63,13 +63,37 @@ class CcAuthorizationDataBuilder implements BuilderInterface
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::HOLDER_NAME);
// if installments is set add it into the request
if ($payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) &&
$payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0
) {
$requestBody['installments']['value'] = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS);
// if installments is set and card type is credit card add it into the request
$numberOfInstallments = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) ?: 0;
$comboCardType = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::COMBO_CARD_TYPE) ?: 'credit';
if ($numberOfInstallments > 0) {
$requestBody['installments']['value'] = $numberOfInstallments;
}
// if card type is debit then change the issuer type and unset the installments field
if ($comboCardType == 'debit') {
if ($selectedDebitBrand = $this->getSelectedDebitBrand($payment->getAdditionalInformation('cc_type'))) {
$requestBody['additionalData']['overwriteBrand'] = true;
$requestBody['selectedBrand'] = $selectedDebitBrand;
$requestBody['paymentMethod']['type'] = $selectedDebitBrand;
}
unset($requestBody['installments']);
}
$request['body'] = $requestBody;
return $request;
}
/**
* @param string $brand
* @return string
*/
private function getSelectedDebitBrand($brand)
{
if ($brand == 'VI') {
return 'electron';
}
if ($brand == 'MC') {
return 'maestro';
}
return null;
}
}
\ No newline at end of file
......@@ -184,6 +184,9 @@ class CheckoutResponseValidator extends AbstractValidator
// Flag to show we are in the checkoutAPM flow
$payment->setAdditionalInformation('checkoutAPM', true);
if (!empty($response['details'])) {
$payment->setAdditionalInformation('details', $response['details']);
}
if ($redirectUrl && $paymentData && $redirectMethod) {
$payment->setAdditionalInformation('redirectUrl', $redirectUrl);
$payment->setAdditionalInformation('redirectMethod', $redirectMethod);
......
......@@ -1098,43 +1098,6 @@ class Data extends AbstractHelper
return false;
}
/**
* @return mixed
*/
/**
* @param $paymentMethod
* @return bool
*/
public function isPaymentMethodBcmcMobileQRMethod($paymentMethod)
{
if (strpos($paymentMethod, 'bcmc_mobile_QR') !== false) {
return true;
}
return false;
}
/**
* The payment method for wechat should be only wechatweb until we support the others too.
*
* @param $paymentMethod
* @return bool
*/
public function isPaymentMethodWechatpayExceptWeb($paymentMethod)
{
if (strpos($paymentMethod, 'wechatpay') !== false) {
if (strpos($paymentMethod, 'wechatpayWeb') !== false) {
return false;
}
return true;
}
return false;
}
public function getRatePayId()
{
return $this->getAdyenHppConfigData("ratepay_id");
......@@ -1156,18 +1119,6 @@ class Data extends AbstractHelper
return false;
}
/**
* @param $paymentMethod
* @return bool
*/
public function isPaymentMethodBoletoMethod($paymentMethod)
{
if (strpos($paymentMethod, 'boleto') !== false) {
return true;
}
return false;
}
/**
* @return bool
*/
......
......@@ -135,41 +135,7 @@ class PaymentMethods extends AbstractHelper
$quote = $this->quoteRepository->getActive($quoteId);
$store = $quote->getStore();
$paymentMethods = $this->addHppMethodsToConfig($store, $country);
return $paymentMethods;
}
/**
* @param $store
* @return array
*/
protected function addHppMethodsToConfig($store, $country)
{
$paymentMethods = [];
$ccEnabled = $this->config->getValue(
'payment/' . \Adyen\Payment\Model\Ui\AdyenCcConfigProvider::CODE . '/active',
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
$ccTypes = array_keys($this->adyenHelper->getCcTypesAltData());
foreach ($this->fetchAlternativeMethods($store, $country) as $methodCode => $methodData) {
/*
* skip payment methods if it is a creditcard that is enabled in adyen_cc or a boleto method or wechat but
* not wechatpay
*/
if (($ccEnabled && in_array($methodCode, $ccTypes)) ||
$this->adyenHelper->isPaymentMethodBoletoMethod($methodCode) ||
$this->adyenHelper->isPaymentMethodBcmcMobileQRMethod($methodCode) ||
$this->adyenHelper->isPaymentMethodWechatpayExceptWeb($methodCode)
) {
continue;
}
$paymentMethods[$methodCode] = $methodData;
}
$paymentMethods = $this->fetchAlternativeMethods($store, $country);
return $paymentMethods;
}
......@@ -215,10 +181,6 @@ class PaymentMethods extends AbstractHelper
if (isset($responseData['paymentMethods'])) {
foreach ($responseData['paymentMethods'] as $paymentMethod) {
if ($paymentMethod['type'] == "scheme") {
continue;
}
$paymentMethodCode = $paymentMethod['type'];
$paymentMethod = $this->fieldMapPaymentMethod($paymentMethod);
......
......@@ -188,7 +188,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
!isset($contractDetail['expiryDate']) ||
!isset($contractDetail['paymentMethod'])
) {
$this->_errors[] = __('"In the Additional data in API response section, select: Card summary, Expiry Date, Cardholder name, Recurring details and Variant to create billing agreements immediately after the payment is authorized."');
$this->_errors[] = __('"In the Additional data in API response section, select: Card bin, Card summary, Expiry Date, Cardholder name, Recurring details and Variant to create billing agreements immediately after the payment is authorized."');
return $this;
}
// Billing agreement is CC
......
......@@ -414,6 +414,10 @@ class Cron
if ($previousAdyenEventCode != "AUTHORISATION : TRUE" ||
$this->_eventCode == Notification::ORDER_CLOSED
) {
// Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled
if ($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW) {
$this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW);
}
$this->_holdCancelOrder(false);
} else {
$this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode);
......@@ -929,6 +933,12 @@ class Cron
break;
}
// Order is already Cancelled
if ($this->_order->isCanceled()){
$this->_adyenLogger->addAdyenNotificationCronjob("Order is already cancelled, skipping OFFER_CLOSED");
break;
}
/*
* For cards, it can be 'visa', 'maestro',...
* For alternatives, it can be 'ideal', 'directEbanking',...
......
......@@ -173,7 +173,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
}
/**
* Retrieve availables credit card types
* Retrieve available credit card types
*
* @return array
*/
......@@ -195,9 +195,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
}
/**
* Retrieve availables credit card type codes by alt code
* Retrieve available credit card type codes by alt code
*
* @param string $methodCode
* @return array
*/
protected function getCcAvailableTypesByAlt()
......@@ -293,3 +292,4 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
return $this->_request;
}
}
......@@ -47,6 +47,7 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
const TIMEZONE_OFFSET = 'timezone_offset';
const LANGUAGE = 'language';
const GUEST_EMAIL = 'guestEmail';
const COMBO_CARD_TYPE = 'combo_card_type';
/**
* @var array
......@@ -67,7 +68,8 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
self::SCREEN_HEIGHT,
self::TIMEZONE_OFFSET,
self::LANGUAGE,
self::GUEST_EMAIL
self::GUEST_EMAIL,
self::COMBO_CARD_TYPE
];
/**
......
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "5.0.2",
"version": "5.1.0",
"license": [
"OSL-3.0",
"AFL-3.0"
......
......@@ -64,7 +64,7 @@
</field>
<field id="sepa_flow" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Sepa Payment flow</label>
<tooltip>If you are not sure just leave it at 'Sale’. Sale means it is always immidiate capture with auth/cap it will follow the Capture Delay. If you want to enable 'Auth/Capt' for SEPA Direct Debit, please contact support@adyen.com</tooltip>
<tooltip>If you are not sure just leave it at 'Sale’. Sale means it is always immediate capture with auth/cap it will follow the Capture Delay. If you want to enable 'Auth/Capt' for SEPA Direct Debit, please contact support@adyen.com</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\SepaFlow</source_model>
<config_path>payment/adyen_abstract/sepa_flow</config_path>
</field>
......
......@@ -53,3 +53,6 @@
"Continue to Adyen App", "Continue to Adyen App"
"Do not use Installments", "Do not use Installments"
"(Please provide a card with the type from the list above)", "(Please provide a card with the type from the list above)"
"Select debit or credit card","Select debit or credit card"
"Credit","Credit"
"Debit","Debit"
\ No newline at end of file
......@@ -47,6 +47,7 @@ define(
return Component.extend({
// need to duplicate as without the button will never activate on first time page view
isPlaceOrderActionAllowed: ko.observable(quote.billingAddress() != null),
comboCardOption: ko.observable('credit'),
defaults: {
template: 'Adyen_Payment/payment/cc-form',
......@@ -294,7 +295,8 @@ define(
'screen_width': browserInfo.screenWidth,
'screen_height': browserInfo.screenHeight,
'timezone_offset': browserInfo.timeZoneOffset,
'language': browserInfo.language
'language': browserInfo.language,
'combo_card_type': this.comboCardOption()
}
};
this.vaultEnabler.visitAdditionalData(data);
......@@ -468,11 +470,19 @@ define(
: false
},
hasInstallments: function () {
return window.checkoutConfig.payment.adyenCc.hasInstallments;
return this.comboCardOption() === 'credit' && window.checkoutConfig.payment.adyenCc.hasInstallments;
},
getAllInstallments: function () {
return window.checkoutConfig.payment.adyenCc.installments;
},
areComboCardsEnabled: function () {
if (quote.billingAddress() === null) {
return false;
}
var countryId = quote.billingAddress().countryId;
var currencyCode = quote.totals().quote_currency_code;
return currencyCode === "BRL" && countryId === "BR";
},
setPlaceOrderHandler: function (handler) {
this.placeOrderHandler = handler;
},
......
......@@ -43,6 +43,7 @@ define(
var paymentMethod = ko.observable(null);
var messageComponents;
var shippingAddressCountryCode = quote.shippingAddress().countryId;
var unsupportedPaymentMethods = ['scheme', 'boleto', 'bcmc_mobile_QR', 'wechatpay'];
/**
* Shareble adyen checkout component
* @type {AdyenCheckout}
......@@ -70,7 +71,7 @@ define(
'bankLocationId'
]);
return this;
},initialize: function () {
}, initialize: function () {
var self = this;
this._super();
......@@ -88,8 +89,8 @@ define(
// reset variable:
adyenPaymentService.setPaymentMethods();
adyenPaymentService.retrieveAvailablePaymentMethods(function() {
let paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
adyenPaymentService.retrieveAvailablePaymentMethods(function () {
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
if (JSON.stringify(paymentMethods).indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
var dfValueRatePay = self.getRatePayDeviceIdentToken();
......@@ -133,7 +134,7 @@ define(
},
getAdyenHppPaymentMethods: function () {
var self = this;
let currentShippingAddressCountryCode = quote.shippingAddress().countryId;
var currentShippingAddressCountryCode = quote.shippingAddress().countryId;
// retrieve new payment methods if country code changed
if (shippingAddressCountryCode != currentShippingAddressCountryCode) {
......@@ -145,14 +146,19 @@ define(
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
var paymentList = _.map(paymentMethods, function (value) {
var paymentList = _.reduce(paymentMethods, function (accumulator, value) {
if (!self.isPaymentMethodSupported(value.type)) {
return accumulator;
}
var result = {};
/**
* Returns the payment method's brand code (in checkout api it is the type)
* @returns {*}
*/
result.getBrandCode = function() {
result.getBrandCode = function () {
return self.getBrandCodeFromPaymentMethod(value);
};
......@@ -180,7 +186,7 @@ define(
* @param bool
* @returns {*}
*/
result.isPlaceOrderAllowed = function(bool) {
result.isPlaceOrderAllowed = function (bool) {
self.isPlaceOrderActionAllowed(bool);
return result.placeOrderAllowed(bool);
};
......@@ -191,11 +197,11 @@ define(
* @param bool
* @returns {*}
*/
result.isPlaceOrderAllowed = function(bool) {
result.isPlaceOrderAllowed = function (bool) {
self.isPlaceOrderActionAllowed(bool);
return result.placeOrderAllowed(bool);
};
result.afterPlaceOrder = function() {
result.afterPlaceOrder = function () {
return self.afterPlaceOrder();
};
/**
......@@ -282,7 +288,7 @@ define(
result.findIssuersProperty = function () {
var issuerKey = false;
if (typeof value.details !== 'undefined') {
$.each(value.details, function(key, detail) {
$.each(value.details, function (key, detail) {
if (typeof detail.items !== 'undefined' && detail.key == 'issuer') {
issuerKey = key;
}
......@@ -317,7 +323,7 @@ define(
* Returns the issuers for a payment method
* @returns {*}
*/
result.getIssuers = function() {
result.getIssuers = function () {
if (result.hasIssuersAvailable()) {
return value.details[result.findIssuersProperty()].items;
}
......@@ -502,11 +508,31 @@ define(
result.bankLocationId = ko.observable(null);
}
return result;
});
accumulator.push(result);
return accumulator;
}, []);
return paymentList;
},
/**
* Some payment methods we do not want to render as it requires extra implementation
* or is already implemented in a separate payment method.
* Using a match as we want to prevent to render all Boleto and most of the WeChat types
* @param paymentMethod
* @returns {boolean}
*/
isPaymentMethodSupported: function (paymentMethod) {
if (paymentMethod == 'wechatpayWeb') {
return true;
}
for (var i = 0; i < unsupportedPaymentMethods.length; i++) {
var match = paymentMethod.match(unsupportedPaymentMethods[i]);
if (match) {
return false;
}
}
return true;
},
getGenderTypes: function () {
return _.map(window.checkoutConfig.payment.adyenHpp.genderTypes, function (value, key) {
return {
......@@ -575,13 +601,13 @@ define(
return true;
},
placeRedirectOrder: function(data) {
placeRedirectOrder: function (data) {
// Place Order but use our own redirect url after
var self = this;
fullScreenLoader.startLoader();
var messageContainer = this.messageContainer;
if(brandCode()) {
if (brandCode()) {
messageContainer = self.messageComponents['messages-' + brandCode()];
}
......@@ -599,7 +625,7 @@ define(
$("#messages-" + brandCode()).text(response['responseJSON'].message).slideDown();
}
setTimeout(function(){
setTimeout(function () {
$("#messages-" + brandCode()).slideUp();
}, 10000);
self.isPlaceOrderActionAllowed(true);
......@@ -632,7 +658,7 @@ define(
var form = '#payment_form_' + this.getCode() + '_' + brandCode;
var validate = $(form).validation() && $(form).validation('isValid');
if(!validate) {
if (!validate) {
return false;
}
......@@ -691,8 +717,8 @@ define(
* @param arr
* @returns {*}
*/
filterUndefinedItemsInArray: function(arr) {
return arr.filter(function(item){
filterUndefinedItemsInArray: function (arr) {
return arr.filter(function (item) {
return typeof item !== 'undefined';
});
}
......
......@@ -73,6 +73,24 @@
<br/>
<!-- /ko -->
<!-- ko if: (areComboCardsEnabled())-->
<div class="field required">
<label for="adyen-combo-card-select">
<!--ko text: $t('Select debit or credit card')--><!-- /ko -->
</label>
<div class="control">
<select id="adyen-combo-card-select"
class="select"
name="payment[combo_card_method]"
data-bind="value: comboCardOption"
>
<option value="credit"><!--ko text: $t('Credit Card')--><!-- /ko --></option>
<option value="debit"><!--ko text: $t('Debit Card')--><!-- /ko --></option>
</select>
</div>
</div>
<!-- /ko -->
<div class="field number cardContainerField">
<div class="checkout-component-dock" afterRender="renderSecureFields()" data-bind="attr: { id: 'cardContainer'}"></div>
</div>
......
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