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 cb5c1e90 authored by Rik ter Beek's avatar Rik ter Beek

Fix recurring payments, added bcmc as type for card recognition and removed duplicate card list

parent 7f9add7a
......@@ -56,7 +56,7 @@ class CcType extends \Magento\Payment\Model\Source\Cctype
*/
public function getAllowedTypes()
{
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'MI', 'DN'];
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'UN', 'MI', 'DN', 'BCMC'];
}
/**
......
......@@ -61,5 +61,9 @@
<label>UnionPay</label>
<code_alt>cup</code_alt>
</type>
<type id="BCMC" order="80">
<label>Bancontact</label>
<code_alt>bcmc</code_alt>
</type>
</adyen_credit_cards>
</payment>
......@@ -68,7 +68,7 @@ define(
* sets up the callbacks for card components and
* set up the installments
*/
renderSecureFields: function() {
renderSecureFields: function () {
var self = this;
self.placeOrderAllowed(false);
......@@ -91,8 +91,15 @@ define(
holderNameRequired: true,
groupTypes: self.getAvailableCardTypeAltCodes(),
onChange: function(state) {
// what card is this ??
onChange: function (state) {
// isValid is not present on start
if (typeof state.isValid !== 'undefined' && state.isValid === false) {
self.creditCardDetailsValid(false);
self.placeOrderAllowed(false);
}
// Define the card type
// translate adyen card type to magento card type
var creditCardType = self.getCcCodeByAltCode(state.brand);
......@@ -132,12 +139,18 @@ define(
}
// Color the image of the credit card
// for BCMC as this is not a core payment method inside magento use maestro as brand detection
if (creditCardType == "BCMC") {
self.creditCardType("MI");
} else {
self.creditCardType(creditCardType);
}else{
}
} else {
self.creditCardType("")
}
},
onValid: function(state) {
onValid: function (state) {
self.variant(state.brand);
self.creditCardNumber(state.data.encryptedCardNumber);
self.expiryMonth(state.data.encryptedExpiryMonth);
......@@ -147,7 +160,7 @@ define(
self.creditCardDetailsValid(true);
self.placeOrderAllowed(true);
},
onError: function(state) {
onError: function (state) {
self.creditCardDetailsValid(false);
self.placeOrderAllowed(false);
}
......@@ -180,7 +193,7 @@ define(
* Returns state of place order button
* @returns {boolean}
*/
isButtonActive: function() {
isButtonActive: function () {
return this.isActive() && this.getCode() == this.isChecked() && this.isPlaceOrderActionAllowed() && this.placeOrderAllowed();
},
/**
......@@ -247,7 +260,7 @@ define(
*
* @returns {boolean}
*/
isCardOwnerValid: function() {
isCardOwnerValid: function () {
if (this.creditCardOwner().length == 0) {
return false;
}
......@@ -260,7 +273,7 @@ define(
*
* @returns {*}
*/
isCreditCardDetailsValid: function() {
isCreditCardDetailsValid: function () {
return this.creditCardDetailsValid();
},
/**
......@@ -269,7 +282,7 @@ define(
* @param altCode
* @returns {*}
*/
getCcCodeByAltCode: function(altCode) {
getCcCodeByAltCode: function (altCode) {
var ccTypes = window.checkoutConfig.payment.ccform.availableTypesByAlt[this.getCode()];
if (ccTypes.hasOwnProperty(altCode)) {
return ccTypes[altCode];
......@@ -283,7 +296,7 @@ define(
*
* @returns {string[]}
*/
getAvailableCardTypeAltCodes: function() {
getAvailableCardTypeAltCodes: function () {
var ccTypes = window.checkoutConfig.payment.ccform.availableTypesByAlt[this.getCode()];
return Object.keys(ccTypes);
},
......
......@@ -130,6 +130,15 @@ define(
var messageContainer = self.messageComponents['messages-' + value.reference_id];
// for recurring enable the placeOrder button at all times
var placeOrderAllowed = true;
if (self.hasVerification()) {
placeOrderAllowed = false;
} else {
// for recurring cards there is no validation needed
isValid(true);
}
return {
'label': value.agreement_label,
'value': value.reference_id,
......@@ -142,10 +151,10 @@ define(
'creditCardExpMonth': ko.observable(creditCardExpMonth),
'creditCardExpYear': ko.observable(creditCardExpYear),
'getInstallments': ko.observableArray(installments),
'placeOrderAllowed': ko.observable(false),
'placeOrderAllowed': ko.observable(placeOrderAllowed),
isButtonActive: function() {
isButtonActive: function () {
return self.isActive() && this.getCode() == self.isChecked() && self.isBillingAgreementChecked() && this.placeOrderAllowed();
},
/**
......@@ -208,7 +217,7 @@ define(
if (self.agreement_data.variant == "bcmc") {
hideCVC = true;
self.placeOrderAllowed(true);
} else if(self.agreement_data.variant == "maestro") {
} else if (self.agreement_data.variant == "maestro") {
// for maestro cvc is optional
self.placeOrderAllowed(true);
}
......@@ -239,7 +248,11 @@ define(
onChange: function (state) {
if (state.isValid) {
if (typeof state.data !== 'undefined' &&
typeof state.data.encryptedSecurityCode !== 'undefined'
) {
self.encryptedCreditCardVerificationNumber = state.data.encryptedSecurityCode;
}
} else {
self.encryptedCreditCardVerificationNumber = '';
}
......@@ -253,7 +266,7 @@ define(
}
return;
},
onError: function(data) {
onError: function (data) {
self.placeOrderAllowed(false);
isValid(false);
return;
......@@ -314,7 +327,7 @@ define(
return window.checkoutConfig.payment.adyenOneclick.checkoutUrl;
},
hasVerification: function () {
return window.checkoutConfig.payment.adyenOneclick.hasCustomerInteraction;
return self.hasVerification()
},
getMessageName: function () {
return 'messages-' + value.reference_id;
......@@ -407,6 +420,9 @@ define(
},
isShowLegend: function () {
return true;
},
hasVerification: function () {
return window.checkoutConfig.payment.adyenOneclick.hasCustomerInteraction;
}
});
}
......
......@@ -68,38 +68,6 @@
<br/>
<!-- /ko -->
<div class="field type">
<label data-bind="attr: {for: getCode() + '_cc_type'}" class="label">
<span><!-- ko text: $t('Credit Card Type')--><!-- /ko --></span>
</label>
<div class="control">
<ul class="credit-card-types">
<!-- ko foreach: {data: getCcAvailableTypesValues(), as: 'item'} -->
<li class="item" data-bind="css: {_active: $parent.creditCardType() == item.value} ">
<!--ko if: $parent.getIcons(item.value) -->
<img data-bind="attr: {
'src': $parent.getIcons(item.value).url,
'alt': item.type,
'width': $parent.getIcons(item.value).width,
'height': $parent.getIcons(item.value).height
}">
<!--/ko-->
</li>
<!--/ko-->
</ul>
<p class="helper-text" data-bind="css: {hidden: creditCardType() !== ''} ">
<!-- ko text: $t('(Please provide a card with the type from the list above)')-->
<!-- /ko --></p>
<input type="hidden"
name="payment[cc_type]"
class="input-text"
value=""
data-bind="attr: {id: getCode() + '_cc_type', 'data-container': getCode() + '-cc-type'},
value: creditCardType
">
</div>
</div>
<div class="field number cardContainerField">
<div 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