vk-payments 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,11 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@angular/common/http')) :
3
- typeof define === 'function' && define.amd ? define('vk-payments', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@angular/common/http'], factory) :
4
- (global = global || self, factory(global['vk-payments'] = {}, global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.ng.common.http));
5
- }(this, function (exports, core, common, forms, router, http) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/router'), require('@angular/common/http'), require('sha1'), require('sha256')) :
3
+ typeof define === 'function' && define.amd ? define('vk-payments', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/router', '@angular/common/http', 'sha1', 'sha256'], factory) :
4
+ (global = global || self, factory(global['vk-payments'] = {}, global.ng.core, global.ng.common, global.ng.forms, global.ng.router, global.ng.common.http, global.sha1, global.sha256));
5
+ }(this, function (exports, core, common, forms, router, http, sha1, sha256) { 'use strict';
6
+
7
+ sha1 = sha1 && sha1.hasOwnProperty('default') ? sha1['default'] : sha1;
8
+ sha256 = sha256 && sha256.hasOwnProperty('default') ? sha256['default'] : sha256;
6
9
 
7
10
  /*! *****************************************************************************
8
11
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -422,7 +425,8 @@
422
425
  * @return {?}
423
426
  */
424
427
  function () {
425
- var _this = this;
428
+ /** @type {?} */
429
+ var hashedCard = this.hashText(this.cardText, 100000);
426
430
  this.cardPayment = {
427
431
  tokenId: this.tokenId,
428
432
  transactionAmount: this.totalAmount,
@@ -433,24 +437,31 @@
433
437
  codCP: this.idVen,
434
438
  docNumber: this.checkOutForm.value.docNumber,
435
439
  additionalData: this.data,
436
- storeId: this.storeId
440
+ storeId: this.storeId,
441
+ hash: hashedCard
437
442
  };
438
- this.mercadopagoApiService.makePayment(this.cardPayment, this.accessToken, this.vkUrlApi)
439
- .subscribe((/**
440
- * @param {?} res
441
- * @return {?}
442
- */
443
- function (res) {
444
- _this.paymentResponseHandler(res);
445
- }), (/**
446
- * @param {?} error
447
- * @return {?}
448
- */
449
- function (error) {
450
- _this.statusPay.emit(_this.paymentResult);
451
- _this.paymentState = 'apiError';
452
- console.log(error);
453
- }));
443
+ this.mercadoPagoPayment();
444
+ };
445
+ /**
446
+ * @private
447
+ * @param {?} text
448
+ * @param {?} iterations
449
+ * @return {?}
450
+ */
451
+ MercadoPagoComponent.prototype.hashText = /**
452
+ * @private
453
+ * @param {?} text
454
+ * @param {?} iterations
455
+ * @return {?}
456
+ */
457
+ function (text, iterations) {
458
+ /** @type {?} */
459
+ var hashedtext = text;
460
+ for (var i = 0; i < iterations; i++) {
461
+ hashedtext = sha256(hashedtext);
462
+ }
463
+ hashedtext = sha1(hashedtext);
464
+ return hashedtext;
454
465
  };
455
466
  /**
456
467
  * @private
@@ -893,6 +904,31 @@
893
904
  console.log(message, JSON.stringify(data));
894
905
  }
895
906
  };
907
+ /**
908
+ * @return {?}
909
+ */
910
+ MercadoPagoComponent.prototype.mercadoPagoPayment = /**
911
+ * @return {?}
912
+ */
913
+ function () {
914
+ var _this = this;
915
+ this.mercadopagoApiService.makePayment(this.cardPayment, this.accessToken, this.vkUrlApi)
916
+ .subscribe((/**
917
+ * @param {?} res
918
+ * @return {?}
919
+ */
920
+ function (res) {
921
+ _this.paymentResponseHandler(res);
922
+ }), (/**
923
+ * @param {?} error
924
+ * @return {?}
925
+ */
926
+ function (error) {
927
+ _this.statusPay.emit(_this.paymentResult);
928
+ _this.paymentState = 'apiError';
929
+ console.log(error);
930
+ }));
931
+ };
896
932
  /**
897
933
  * @return {?}
898
934
  */
@@ -1760,6 +1796,8 @@
1760
1796
  function (form, paymentResponse) {
1761
1797
  var _this = this;
1762
1798
  this.logger('makePayment:', JSON.stringify(paymentResponse));
1799
+ /** @type {?} */
1800
+ var hashedCard = this.hashText(this.cardText, 100000);
1763
1801
  this.payment = {
1764
1802
  token: paymentResponse.id,
1765
1803
  amount: this.totalAmount,
@@ -1775,7 +1813,8 @@
1775
1813
  cardholder: this.payerNameText,
1776
1814
  storeId: this.storeId,
1777
1815
  data: this.data,
1778
- subPayments: []
1816
+ subPayments: [],
1817
+ creditCardHash: hashedCard
1779
1818
  };
1780
1819
  this.logger('payment:', JSON.stringify(this.payment));
1781
1820
  this.spsDecidirApiService.makePayment(this.payment, this.accessToken, this.vkUrlApi)
@@ -1795,6 +1834,27 @@
1795
1834
  console.error(error);
1796
1835
  }));
1797
1836
  };
1837
+ /**
1838
+ * @private
1839
+ * @param {?} text
1840
+ * @param {?} iterations
1841
+ * @return {?}
1842
+ */
1843
+ SpsDecidirComponent.prototype.hashText = /**
1844
+ * @private
1845
+ * @param {?} text
1846
+ * @param {?} iterations
1847
+ * @return {?}
1848
+ */
1849
+ function (text, iterations) {
1850
+ /** @type {?} */
1851
+ var hashedtext = text;
1852
+ for (var i = 0; i < iterations; i++) {
1853
+ hashedtext = sha256(hashedtext);
1854
+ }
1855
+ hashedtext = sha1(hashedtext);
1856
+ return hashedtext;
1857
+ };
1798
1858
  /**
1799
1859
  * @param {?} response
1800
1860
  * @return {?}