Skip to content
Snippets Groups Projects
Commit e65dd684 authored by Stanislav Idolov's avatar Stanislav Idolov
Browse files

MAGETWO-38647: credit card validation issue

parent 73075912
No related merge requests found
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/*jshint browser:true jquery:true*/
/*global alert*/
define(
[],
function() {
'use strict';
return {
creditCard: null,
creditCardNumber: null,
expirationMonth: null,
expirationYear: null,
cvvCode: null
}
}
);
...@@ -8,9 +8,10 @@ define( ...@@ -8,9 +8,10 @@ define(
[ [
'underscore', 'underscore',
'Magento_Checkout/js/view/payment/default', 'Magento_Checkout/js/view/payment/default',
'Magento_Payment/js/model/credit-card-validation/credit-card-data',
'mage/translate' 'mage/translate'
], ],
function (_, Component, $t) { function (_, Component, creditCardData, $t) {
return Component.extend({ return Component.extend({
defaults: { defaults: {
creditCardType: '', creditCardType: '',
...@@ -34,6 +35,31 @@ define( ...@@ -34,6 +35,31 @@ define(
]); ]);
return this; return this;
}, },
initialize: function() {
this._super();
//Set credit card number to credit card data object
this.creditCardNumber.subscribe(function(value) {
console.log(value);
});
//Set expiration year to credit card data object
this.creditCardExpYear.subscribe(function(value) {
creditCardData.expirationYear = value;
});
//Set expiration month to credit card data object
this.creditCardExpMonth.subscribe(function(value) {
creditCardData.expirationYear = value;
});
//Set cvv code to credit card data object
this.creditCardVerificationNumber.subscribe(function(value) {
creditCardData.cvvCode = value;
});
},
getCode: function() { getCode: function() {
return 'cc'; return 'cc';
}, },
......
...@@ -38,7 +38,8 @@ ...@@ -38,7 +38,8 @@
<input type="text" name="payment[cc_number]" class="input-text" value="" <input type="text" name="payment[cc_number]" class="input-text" value=""
data-bind="attr: {id: getCode() + '_cc_number', title: $t('Credit Card Number'), 'data-container': getCode() + '-cc-number', 'data-validate': JSON.stringify({'required-number':true, 'validate-card-number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})}, data-bind="attr: {id: getCode() + '_cc_number', title: $t('Credit Card Number'), 'data-container': getCode() + '-cc-number', 'data-validate': JSON.stringify({'required-number':true, 'validate-card-number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})},
enable: isActive($parents), enable: isActive($parents),
value: creditCardNumber"/> value: creditCardNumber,
valueUpdate: 'keyup',"/>
</div> </div>
</div> </div>
<div class="field date required" data-bind="attr: {id: getCode() + '_cc_type_exp_div'}"> <div class="field date required" data-bind="attr: {id: getCode() + '_cc_type_exp_div'}">
......
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