vk-payments 0.2.31 → 0.2.33

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.
@@ -5,6 +5,7 @@ import { Router, RouterModule } from '@angular/router';
5
5
  import { __values, __awaiter, __generator } from 'tslib';
6
6
  import { HttpHeaders, HttpClient, HttpClientModule } from '@angular/common/http';
7
7
  import sha256 from 'sha256';
8
+ import { toDataURL } from 'qrcode';
8
9
 
9
10
  /**
10
11
  * @fileoverview added by tsickle
@@ -4025,6 +4026,476 @@ var BankTransferModule = /** @class */ (function () {
4025
4026
  return BankTransferModule;
4026
4027
  }());
4027
4028
 
4029
+ /**
4030
+ * @fileoverview added by tsickle
4031
+ * Generated from: lib/galicia/services/galicia.api.service.ts
4032
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4033
+ */
4034
+ var GaliciaApiService = /** @class */ (function () {
4035
+ function GaliciaApiService(httpClient) {
4036
+ this.httpClient = httpClient;
4037
+ }
4038
+ /**
4039
+ * @param {?} url
4040
+ * @return {?}
4041
+ */
4042
+ GaliciaApiService.prototype.normalizeUrl = /**
4043
+ * @param {?} url
4044
+ * @return {?}
4045
+ */
4046
+ function (url) {
4047
+ if (url.length > 0 && url.charAt(url.length - 1) == '/') {
4048
+ url = url.substr(0, url.length - 1);
4049
+ }
4050
+ return url;
4051
+ };
4052
+ /**
4053
+ * @param {?} url
4054
+ * @param {?} initPayment
4055
+ * @return {?}
4056
+ */
4057
+ GaliciaApiService.prototype.initPayment = /**
4058
+ * @param {?} url
4059
+ * @param {?} initPayment
4060
+ * @return {?}
4061
+ */
4062
+ function (url, initPayment) {
4063
+ /** @type {?} */
4064
+ var body = {
4065
+ storeId: initPayment.storeId,
4066
+ userId: initPayment.userId,
4067
+ sessionId: initPayment.sessionId,
4068
+ storeName: initPayment.storeName,
4069
+ checkoutId: initPayment.checkoutId
4070
+ };
4071
+ return this.httpClient.post(this.normalizeUrl(url) + '/init-payment', body);
4072
+ };
4073
+ /**
4074
+ * @param {?} url
4075
+ * @param {?} billNumber
4076
+ * @return {?}
4077
+ */
4078
+ GaliciaApiService.prototype.paymentStatus = /**
4079
+ * @param {?} url
4080
+ * @param {?} billNumber
4081
+ * @return {?}
4082
+ */
4083
+ function (url, billNumber) {
4084
+ return this.httpClient.get(this.normalizeUrl(url) + '/payment-status?billNumber=' + billNumber);
4085
+ };
4086
+ GaliciaApiService.decorators = [
4087
+ { type: Injectable, args: [{
4088
+ providedIn: 'root'
4089
+ },] }
4090
+ ];
4091
+ /** @nocollapse */
4092
+ GaliciaApiService.ctorParameters = function () { return [
4093
+ { type: HttpClient }
4094
+ ]; };
4095
+ /** @nocollapse */ GaliciaApiService.ngInjectableDef = ɵɵdefineInjectable({ factory: function GaliciaApiService_Factory() { return new GaliciaApiService(ɵɵinject(HttpClient)); }, token: GaliciaApiService, providedIn: "root" });
4096
+ return GaliciaApiService;
4097
+ }());
4098
+ if (false) {
4099
+ /**
4100
+ * @type {?}
4101
+ * @private
4102
+ */
4103
+ GaliciaApiService.prototype.authHeaders;
4104
+ /**
4105
+ * @type {?}
4106
+ * @private
4107
+ */
4108
+ GaliciaApiService.prototype.httpClient;
4109
+ }
4110
+
4111
+ /**
4112
+ * @fileoverview added by tsickle
4113
+ * Generated from: lib/galicia/components/galicia.component.ts
4114
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4115
+ */
4116
+ var GaliciaComponent = /** @class */ (function () {
4117
+ function GaliciaComponent(galiciaApiService) {
4118
+ this.galiciaApiService = galiciaApiService;
4119
+ this.statusPay = new EventEmitter();
4120
+ this.qrImage = '';
4121
+ this.billNumber = '';
4122
+ this.errorMessage = '';
4123
+ this.isGeneratingQr = true;
4124
+ this.paymentCompleted = false;
4125
+ this.paymentId = '';
4126
+ this.showQr = false;
4127
+ this.expired = false;
4128
+ this.isLoading = false;
4129
+ this.hasError = false;
4130
+ this.minutes = 0;
4131
+ this.seconds = 0;
4132
+ this.paymentResult = { success: false, paymentId: '', integrator: 'GALICIA' };
4133
+ }
4134
+ /**
4135
+ * @return {?}
4136
+ */
4137
+ GaliciaComponent.prototype.ngOnInit = /**
4138
+ * @return {?}
4139
+ */
4140
+ function () {
4141
+ this.createInitPayment();
4142
+ };
4143
+ /**
4144
+ * @param {?} datos
4145
+ * @return {?}
4146
+ */
4147
+ GaliciaComponent.prototype.generateQr = /**
4148
+ * @param {?} datos
4149
+ * @return {?}
4150
+ */
4151
+ function (datos) {
4152
+ var _this = this;
4153
+ /** @type {?} */
4154
+ var decoded = atob(datos);
4155
+ toDataURL(decoded, {
4156
+ width: 300,
4157
+ margin: 2
4158
+ })
4159
+ .then((/**
4160
+ * @param {?} url
4161
+ * @return {?}
4162
+ */
4163
+ function (url) {
4164
+ _this.qrImage = url;
4165
+ _this.isGeneratingQr = false;
4166
+ _this.showQr = true;
4167
+ _this.expired = false;
4168
+ _this.startTimer();
4169
+ _this.startPaymentValidation();
4170
+ }));
4171
+ };
4172
+ /**
4173
+ * @return {?}
4174
+ */
4175
+ GaliciaComponent.prototype.createInitPayment = /**
4176
+ * @return {?}
4177
+ */
4178
+ function () {
4179
+ this.OinitPayment = {
4180
+ sessionId: '',
4181
+ userId: this.userId,
4182
+ storeId: this.storeId,
4183
+ storeName: this.storeName,
4184
+ checkoutId: this.checkoutId
4185
+ };
4186
+ this.initPayment();
4187
+ };
4188
+ /**
4189
+ * @return {?}
4190
+ */
4191
+ GaliciaComponent.prototype.initPayment = /**
4192
+ * @return {?}
4193
+ */
4194
+ function () {
4195
+ var _this = this;
4196
+ this.isGeneratingQr = true;
4197
+ this.galiciaApiService.initPayment(this.vkUrlApi, this.OinitPayment)
4198
+ .subscribe({
4199
+ next: (/**
4200
+ * @param {?} v
4201
+ * @return {?}
4202
+ */
4203
+ function (v) { return _this.initPaymentResponseHandler(v); }),
4204
+ error: (/**
4205
+ * @param {?} v
4206
+ * @return {?}
4207
+ */
4208
+ function (v) { return _this.initPaymentErrorHandler(v); })
4209
+ });
4210
+ };
4211
+ /**
4212
+ * @private
4213
+ * @param {?} response
4214
+ * @return {?}
4215
+ */
4216
+ GaliciaComponent.prototype.initPaymentResponseHandler = /**
4217
+ * @private
4218
+ * @param {?} response
4219
+ * @return {?}
4220
+ */
4221
+ function (response) {
4222
+ if (!response.success) {
4223
+ this.isLoading = false;
4224
+ this.hasError = true;
4225
+ this.statusPay.emit(this.paymentResult);
4226
+ this.errorMessage = response.errorsMessages[0] || 'Ocurrió un error al generar el código QR.';
4227
+ return;
4228
+ }
4229
+ /** @type {?} */
4230
+ var qrData = response.data.bills[0].qr.datos;
4231
+ this.billNumber = response.data.bills[0].nroBoleta;
4232
+ this.generateQr(qrData);
4233
+ };
4234
+ /**
4235
+ * @private
4236
+ * @param {?} error
4237
+ * @return {?}
4238
+ */
4239
+ GaliciaComponent.prototype.initPaymentErrorHandler = /**
4240
+ * @private
4241
+ * @param {?} error
4242
+ * @return {?}
4243
+ */
4244
+ function (error) {
4245
+ this.isLoading = false;
4246
+ this.hasError = true;
4247
+ this.errorMessage = error.errorsMessages[0] || 'Ocurrió un error al generar el código QR.';
4248
+ this.paymentResult.success = false;
4249
+ this.statusPay.emit(this.paymentResult);
4250
+ };
4251
+ /**
4252
+ * @return {?}
4253
+ */
4254
+ GaliciaComponent.prototype.startTimer = /**
4255
+ * @return {?}
4256
+ */
4257
+ function () {
4258
+ var _this = this;
4259
+ clearInterval(this.interval);
4260
+ this.minutes = 1;
4261
+ this.seconds = 0;
4262
+ this.interval = setInterval((/**
4263
+ * @return {?}
4264
+ */
4265
+ function () {
4266
+ if (_this.seconds === 0) {
4267
+ if (_this.minutes === 0) {
4268
+ _this.stopValidation();
4269
+ _this.showQr = false;
4270
+ _this.expired = true;
4271
+ return;
4272
+ }
4273
+ _this.minutes--;
4274
+ _this.seconds = 59;
4275
+ }
4276
+ else {
4277
+ _this.seconds--;
4278
+ }
4279
+ }), 1000);
4280
+ };
4281
+ /**
4282
+ * @return {?}
4283
+ */
4284
+ GaliciaComponent.prototype.startPaymentValidation = /**
4285
+ * @return {?}
4286
+ */
4287
+ function () {
4288
+ var _this = this;
4289
+ this.validationInterval = setInterval((/**
4290
+ * @return {?}
4291
+ */
4292
+ function () {
4293
+ _this.galiciaApiService.paymentStatus(_this.vkUrlApi, _this.billNumber)
4294
+ .subscribe({
4295
+ next: (/**
4296
+ * @param {?} v
4297
+ * @return {?}
4298
+ */
4299
+ function (v) { return _this.paymentStatusResponseHandler(v); }),
4300
+ error: (/**
4301
+ * @param {?} v
4302
+ * @return {?}
4303
+ */
4304
+ function (v) { return _this.paymentStatusErrorHandler(v); })
4305
+ });
4306
+ }), 5000);
4307
+ };
4308
+ /**
4309
+ * @param {?} response
4310
+ * @return {?}
4311
+ */
4312
+ GaliciaComponent.prototype.paymentStatusResponseHandler = /**
4313
+ * @param {?} response
4314
+ * @return {?}
4315
+ */
4316
+ function (response) {
4317
+ if (!response.success) {
4318
+ this.isLoading = false;
4319
+ this.statusPay.emit(this.paymentResult);
4320
+ return;
4321
+ }
4322
+ if (response.data.isPaid) {
4323
+ this.stopValidation();
4324
+ this.showQr = false;
4325
+ this.expired = false;
4326
+ this.paymentCompleted = true;
4327
+ this.paymentId = response.data.paymentId;
4328
+ this.paymentResult = {
4329
+ success: true,
4330
+ paymentId: this.paymentId,
4331
+ integrator: 'GALICIA'
4332
+ };
4333
+ this.statusPay.emit(this.paymentResult);
4334
+ }
4335
+ };
4336
+ /**
4337
+ * @private
4338
+ * @param {?} error
4339
+ * @return {?}
4340
+ */
4341
+ GaliciaComponent.prototype.paymentStatusErrorHandler = /**
4342
+ * @private
4343
+ * @param {?} error
4344
+ * @return {?}
4345
+ */
4346
+ function (error) {
4347
+ clearInterval(this.validationInterval);
4348
+ this.hasError = true;
4349
+ };
4350
+ /**
4351
+ * @return {?}
4352
+ */
4353
+ GaliciaComponent.prototype.showQrAgain = /**
4354
+ * @return {?}
4355
+ */
4356
+ function () {
4357
+ this.showQr = true;
4358
+ this.expired = false;
4359
+ this.startTimer();
4360
+ this.startPaymentValidation();
4361
+ };
4362
+ /**
4363
+ * @private
4364
+ * @return {?}
4365
+ */
4366
+ GaliciaComponent.prototype.stopValidation = /**
4367
+ * @private
4368
+ * @return {?}
4369
+ */
4370
+ function () {
4371
+ clearInterval(this.validationInterval);
4372
+ clearInterval(this.interval);
4373
+ };
4374
+ GaliciaComponent.decorators = [
4375
+ { type: Component, args: [{
4376
+ selector: 'lib-galicia',
4377
+ template: "<div class=\"gc-payment\">\n <div class=\"formRow\">\n <p>\n Escane\u00E1 el c\u00F3digo QR con tu aplicaci\u00F3n bancaria para realizar el pago.\n </p>\n </div>\n\n <div *ngIf=\"isGeneratingQr && !hasError\" class=\"loading-container\">\n <div class=\"spinner\"></div>\n <p>Generando c\u00F3digo QR...</p>\n </div>\n\n <div *ngIf=\"showQr\">\n <div class=\"qr-container\">\n <img [src]=\"qrImage\" alt=\"QR Galicia\" />\n </div>\n\n <div class=\"timer\">\n Tiempo restante: {{ minutes }}:{{ seconds < 10 ? '0' + seconds : seconds }} \n </div>\n </div>\n\n <div *ngIf=\"hasError\" class=\"payment-error\">\n <div class=\"error-icon\">\n \u26A0\n </div>\n\n <div class=\"error-message\">\n <h3>No fue posible generar el c\u00F3digo QR</h3>\n\n <p>{{ errorMessage }}</p>\n </div>\n </div>\n\n <div *ngIf=\"paymentCompleted\" class=\"payment-success\">\n <div class=\"success-icon\">\n \u2713\n </div>\n\n <div class=\"success-message\">\n <h3>Pago realizado correctamente</h3>\n\n <p>\n ID de pago Galicia: <strong>{{ paymentId }}</strong>\n </p>\n </div>\n </div>\n\n <div *ngIf=\"expired\">\n <div class=\"pay-message info\">\n El c\u00F3digo QR expir\u00F3.\n </div>\n\n <button type=\"button\" (click)=\"showQrAgain()\">\n Regenerar c\u00F3digo QR\n </button>\n\n </div>\n</div>",
4378
+ styles: [".gc-payment{display:flex;flex-direction:column;align-items:center;text-align:center}.formRow{width:100%;max-width:400px;margin-bottom:20px}.loading-container{text-align:center;padding:30px}.spinner{width:40px;height:40px;margin:0 auto 15px;border:4px solid #e0e0e0;border-top:4px solid #06c;border-radius:50%;-webkit-animation:1s linear infinite spin;animation:1s linear infinite spin}.qr-container{margin:20px 0}.qr-container img{max-width:300px;width:100%;height:auto}.timer{margin-top:10px;font-size:18px;font-weight:600}.payment-error{text-align:center;padding:30px;max-width:400px}.error-icon{width:80px;height:80px;margin:0 auto 15px;border-radius:50%;background:#fc2626;color:#fff;font-size:48px;font-weight:700;display:flex;align-items:center;justify-content:center}.error-message h3{color:#fc2626;margin-bottom:10px}.payment-success{text-align:center;padding:30px}.success-icon{width:80px;height:80px;margin:0 auto 15px;border-radius:50%;background:#28a745;color:#fff;font-size:48px;font-weight:700;display:flex;align-items:center;justify-content:center}.success-message h3{color:#28a745;margin-bottom:10px}@-webkit-keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}"]
4379
+ }] }
4380
+ ];
4381
+ /** @nocollapse */
4382
+ GaliciaComponent.ctorParameters = function () { return [
4383
+ { type: GaliciaApiService }
4384
+ ]; };
4385
+ GaliciaComponent.propDecorators = {
4386
+ accessToken: [{ type: Input }],
4387
+ gaUrlApi: [{ type: Input }],
4388
+ vkUrlApi: [{ type: Input }],
4389
+ userId: [{ type: Input }],
4390
+ logoGa: [{ type: Input }],
4391
+ storeId: [{ type: Input }],
4392
+ storeName: [{ type: Input }],
4393
+ sessionId: [{ type: Input }],
4394
+ checkoutId: [{ type: Input }],
4395
+ data: [{ type: Input }],
4396
+ statusPay: [{ type: Output }]
4397
+ };
4398
+ return GaliciaComponent;
4399
+ }());
4400
+ if (false) {
4401
+ /** @type {?} */
4402
+ GaliciaComponent.prototype.accessToken;
4403
+ /** @type {?} */
4404
+ GaliciaComponent.prototype.gaUrlApi;
4405
+ /** @type {?} */
4406
+ GaliciaComponent.prototype.vkUrlApi;
4407
+ /** @type {?} */
4408
+ GaliciaComponent.prototype.userId;
4409
+ /** @type {?} */
4410
+ GaliciaComponent.prototype.logoGa;
4411
+ /** @type {?} */
4412
+ GaliciaComponent.prototype.storeId;
4413
+ /** @type {?} */
4414
+ GaliciaComponent.prototype.storeName;
4415
+ /** @type {?} */
4416
+ GaliciaComponent.prototype.sessionId;
4417
+ /** @type {?} */
4418
+ GaliciaComponent.prototype.checkoutId;
4419
+ /** @type {?} */
4420
+ GaliciaComponent.prototype.data;
4421
+ /** @type {?} */
4422
+ GaliciaComponent.prototype.statusPay;
4423
+ /** @type {?} */
4424
+ GaliciaComponent.prototype.qrImage;
4425
+ /** @type {?} */
4426
+ GaliciaComponent.prototype.billNumber;
4427
+ /** @type {?} */
4428
+ GaliciaComponent.prototype.errorMessage;
4429
+ /** @type {?} */
4430
+ GaliciaComponent.prototype.OinitPayment;
4431
+ /** @type {?} */
4432
+ GaliciaComponent.prototype.isGeneratingQr;
4433
+ /** @type {?} */
4434
+ GaliciaComponent.prototype.paymentCompleted;
4435
+ /** @type {?} */
4436
+ GaliciaComponent.prototype.paymentId;
4437
+ /** @type {?} */
4438
+ GaliciaComponent.prototype.showQr;
4439
+ /** @type {?} */
4440
+ GaliciaComponent.prototype.expired;
4441
+ /** @type {?} */
4442
+ GaliciaComponent.prototype.isLoading;
4443
+ /** @type {?} */
4444
+ GaliciaComponent.prototype.hasError;
4445
+ /** @type {?} */
4446
+ GaliciaComponent.prototype.minutes;
4447
+ /** @type {?} */
4448
+ GaliciaComponent.prototype.seconds;
4449
+ /**
4450
+ * @type {?}
4451
+ * @private
4452
+ */
4453
+ GaliciaComponent.prototype.interval;
4454
+ /** @type {?} */
4455
+ GaliciaComponent.prototype.validationInterval;
4456
+ /** @type {?} */
4457
+ GaliciaComponent.prototype.paymentResult;
4458
+ /**
4459
+ * @type {?}
4460
+ * @private
4461
+ */
4462
+ GaliciaComponent.prototype.galiciaApiService;
4463
+ }
4464
+
4465
+ /**
4466
+ * @fileoverview added by tsickle
4467
+ * Generated from: lib/galicia/galicia.module.ts
4468
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4469
+ */
4470
+ /** @type {?} */
4471
+ var COMPONENTS$2 = [
4472
+ GaliciaComponent
4473
+ ];
4474
+ var GaliciaModule = /** @class */ (function () {
4475
+ function GaliciaModule() {
4476
+ }
4477
+ GaliciaModule.decorators = [
4478
+ { type: NgModule, args: [{
4479
+ declarations: [
4480
+ COMPONENTS$2
4481
+ ],
4482
+ exports: [
4483
+ COMPONENTS$2
4484
+ ],
4485
+ imports: [
4486
+ CommonModule,
4487
+ FormsModule,
4488
+ ReactiveFormsModule,
4489
+ RouterModule,
4490
+ ],
4491
+ providers: [
4492
+ GaliciaApiService
4493
+ ]
4494
+ },] }
4495
+ ];
4496
+ return GaliciaModule;
4497
+ }());
4498
+
4028
4499
  /**
4029
4500
  * @fileoverview added by tsickle
4030
4501
  * Generated from: lib/vk-payments.module.ts
@@ -4036,8 +4507,9 @@ var LIB_MODULES = [
4036
4507
  SpsDecidirModule,
4037
4508
  PaypalModule,
4038
4509
  GoCuotasModule,
4510
+ BankTransferModule,
4039
4511
  ModoModule,
4040
- BankTransferModule
4512
+ GaliciaModule
4041
4513
  ];
4042
4514
  var VkPaymentsModule = /** @class */ (function () {
4043
4515
  function VkPaymentsModule() {
@@ -4045,7 +4517,8 @@ var VkPaymentsModule = /** @class */ (function () {
4045
4517
  VkPaymentsModule.decorators = [
4046
4518
  { type: NgModule, args: [{
4047
4519
  imports: LIB_MODULES,
4048
- exports: LIB_MODULES
4520
+ exports: LIB_MODULES,
4521
+ declarations: []
4049
4522
  },] }
4050
4523
  ];
4051
4524
  return VkPaymentsModule;
@@ -4063,5 +4536,5 @@ var VkPaymentsModule = /** @class */ (function () {
4063
4536
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4064
4537
  */
4065
4538
 
4066
- export { VkPaymentsModule, MercadopagoModule as ɵa, MercadoPagoComponent as ɵb, MercadopagoApiService as ɵc, PromotionBankComponent as ɵd, SpsDecidirModule as ɵe, SpsDecidirComponent as ɵf, SpsDecidirApiService as ɵg, PaypalModule as ɵh, PayPalNewComponent as ɵi, GoCuotasModule as ɵj, GoCuotasComponent as ɵk, ModalComponent as ɵl, GoCuotasApiService as ɵm, ModoModule as ɵn, ModoComponent as ɵo, ModoApiService as ɵp, BankTransferModule as ɵq, BankTransferComponent as ɵr, BankTransferApiService as ɵs };
4539
+ export { VkPaymentsModule, MercadopagoModule as ɵa, MercadoPagoComponent as ɵb, MercadopagoApiService as ɵc, PromotionBankComponent as ɵd, SpsDecidirModule as ɵe, SpsDecidirComponent as ɵf, SpsDecidirApiService as ɵg, PaypalModule as ɵh, PayPalNewComponent as ɵi, GoCuotasModule as ɵj, GoCuotasComponent as ɵk, ModalComponent as ɵl, GoCuotasApiService as ɵm, BankTransferModule as ɵn, BankTransferComponent as ɵo, BankTransferApiService as ɵp, ModoModule as ɵq, ModoComponent as ɵr, ModoApiService as ɵs, GaliciaModule as ɵt, GaliciaComponent as ɵu, GaliciaApiService as ɵv };
4067
4540
  //# sourceMappingURL=vk-payments.js.map