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 331edac8 authored by Bas Maassen's avatar Bas Maassen Committed by GitHub

Merge pull request #224 from Adyen/PW-261

PW-261 Removed the detailed refusal reasons, added frontend CVC validation. 
parents c8bf0c44 d459a91b
...@@ -114,31 +114,7 @@ class GeneralResponseValidator extends AbstractValidator ...@@ -114,31 +114,7 @@ class GeneralResponseValidator extends AbstractValidator
} }
break; break;
case "Refused": case "Refused":
if ($response['refusalReason']) { $errorMsg = __('The payment is REFUSED.');
$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 // this will result the specific error
throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg)); throw new \Magento\Framework\Exception\LocalizedException(__($errorMsg));
break; break;
......
...@@ -39,6 +39,8 @@ define( ...@@ -39,6 +39,8 @@ define(
function (_, $, Component, placeOrderAction, $t, additionalValidators, customer, creditCardData, quote, ko, installments, adyenEncrypt) { function (_, $, Component, placeOrderAction, $t, additionalValidators, customer, creditCardData, quote, ko, installments, adyenEncrypt) {
'use strict'; 'use strict';
var cvcLength = ko.observable(4);
return Component.extend({ return Component.extend({
defaults: { defaults: {
template: 'Adyen_Payment/payment/cc-form', template: 'Adyen_Payment/payment/cc-form',
...@@ -79,9 +81,11 @@ define( ...@@ -79,9 +81,11 @@ define(
// what card is this ?? // what card is this ??
var creditcardType = creditCardData.creditCard.type; var creditcardType = creditCardData.creditCard.type;
if(creditcardType) { if(creditcardType) {
cvcLength(4);
if (creditcardType != "AE"){
cvcLength(3);
}
if (creditcardType in allInstallments) { if (creditcardType in allInstallments) {
// get for the creditcard the installments // get for the creditcard the installments
var installmentCreditcard = allInstallments[creditcardType]; var installmentCreditcard = allInstallments[creditcardType];
...@@ -125,6 +129,9 @@ define( ...@@ -125,6 +129,9 @@ define(
} }
}; };
}, },
getCvcLength: function() {
return cvcLength();
},
isActive: function() { isActive: function() {
return true; return true;
}, },
......
...@@ -178,13 +178,18 @@ ...@@ -178,13 +178,18 @@
class="input-text cvv" class="input-text cvv"
data-encrypted-name="cvc" data-encrypted-name="cvc"
value="" value=""
data-bind="attr: {id: getCode() + '_cc_cid', data-bind="attr: {
id: getCode() + '_cc_cid',
title: $t('Card Verification Number'), title: $t('Card Verification Number'),
'data-container': getCode() + '-cc-cvv', 'data-container': getCode() + '-cc-cvv',
'data-validate': JSON.stringify({'required-number':true, 'validate-card-cvv':'#' + getCode() + '_cc_type'})}, 'data-validate': JSON.stringify({'required-number':true, 'validate-card-cvv':'#' + getCode() + '_cc_type'}),
maxLength : getCvcLength(),
oninput:'javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);'
},
enable: isActive($parents), enable: isActive($parents),
value: creditCardVerificationNumber" value: creditCardVerificationNumber",
data-validate="{required:true}"/> data-validate="{required:true}"
/>
<div class="field-tooltip toggle"> <div class="field-tooltip toggle">
<span class="field-tooltip-action action-cvv" <span class="field-tooltip-action action-cvv"
tabindex="0" tabindex="0"
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<!-- ko if: isPaymentMethodOpenInvoiceMethod() --> <!-- ko if: isPaymentMethodOpenInvoiceMethod() -->
<!-- ko if: showGender() --> <!-- ko if: showGender() -->
<div class="field gender_type type required"> <div class="field gender type required">
<label data-bind="attr: {for: getCode() + '_gender_type'}" class="label"> <label data-bind="attr: {for: getCode() + '_gender_type'}" class="label">
<span><!-- ko text: $t('Gender')--><!-- /ko --></span> <span><!-- ko text: $t('Gender')--><!-- /ko --></span>
</label> </label>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<!--/ko--> <!--/ko-->
<!-- ko if: showDob() --> <!-- ko if: showDob() -->
<div class="field required"> <div class="field dob type required">
<label data-bind="attr: {for: getCode() + '_dob'}" class="label"> <label data-bind="attr: {for: getCode() + '_dob'}" class="label">
<span><!-- ko text: $t('Date of Birth')--><!-- /ko --></span> <span><!-- ko text: $t('Date of Birth')--><!-- /ko --></span>
</label> </label>
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<!--/ko--> <!--/ko-->
<!-- ko if: showTelephone() --> <!-- ko if: showTelephone() -->
<div class="field required"> <div class="field telephone type required">
<label data-bind="attr: {for: getCode() + '_telephone'}" class="label"> <label data-bind="attr: {for: getCode() + '_telephone'}" class="label">
<span><!-- ko text: $t('Telephone')--><!-- /ko --></span> <span><!-- ko text: $t('Telephone')--><!-- /ko --></span>
</label> </label>
...@@ -120,20 +120,21 @@ ...@@ -120,20 +120,21 @@
<input type="number" class="input-text" <input type="number" class="input-text"
name="payment[telephone]" name="payment[telephone]"
data-bind=" data-bind="
attr: { attr: {
id: getCode() + '_telephone', id: getCode() + '_telephone',
title: $t('Telephone'), title: $t('Telephone'),
'data-container': getCode() + '-telephone', 'data-container': getCode() + '-telephone',
'data-validate': JSON.stringify({'required-number':true }) 'data-validate': JSON.stringify({'required-number':true })
}, },
value: telephone" value: telephone"
data-validate="{required:true}"
/> />
</div> </div>
</div> </div>
<!--/ko--> <!--/ko-->
<!-- ko if: showSsn() --> <!-- ko if: showSsn() -->
<div class="field required"> <div class="field ssn type required">
<label data-bind="attr: {for: getCode() + '_ssn'}" class="label"> <label data-bind="attr: {for: getCode() + '_ssn'}" class="label">
<span><!-- ko text: $t('Personal number (last digits)')--><!-- /ko --></span> <span><!-- ko text: $t('Personal number (last digits)')--><!-- /ko --></span>
</label> </label>
...@@ -149,6 +150,7 @@ ...@@ -149,6 +150,7 @@
maxlength : getSsnLength() maxlength : getSsnLength()
}, },
value: ssn" value: ssn"
data-validate="{required:true}"
/> />
</div> </div>
</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