From e65dd6846275f4e350445883bd33e8ea3a7c5f7a Mon Sep 17 00:00:00 2001
From: Stanislav Idolov <sidolov@ebay.com>
Date: Thu, 25 Jun 2015 18:25:37 +0300
Subject: [PATCH] MAGETWO-38647: credit card validation issue

---
 .../credit-card-data.js                       | 19 +++++++++++++
 .../frontend/web/js/view/payment/cc-form.js   | 28 ++++++++++++++++++-
 .../web/template/payment/cc-form.html         |  3 +-
 3 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-data.js

diff --git a/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-data.js b/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-data.js
new file mode 100644
index 00000000000..ef6dd82c179
--- /dev/null
+++ b/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-data.js
@@ -0,0 +1,19 @@
+/**
+ * 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
+        }
+    }
+);
diff --git a/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js b/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js
index b8c738f6b3d..4e9c7b83332 100644
--- a/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js
+++ b/app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js
@@ -8,9 +8,10 @@ define(
     [
         'underscore',
         'Magento_Checkout/js/view/payment/default',
+        'Magento_Payment/js/model/credit-card-validation/credit-card-data',
         'mage/translate'
     ],
-    function (_, Component, $t) {
+    function (_, Component, creditCardData, $t) {
         return Component.extend({
             defaults: {
                 creditCardType: '',
@@ -34,6 +35,31 @@ define(
                     ]);
                 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() {
                 return 'cc';
             },
diff --git a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html
index 52a675b8902..87dfe38b878 100644
--- a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html
+++ b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html
@@ -38,7 +38,8 @@
             <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'})},
                               enable: isActive($parents),
-                              value: creditCardNumber"/>
+                              value: creditCardNumber,
+                              valueUpdate: 'keyup',"/>
         </div>
     </div>
     <div class="field date required" data-bind="attr: {id: getCode() + '_cc_type_exp_div'}">
-- 
GitLab