Skip to content

Commit 58f3cdc

Browse files
committed
Merge pull request magento#394 from magento-mpi/MAGETWO-49453
[MPI] Bug fixes
2 parents 97ade87 + 58122dd commit 58f3cdc

File tree

2 files changed

+160
-45
lines changed
  • app/code/Magento

2 files changed

+160
-45
lines changed

Diff for: app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js

+159-45
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ define(
1313
'mage/translate'
1414
],
1515
function (_, Component, creditCardData, cardNumberValidator, $t) {
16+
'use strict';
17+
1618
return Component.extend({
1719
defaults: {
1820
creditCardType: '',
@@ -39,26 +41,33 @@ define(
3941
'creditCardSsIssue',
4042
'selectedCardType'
4143
]);
44+
4245
return this;
4346
},
4447

45-
initialize: function() {
48+
/**
49+
* Init component
50+
*/
51+
initialize: function () {
4652
var self = this;
53+
4754
this._super();
4855

4956
//Set credit card number to credit card data object
50-
this.creditCardNumber.subscribe(function(value) {
57+
this.creditCardNumber.subscribe(function (value) {
5158
var result;
59+
5260
self.selectedCardType(null);
5361

54-
if (value == '' || value == null) {
62+
if (value === '' || value === null) {
5563
return false;
5664
}
5765
result = cardNumberValidator(value);
5866

5967
if (!result.isPotentiallyValid && !result.isValid) {
6068
return false;
6169
}
70+
6271
if (result.card !== null) {
6372
self.selectedCardType(result.card.type);
6473
creditCardData.creditCard = result.card;
@@ -71,25 +80,34 @@ define(
7180
});
7281

7382
//Set expiration year to credit card data object
74-
this.creditCardExpYear.subscribe(function(value) {
83+
this.creditCardExpYear.subscribe(function (value) {
7584
creditCardData.expirationYear = value;
7685
});
7786

7887
//Set expiration month to credit card data object
79-
this.creditCardExpMonth.subscribe(function(value) {
80-
creditCardData.expirationYear = value;
88+
this.creditCardExpMonth.subscribe(function (value) {
89+
creditCardData.expirationMonth = value;
8190
});
8291

8392
//Set cvv code to credit card data object
84-
this.creditCardVerificationNumber.subscribe(function(value) {
93+
this.creditCardVerificationNumber.subscribe(function (value) {
8594
creditCardData.cvvCode = value;
8695
});
8796
},
8897

89-
getCode: function() {
98+
/**
99+
* Get code
100+
* @returns {String}
101+
*/
102+
getCode: function () {
90103
return 'cc';
91104
},
92-
getData: function() {
105+
106+
/**
107+
* Get data
108+
* @returns {Object}
109+
*/
110+
getData: function () {
93111
return {
94112
'method': this.item.method,
95113
'additional_data': {
@@ -104,89 +122,185 @@ define(
104122
}
105123
};
106124
},
107-
getCcAvailableTypes: function() {
125+
126+
/**
127+
* Get list of available credit card types
128+
* @returns {Object}
129+
*/
130+
getCcAvailableTypes: function () {
108131
return window.checkoutConfig.payment.ccform.availableTypes[this.getCode()];
109132
},
133+
134+
/**
135+
* Get payment icons
136+
* @param {String} type
137+
* @returns {Boolean}
138+
*/
110139
getIcons: function (type) {
111-
return window.checkoutConfig.payment.ccform.icons.hasOwnProperty(type)
112-
? window.checkoutConfig.payment.ccform.icons[type]
113-
: false
140+
return window.checkoutConfig.payment.ccform.icons.hasOwnProperty(type) ?
141+
window.checkoutConfig.payment.ccform.icons[type]
142+
: false;
114143
},
115-
getCcMonths: function() {
144+
145+
/**
146+
* Get list of months
147+
* @returns {Object}
148+
*/
149+
getCcMonths: function () {
116150
return window.checkoutConfig.payment.ccform.months[this.getCode()];
117151
},
118-
getCcYears: function() {
152+
153+
/**
154+
* Get list of years
155+
* @returns {Object}
156+
*/
157+
getCcYears: function () {
119158
return window.checkoutConfig.payment.ccform.years[this.getCode()];
120159
},
121-
hasVerification: function() {
160+
161+
/**
162+
* Check if current payment has verification
163+
* @returns {Boolean}
164+
*/
165+
hasVerification: function () {
122166
return window.checkoutConfig.payment.ccform.hasVerification[this.getCode()];
123167
},
124-
hasSsCardType: function() {
168+
169+
/**
170+
* @deprecated
171+
* @returns {Boolean}
172+
*/
173+
hasSsCardType: function () {
125174
return window.checkoutConfig.payment.ccform.hasSsCardType[this.getCode()];
126175
},
127-
getCvvImageUrl: function() {
176+
177+
/**
178+
* Get image url for CVV
179+
* @returns {String}
180+
*/
181+
getCvvImageUrl: function () {
128182
return window.checkoutConfig.payment.ccform.cvvImageUrl[this.getCode()];
129183
},
130-
getCvvImageHtml: function() {
131-
return '<img src="' + this.getCvvImageUrl()
132-
+ '" alt="' + $t('Card Verification Number Visual Reference')
133-
+ '" title="' + $t('Card Verification Number Visual Reference')
134-
+ '" />';
184+
185+
/**
186+
* Get image for CVV
187+
* @returns {String}
188+
*/
189+
getCvvImageHtml: function () {
190+
return '<img src="' + this.getCvvImageUrl() +
191+
'" alt="' + $t('Card Verification Number Visual Reference') +
192+
'" title="' + $t('Card Verification Number Visual Reference') +
193+
'" />';
135194
},
136-
getSsStartYears: function() {
195+
196+
/**
197+
* @deprecated
198+
* @returns {Object}
199+
*/
200+
getSsStartYears: function () {
137201
return window.checkoutConfig.payment.ccform.ssStartYears[this.getCode()];
138202
},
139-
getCcAvailableTypesValues: function() {
140-
return _.map(this.getCcAvailableTypes(), function(value, key) {
203+
204+
/**
205+
* Get list of available credit card types values
206+
* @returns {Object}
207+
*/
208+
getCcAvailableTypesValues: function () {
209+
return _.map(this.getCcAvailableTypes(), function (value, key) {
141210
return {
142211
'value': key,
143212
'type': value
144-
}
213+
};
145214
});
146215
},
147-
getCcMonthsValues: function() {
148-
return _.map(this.getCcMonths(), function(value, key) {
216+
217+
/**
218+
* Get list of available month values
219+
* @returns {Object}
220+
*/
221+
getCcMonthsValues: function () {
222+
return _.map(this.getCcMonths(), function (value, key) {
149223
return {
150224
'value': key,
151225
'month': value
152-
}
226+
};
153227
});
154228
},
155-
getCcYearsValues: function() {
156-
return _.map(this.getCcYears(), function(value, key) {
229+
230+
/**
231+
* Get list of available year values
232+
* @returns {Object}
233+
*/
234+
getCcYearsValues: function () {
235+
return _.map(this.getCcYears(), function (value, key) {
157236
return {
158237
'value': key,
159238
'year': value
160-
}
239+
};
161240
});
162241
},
163-
getSsStartYearsValues: function() {
164-
return _.map(this.getSsStartYears(), function(value, key) {
242+
243+
/**
244+
* @deprecated
245+
* @returns {Object}
246+
*/
247+
getSsStartYearsValues: function () {
248+
return _.map(this.getSsStartYears(), function (value, key) {
165249
return {
166250
'value': key,
167251
'year': value
168-
}
252+
};
169253
});
170254
},
171-
isShowLegend: function() {
255+
256+
/**
257+
* Is legend available to display
258+
* @returns {Boolean}
259+
*/
260+
isShowLegend: function () {
172261
return false;
173262
},
174-
getCcTypeTitleByCode: function(code) {
175-
var title = '';
263+
264+
/**
265+
* Get available credit card type by code
266+
* @param {String} code
267+
* @returns {String}
268+
*/
269+
getCcTypeTitleByCode: function (code) {
270+
var title = '',
271+
keyValue = 'value',
272+
keyType = 'type';
273+
176274
_.each(this.getCcAvailableTypesValues(), function (value) {
177-
if (value['value'] == code) {
178-
title = value['type'];
275+
if (value[keyValue] === code) {
276+
title = value[keyType];
179277
}
180278
});
279+
181280
return title;
182281
},
183-
formatDisplayCcNumber: function(number) {
282+
283+
/**
284+
* Prepare credit card number to output
285+
* @param {String} number
286+
* @returns {String}
287+
*/
288+
formatDisplayCcNumber: function (number) {
184289
return 'xxxx-' + number.substr(-4);
185290
},
186-
getInfo: function() {
291+
292+
/**
293+
* Get credit card details
294+
* @returns {Array}
295+
*/
296+
getInfo: function () {
187297
return [
188-
{'name': 'Credit Card Type', value: this.getCcTypeTitleByCode(this.creditCardType())},
189-
{'name': 'Credit Card Number', value: this.formatDisplayCcNumber(this.creditCardNumber())}
298+
{
299+
'name': 'Credit Card Type', value: this.getCcTypeTitleByCode(this.creditCardType())
300+
},
301+
{
302+
'name': 'Credit Card Number', value: this.formatDisplayCcNumber(this.creditCardNumber())
303+
}
190304
];
191305
}
192306
});

Diff for: app/code/Magento/Paypal/etc/frontend/di.xml

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<item name="paypal_payflowbml" xsi:type="string">/paypal/payflowbml/</item>
4949
<item name="paypal_payflowexpress" xsi:type="string">/paypal/payflowexpress/</item>
5050
<item name="paypal_transparent" xsi:type="string">/paypal/transparent/</item>
51+
<item name="paypal_express" xsi:type="string">/paypal/express/</item>
5152
</argument>
5253
</arguments>
5354
</type>

0 commit comments

Comments
 (0)