epp-lib 0.0.4 → 0.0.6-snapshot

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.
Files changed (70) hide show
  1. package/esm2022/lib/api-route.const.mjs +2 -2
  2. package/esm2022/lib/component/index.mjs +4 -0
  3. package/esm2022/lib/component/payment.mjs +142 -0
  4. package/esm2022/lib/component/rapyd/rapyd.component.mjs +222 -0
  5. package/esm2022/lib/component/vodds-loader/vodds-loader.component.mjs +19 -0
  6. package/esm2022/lib/model/broadcast/broadcast-event-type.mjs +5 -0
  7. package/esm2022/lib/model/broadcast/ibroadcast-event.mjs +2 -0
  8. package/esm2022/lib/model/count-down-time.mjs +56 -0
  9. package/esm2022/lib/model/domain.mjs +4 -2
  10. package/esm2022/lib/model/iframe-message-type.mjs +2 -1
  11. package/esm2022/lib/model/index.mjs +9 -0
  12. package/esm2022/lib/model/timer.mjs +1 -3
  13. package/esm2022/lib/pipe/index.mjs +2 -0
  14. package/esm2022/lib/pipe/transloco.pipe.mjs +22 -0
  15. package/esm2022/lib/service/common-util.mjs +7 -0
  16. package/esm2022/lib/service/event-emitter.service.mjs +23 -0
  17. package/esm2022/lib/service/iframe-message.service.mjs +28 -14
  18. package/esm2022/lib/service/index.mjs +5 -0
  19. package/esm2022/lib/service/vodds-http.service.mjs +7 -8
  20. package/esm2022/lib/translation/epp-lib-loader.mjs +23 -0
  21. package/esm2022/lib/translation/epp-lib-translation.service.mjs +23 -0
  22. package/esm2022/lib/translation/epp-lib.providers.mjs +25 -0
  23. package/esm2022/lib/translation/i18n/cs.json +6 -0
  24. package/esm2022/lib/translation/i18n/en.json +7 -0
  25. package/esm2022/lib/translation/i18n/es.json +6 -0
  26. package/esm2022/lib/translation/i18n/ru.json +6 -0
  27. package/esm2022/lib/translation/index.mjs +4 -0
  28. package/esm2022/public-api.mjs +6 -16
  29. package/fesm2022/epp-lib-cs-Cq7S0zUq.mjs +13 -0
  30. package/fesm2022/epp-lib-cs-Cq7S0zUq.mjs.map +1 -0
  31. package/fesm2022/epp-lib-en-Bt5VLnlu.mjs +15 -0
  32. package/fesm2022/epp-lib-en-Bt5VLnlu.mjs.map +1 -0
  33. package/fesm2022/epp-lib-es--n1OPBgV.mjs +13 -0
  34. package/fesm2022/epp-lib-es--n1OPBgV.mjs.map +1 -0
  35. package/fesm2022/epp-lib-ru-DCZzQ5FE.mjs +13 -0
  36. package/fesm2022/epp-lib-ru-DCZzQ5FE.mjs.map +1 -0
  37. package/fesm2022/epp-lib.mjs +538 -138
  38. package/fesm2022/epp-lib.mjs.map +1 -1
  39. package/lib/component/index.d.ts +3 -0
  40. package/lib/{service/payment.service.d.ts → component/payment.d.ts} +9 -4
  41. package/lib/component/rapyd/rapyd.component.d.ts +37 -0
  42. package/lib/component/vodds-loader/vodds-loader.component.d.ts +7 -0
  43. package/lib/model/broadcast/broadcast-event-type.d.ts +3 -0
  44. package/lib/model/broadcast/ibroadcast-event.d.ts +5 -0
  45. package/lib/model/count-down-time.d.ts +16 -0
  46. package/lib/model/domain.d.ts +2 -0
  47. package/lib/model/iframe-message-type.d.ts +2 -1
  48. package/lib/model/index.d.ts +8 -0
  49. package/lib/pipe/index.d.ts +1 -0
  50. package/lib/pipe/transloco.pipe.d.ts +9 -0
  51. package/lib/service/common-util.d.ts +3 -0
  52. package/lib/service/event-emitter.service.d.ts +10 -0
  53. package/lib/service/iframe-message.service.d.ts +7 -5
  54. package/lib/service/index.d.ts +4 -0
  55. package/lib/service/vodds-http.service.d.ts +1 -3
  56. package/lib/translation/epp-lib-loader.d.ts +31 -0
  57. package/lib/translation/epp-lib-translation.service.d.ts +8 -0
  58. package/lib/translation/epp-lib.providers.d.ts +6 -0
  59. package/lib/translation/index.d.ts +3 -0
  60. package/package.json +4 -2
  61. package/public-api.d.ts +5 -12
  62. package/src/lib/translation/i18n/cs.json +6 -0
  63. package/src/lib/translation/i18n/en.json +7 -0
  64. package/src/lib/translation/i18n/es.json +6 -0
  65. package/src/lib/translation/i18n/ru.json +6 -0
  66. package/esm2022/lib/model/base-form.mjs +0 -49
  67. package/esm2022/lib/model/callback-message.mjs +0 -7
  68. package/esm2022/lib/service/payment.service.mjs +0 -100
  69. package/lib/model/base-form.d.ts +0 -28
  70. package/lib/model/callback-message.d.ts +0 -4
@@ -1,125 +1,112 @@
1
- import * as i1 from '@angular/common/http';
2
- import { HttpParams, HttpHeaders } from '@angular/common/http';
3
1
  import * as i0 from '@angular/core';
4
- import { Injectable, inject } from '@angular/core';
5
- import { Observable, Subject } from 'rxjs';
2
+ import { Injectable, inject, makeEnvironmentProviders, Pipe, Input, Component, Inject } from '@angular/core';
3
+ import * as i2 from '@jsverse/transloco';
4
+ import { TranslocoService, provideTransloco, provideTranslocoScope, TranslocoModule } from '@jsverse/transloco';
5
+ import { Subject, Observable, timer, takeUntil } from 'rxjs';
6
+ import { HttpClient, HttpHeaders } from '@angular/common/http';
7
+ import * as i1 from '@angular/material/dialog';
8
+ import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
9
+ import * as i3 from '@angular/material/progress-spinner';
10
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
11
+ import { NgStyle } from '@angular/common';
6
12
 
7
- class IParam {
8
- getMobileFlag() {
9
- return /android|mobi/i.test(navigator.userAgent.toLowerCase());
10
- }
11
- toJson() {
12
- return JSON.stringify(this);
13
- }
14
- toFormUrlEncoded() {
15
- return new URLSearchParams(Object.entries(this).map(([key, value]) => [key, String(value)])).toString();
13
+ class EppLibLoader {
14
+ getTranslation(lang) {
15
+ switch (lang) {
16
+ case 'cs':
17
+ return import('./epp-lib-cs-Cq7S0zUq.mjs');
18
+ case 'ru':
19
+ return import('./epp-lib-ru-DCZzQ5FE.mjs');
20
+ case 'es':
21
+ return import('./epp-lib-es--n1OPBgV.mjs');
22
+ case 'en':
23
+ default:
24
+ return import('./epp-lib-en-Bt5VLnlu.mjs');
25
+ }
16
26
  }
27
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EppLibLoader, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
28
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EppLibLoader }); }
17
29
  }
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EppLibLoader, decorators: [{
31
+ type: Injectable
32
+ }] });
18
33
 
19
- class BaseForm extends IParam {
34
+ class EppLibTranslationService {
20
35
  constructor() {
21
- super();
22
- this.isMobile = 'false';
23
- }
24
- /**
25
- * Use this function for building POST params with form url encoded content type.
26
- * Remeber to call params.toString() when passing to http request
27
- */
28
- getUrlSearchParam() {
29
- const params = new URLSearchParams();
30
- params.set('isMobile', this.isMobile);
31
- return params;
36
+ this.transloco = inject(TranslocoService);
32
37
  }
33
- /**
34
- * Use this function for building GET params
35
- */
36
- getHttpParams() {
37
- let params = new HttpParams();
38
- params = params.append('isMobile', this.isMobile);
39
- return params;
38
+ setLanguage(lang) {
39
+ this.transloco.setActiveLang(lang);
40
40
  }
41
- /**
42
- * Add isMobile = 'true' to paramters
43
- * @param params : object
44
- */
45
- addIsMobile(params) {
46
- params['isMobile'] = this.isMobile;
47
- }
48
- /**
49
- * For POST request with form-urlencoded
50
- */
51
- getHeaderWithContentTypeForm() {
52
- const headers = new HttpHeaders()
53
- .set('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
54
- return headers;
55
- }
56
- /**
57
- * For POST request with json body
58
- */
59
- getHeaderWithContentTypeJson() {
60
- const headers = new HttpHeaders()
61
- .set('Content-Type', 'application/json; charset=utf-8');
62
- return headers;
41
+ getLanguage() {
42
+ return this.transloco.getActiveLang();
63
43
  }
44
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EppLibTranslationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
45
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EppLibTranslationService, providedIn: 'root' }); }
64
46
  }
47
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EppLibTranslationService, decorators: [{
48
+ type: Injectable,
49
+ args: [{
50
+ providedIn: 'root'
51
+ }]
52
+ }] });
65
53
 
66
- class CallbackMessage {
67
- constructor(errorMessage) {
68
- this.errorMessage = '';
69
- this.errorMessage = errorMessage;
70
- }
54
+ function provideEppLibTranslations(config) {
55
+ return makeEnvironmentProviders([
56
+ provideTransloco({
57
+ config: {
58
+ availableLangs: config.availableLangs,
59
+ defaultLang: config.defaultLang,
60
+ reRenderOnLangChange: true,
61
+ },
62
+ loader: EppLibLoader,
63
+ }),
64
+ provideTranslocoScope({
65
+ scope: 'epp-lib',
66
+ loader: {
67
+ en: () => import('./epp-lib-en-Bt5VLnlu.mjs'),
68
+ cs: () => import('./epp-lib-cs-Cq7S0zUq.mjs'),
69
+ es: () => import('./epp-lib-es--n1OPBgV.mjs'),
70
+ ru: () => import('./epp-lib-ru-DCZzQ5FE.mjs'),
71
+ },
72
+ })
73
+ ]);
71
74
  }
72
75
 
73
- var PaymentType;
74
- (function (PaymentType) {
75
- PaymentType[PaymentType["NA"] = 0] = "NA";
76
- PaymentType[PaymentType["JETON"] = 1] = "JETON";
77
- PaymentType[PaymentType["ECOPAYZ"] = 2] = "ECOPAYZ";
78
- PaymentType[PaymentType["RAPYD"] = 3] = "RAPYD";
79
- })(PaymentType || (PaymentType = {}));
80
-
81
- class Checkout {
76
+ class EventEmitterService {
82
77
  constructor() {
83
- this.requestId = 0;
84
- this.paymentType = PaymentType.NA;
85
- this.url = '';
86
- this.expiration = 300;
87
- this.errorMessage = '';
88
- this.successMessage = '';
78
+ this.eventBus = new Subject();
89
79
  }
90
- setErrorMessage(errorMessage) {
91
- this.errorMessage = errorMessage;
92
- this.popup = undefined;
80
+ broadcast(event) {
81
+ this.eventBus.next(event);
93
82
  }
94
- setCallback(callback) {
95
- this.successMessage = 'success';
96
- this.callback = callback;
97
- this.popup = undefined;
83
+ getEventBus() {
84
+ return this.eventBus;
98
85
  }
86
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EventEmitterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
87
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EventEmitterService, providedIn: 'root' }); }
99
88
  }
89
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EventEmitterService, decorators: [{
90
+ type: Injectable,
91
+ args: [{
92
+ providedIn: 'root',
93
+ }]
94
+ }] });
100
95
 
101
96
  class Domain {
102
97
  constructor() {
103
98
  this.defaultDomain = '';
104
- this.allowedOrigins = ['http://localhost:9000'];
99
+ this.allowedOrigins = ['http://localhost:9000', 'http://localhost:4200'];
105
100
  this.specialDomain = [];
106
101
  this.jetonDomain = '';
102
+ this.ecopayzDomain = '';
103
+ this.rapydDomain = 'https://sandboxcheckout.rapyd.net';
107
104
  }
108
105
  }
109
106
 
110
- var IframeMessageType;
111
- (function (IframeMessageType) {
112
- IframeMessageType[IframeMessageType["OPEN_PAYMENT_FORM"] = 0] = "OPEN_PAYMENT_FORM";
113
- IframeMessageType[IframeMessageType["PAYMENT_CALLBACK"] = 1] = "PAYMENT_CALLBACK";
114
- })(IframeMessageType || (IframeMessageType = {}));
115
-
116
- const ApiRoute = {
117
- GET_DOMAIN: { url: "/getDomain", method: "get" }
118
- };
119
-
120
107
  class VoddsHttpService {
121
- constructor(httpClient) {
122
- this.httpClient = httpClient;
108
+ constructor() {
109
+ this.httpClient = inject(HttpClient);
123
110
  }
124
111
  postJson(url, request) {
125
112
  const headers = new HttpHeaders({ 'Content-type': 'application/json' });
@@ -159,7 +146,7 @@ class VoddsHttpService {
159
146
  getFullUrl(url, param) {
160
147
  return `${url}?${param.toFormUrlEncoded()}`;
161
148
  }
162
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VoddsHttpService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
149
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VoddsHttpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
163
150
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VoddsHttpService, providedIn: 'root' }); }
164
151
  }
165
152
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VoddsHttpService, decorators: [{
@@ -167,26 +154,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
167
154
  args: [{
168
155
  providedIn: 'root',
169
156
  }]
170
- }], ctorParameters: () => [{ type: i1.HttpClient }] });
157
+ }] });
158
+
159
+ const ApiRoute = {
160
+ GET_DOMAIN: { url: "/payment/getDomain", method: "get" }
161
+ };
162
+
163
+ var PaymentType;
164
+ (function (PaymentType) {
165
+ PaymentType[PaymentType["NA"] = 0] = "NA";
166
+ PaymentType[PaymentType["JETON"] = 1] = "JETON";
167
+ PaymentType[PaymentType["ECOPAYZ"] = 2] = "ECOPAYZ";
168
+ PaymentType[PaymentType["RAPYD"] = 3] = "RAPYD";
169
+ })(PaymentType || (PaymentType = {}));
170
+
171
+ var IframeMessageType;
172
+ (function (IframeMessageType) {
173
+ IframeMessageType[IframeMessageType["OPEN_PAYMENT_FORM"] = 0] = "OPEN_PAYMENT_FORM";
174
+ IframeMessageType[IframeMessageType["PAYMENT_CALLBACK"] = 1] = "PAYMENT_CALLBACK";
175
+ IframeMessageType[IframeMessageType["THIRD_PARTY_CALLBACK"] = 2] = "THIRD_PARTY_CALLBACK";
176
+ })(IframeMessageType || (IframeMessageType = {}));
171
177
 
172
178
  class IframeMessageService {
173
- constructor(ngZone, http) {
179
+ constructor(ngZone) {
174
180
  this.ngZone = ngZone;
175
- this.http = http;
176
181
  this.messages$ = new Subject();
177
182
  this.thirdPartyMessages$ = new Subject();
183
+ this.http = inject(VoddsHttpService);
178
184
  this.listener = (event) => {
179
- // console.log("message: ", event);
185
+ if (event.data && event.data.target != "metamask-inpage") {
186
+ console.log("listener: ", event);
187
+ }
180
188
  if (!this.domain.allowedOrigins.includes(event.origin)) {
181
- console.log("listener not allow: ", event);
182
- if (this.domain.jetonDomain == event.origin) {
189
+ if (this.isValidDomain(PaymentType.NA, event.origin)) {
183
190
  this.ngZone.run(() => {
184
191
  this.thirdPartyMessages$.next(event);
185
192
  });
186
- return;
187
193
  }
188
194
  return;
189
195
  }
196
+ if (event.data && event.data.target == "metamask-inpage") {
197
+ return;
198
+ }
190
199
  if (event.data && IframeMessageType[event.data.type]) {
191
200
  this.ngZone.run(() => {
192
201
  this.messages$.next(event.data);
@@ -204,10 +213,10 @@ class IframeMessageService {
204
213
  });
205
214
  window.addEventListener('message', this.listener);
206
215
  }
207
- messages() {
216
+ onMessages() {
208
217
  return this.messages$.asObservable();
209
218
  }
210
- thirdPartyMessages() {
219
+ onThirdPartyMessages() {
211
220
  return this.thirdPartyMessages$.asObservable();
212
221
  }
213
222
  ngOnDestroy() {
@@ -215,12 +224,23 @@ class IframeMessageService {
215
224
  this.messages$.complete();
216
225
  this.thirdPartyMessages$.complete();
217
226
  }
227
+ /**
228
+ * Skip for RAPYD - It will process when the dialog close
229
+ */
218
230
  isValidDomain(paymentType, origin) {
219
- if (paymentType == null)
231
+ if (paymentType == undefined || paymentType == null)
220
232
  return false;
221
233
  switch (paymentType) {
222
234
  case PaymentType.JETON:
223
235
  return this.domain.jetonDomain == origin;
236
+ case PaymentType.ECOPAYZ:
237
+ return this.domain.ecopayzDomain == origin;
238
+ // case PaymentType.RAPYD:
239
+ // return this.domain.rapydDomain == origin;
240
+ case PaymentType.NA:
241
+ return this.domain.jetonDomain == origin
242
+ // || this.domain.rapydDomain == origin
243
+ || this.domain.ecopayzDomain == origin;
224
244
  default:
225
245
  return false;
226
246
  }
@@ -230,7 +250,7 @@ class IframeMessageService {
230
250
  return;
231
251
  iframe.nativeElement.contentWindow?.postMessage(message, window.location.origin);
232
252
  }
233
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: IframeMessageService, deps: [{ token: i0.NgZone }, { token: VoddsHttpService }], target: i0.ɵɵFactoryTarget.Injectable }); }
253
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: IframeMessageService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
234
254
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: IframeMessageService, providedIn: 'root' }); }
235
255
  }
236
256
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: IframeMessageService, decorators: [{
@@ -238,7 +258,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
238
258
  args: [{
239
259
  providedIn: 'root'
240
260
  }]
241
- }], ctorParameters: () => [{ type: i0.NgZone }, { type: VoddsHttpService }] });
261
+ }], ctorParameters: () => [{ type: i0.NgZone }] });
262
+
263
+ class CommonUtil {
264
+ static isMobileTemplate() {
265
+ const userAgent = navigator.userAgent || navigator.vendor || window.opera;
266
+ return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|Mobile/i.test(userAgent.toLowerCase());
267
+ }
268
+ }
269
+
270
+ class Checkout {
271
+ constructor() {
272
+ this.requestId = 0;
273
+ this.paymentType = PaymentType.NA;
274
+ this.url = '';
275
+ this.expiration = 300;
276
+ this.errorMessage = '';
277
+ this.successMessage = '';
278
+ }
279
+ setErrorMessage(errorMessage) {
280
+ this.errorMessage = errorMessage;
281
+ this.popup = undefined;
282
+ }
283
+ setCallback(callback) {
284
+ this.successMessage = 'success';
285
+ this.callback = callback;
286
+ this.popup = undefined;
287
+ }
288
+ }
289
+
290
+ class CountDownTime {
291
+ constructor(initTime) {
292
+ this.isStart = false;
293
+ this.isStop = false;
294
+ this.nextRound = false;
295
+ this.initTime = 0;
296
+ this.timeLeft = 0;
297
+ this.isCancel = false;
298
+ this.destroy$ = new Subject();
299
+ this.initTime = initTime;
300
+ }
301
+ start() {
302
+ this.isStart = true;
303
+ this.isStop = false;
304
+ this.timeLeft = this.initTime;
305
+ }
306
+ stop() {
307
+ this.isStart = false;
308
+ this.isStop = true;
309
+ this.timeLeft = 0;
310
+ this.nextRound = true;
311
+ }
312
+ downTime() {
313
+ this.timeLeft = this.timeLeft - 1;
314
+ }
315
+ cancel() {
316
+ this.isCancel = true;
317
+ this.stop();
318
+ }
319
+ oberserableTimer(isStop) {
320
+ timer(0, 1000)
321
+ .pipe(takeUntil(this.destroy$))
322
+ .subscribe(val => {
323
+ if (this.timeLeft === 0) {
324
+ if (this.isStart) {
325
+ this.stop();
326
+ }
327
+ }
328
+ else {
329
+ this.downTime();
330
+ }
331
+ if (this.nextRound) {
332
+ this.nextRound = false;
333
+ if (isStop) {
334
+ isStop.emit();
335
+ }
336
+ }
337
+ });
338
+ }
339
+ onDestroy() {
340
+ this.destroy$.next();
341
+ this.destroy$.complete();
342
+ }
343
+ }
344
+
345
+ class IParam {
346
+ getMobileFlag() {
347
+ return /android|mobi/i.test(navigator.userAgent.toLowerCase());
348
+ }
349
+ toJson() {
350
+ return JSON.stringify(this);
351
+ }
352
+ toFormUrlEncoded() {
353
+ return new URLSearchParams(Object.entries(this).map(([key, value]) => [key, String(value)])).toString();
354
+ }
355
+ }
242
356
 
243
357
  class Timer {
244
358
  constructor(interval, maxTime) {
@@ -253,9 +367,7 @@ class Timer {
253
367
  }
254
368
  oberserableTimer(data, callback) {
255
369
  this.popup = data.popup;
256
- console.log("investigate popup status begin: ", this.popup?.name, this.popup);
257
370
  this.popupTimer = setInterval(() => {
258
- console.log("investigate popup status: ", data);
259
371
  if ((this.maxTime > 0 && this.currentTime >= this.maxTime) || !data) {
260
372
  this.stopWatcher();
261
373
  // TODO Hit expire time
@@ -280,24 +392,275 @@ class Timer {
280
392
  }
281
393
  }
282
394
 
283
- class PaymentService {
395
+ class TranslocoPipe {
284
396
  constructor() {
397
+ this.transloco = inject(TranslocoService);
398
+ }
399
+ transform(key) {
400
+ return this.transloco.translate(key, {}, 'epp-lib');
401
+ // return this.transloco.selectTranslate(key, {}, 'epp-lib');
402
+ }
403
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TranslocoPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
404
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: TranslocoPipe, isStandalone: true, name: "vTransloco" }); }
405
+ }
406
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TranslocoPipe, decorators: [{
407
+ type: Pipe,
408
+ args: [{
409
+ name: 'vTransloco',
410
+ standalone: true
411
+ }]
412
+ }] });
413
+
414
+ class VoddsLoaderComponent {
415
+ constructor() {
416
+ this.message = '';
417
+ this.showAjaxLoader = false;
418
+ }
419
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VoddsLoaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
420
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: VoddsLoaderComponent, isStandalone: true, selector: "vodds-loader", inputs: { message: "message", showAjaxLoader: "showAjaxLoader" }, ngImport: i0, template: "@if (showAjaxLoader) {\r\n <div class=\"load-indicator\">\r\n <img src=\"https://cdn.voddos.net/vodds/static/ajax-loader16.gif\">\r\n {{message != undefined ? message : ''}}\r\n </div>\r\n}\r\n", styles: [""] }); }
421
+ }
422
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VoddsLoaderComponent, decorators: [{
423
+ type: Component,
424
+ args: [{ selector: 'vodds-loader', standalone: true, imports: [], template: "@if (showAjaxLoader) {\r\n <div class=\"load-indicator\">\r\n <img src=\"https://cdn.voddos.net/vodds/static/ajax-loader16.gif\">\r\n {{message != undefined ? message : ''}}\r\n </div>\r\n}\r\n" }]
425
+ }], propDecorators: { message: [{
426
+ type: Input
427
+ }], showAjaxLoader: [{
428
+ type: Input
429
+ }] } });
430
+
431
+ class RapydComponent {
432
+ constructor(dialogRef, data, translocoService) {
433
+ this.dialogRef = dialogRef;
434
+ this.data = data;
435
+ this.translocoService = translocoService;
436
+ this.isOpen = false;
437
+ this.checkoutToolKit = undefined;
438
+ this.visaMasterTimeout = 300;
439
+ this.visaMasterCheckoutId = '';
440
+ this.displayTimer = "00:00";
441
+ this.isShow = false;
442
+ this.isLoading = true;
443
+ this.errorMessage = "";
444
+ this.defaultExpirationSec = 300; // 5mins
445
+ this.checkoutFailureMessage = '';
446
+ this.handleLoading = (event) => {
447
+ if (!event.detail.loading && this.isLoading) {
448
+ this.isShow = true;
449
+ this.isLoading = false;
450
+ this.startTimer();
451
+ }
452
+ };
453
+ this.handleCheckoutPaymentSuccess = (event) => {
454
+ this.closeDialog(false);
455
+ };
456
+ this.handleCheckoutPaymentFailure = (event) => {
457
+ this.stopTimer();
458
+ this.isShow = false;
459
+ this.checkoutFailureMessage = event.detail.message;
460
+ };
461
+ this.visaMasterTimeout = data.expiration ?? data.expiration;
462
+ this.visaMasterCheckoutId = data.checkoutUrl;
463
+ }
464
+ ngOnDestroy() {
465
+ this.stopTimer();
466
+ window.removeEventListener('onLoading', this.handleLoading);
467
+ window.removeEventListener('onCheckoutPaymentSuccess', this.handleCheckoutPaymentSuccess);
468
+ window.removeEventListener('onCheckoutPaymentFailure', this.handleCheckoutPaymentFailure);
469
+ }
470
+ ngAfterViewInit() {
471
+ if (this.checkout) {
472
+ this.visaMasterTimeout = this.checkout.expiration;
473
+ this.visaMasterCheckoutId = this.checkout.url;
474
+ }
475
+ this.translocoService.selectTranslate('mobile_payment_form_title').subscribe(buttonText => {
476
+ console.log('Async translations loaded:', buttonText);
477
+ this.checkoutToolKit = this.isMobile() ? this.createCheckoutToolKitOnMobile(buttonText) : this.createCheckoutToolKitOnDesktop(buttonText);
478
+ this.displayCheckout();
479
+ window.addEventListener('onLoading', this.handleLoading);
480
+ window.addEventListener('onCheckoutPaymentSuccess', this.handleCheckoutPaymentSuccess);
481
+ window.addEventListener('onCheckoutPaymentFailure', this.handleCheckoutPaymentFailure);
482
+ });
483
+ }
484
+ createCheckoutToolKitOnDesktop(buttonText) {
485
+ return new RapydCheckoutToolkit({
486
+ pay_button_text: buttonText,
487
+ id: this.visaMasterCheckoutId,
488
+ wait_on_payment_redirect: true,
489
+ style: {
490
+ cardFields: {
491
+ title: {
492
+ color: '#80807F'
493
+ },
494
+ saveForFutureLabel: {
495
+ color: '#80807F'
496
+ }
497
+ },
498
+ input: {
499
+ base: {
500
+ fontWeight: "400",
501
+ borderRadius: "5px",
502
+ }
503
+ },
504
+ orderDetails: {
505
+ title: {
506
+ color: '#80807F'
507
+ },
508
+ totalLabel: {
509
+ color: '#80807F'
510
+ },
511
+ totalValue: {
512
+ color: '#80807F'
513
+ }
514
+ },
515
+ submit: {
516
+ base: {
517
+ backgroundColor: "#F48215",
518
+ color: "#FFFFFF",
519
+ fontWeight: "900",
520
+ borderRadius: "5px",
521
+ border: "none",
522
+ boxShadow: "0px 0px 20px 0px #28303A33",
523
+ height: "35px",
524
+ }
525
+ }
526
+ }
527
+ });
528
+ }
529
+ createCheckoutToolKitOnMobile(buttonText) {
530
+ return new RapydCheckoutToolkit({
531
+ pay_button_text: buttonText,
532
+ id: this.visaMasterCheckoutId,
533
+ wait_on_payment_redirect: true,
534
+ style: {
535
+ input: {
536
+ base: {
537
+ fontWeight: "400",
538
+ borderRadius: "5px",
539
+ fontSize: "12px"
540
+ },
541
+ placeholder: {
542
+ fontSize: "12px !important",
543
+ fontWeight: "700",
544
+ fontFamily: "Manrope",
545
+ color: '#8C8C8C',
546
+ },
547
+ },
548
+ cardFields: {
549
+ title: {
550
+ color: '#8C8C8C'
551
+ },
552
+ saveForFutureLabel: {
553
+ color: '#8C8C8C',
554
+ }
555
+ },
556
+ orderDetails: {
557
+ title: {
558
+ color: '#8C8C8C',
559
+ },
560
+ totalLabel: {
561
+ color: '#8C8C8C',
562
+ },
563
+ totalValue: {
564
+ color: '#8C8C8C',
565
+ }
566
+ },
567
+ submit: {
568
+ base: {
569
+ backgroundColor: "#28303A",
570
+ color: "#FFFFFF",
571
+ fontWeight: "900 !important",
572
+ borderRadius: "12px",
573
+ boxShadow: "0 0 8.57px #ff6b0066 !important",
574
+ height: "40px",
575
+ width: "100%",
576
+ fontSize: "12px !important",
577
+ border: "none"
578
+ }
579
+ }
580
+ }
581
+ });
582
+ }
583
+ closeDialog(isCloseCheckout = true) {
584
+ this.stopTimer();
585
+ if (this.checkoutToolKit && isCloseCheckout) {
586
+ try {
587
+ this.checkoutToolKit.closeCheckout();
588
+ }
589
+ catch (err) {
590
+ console.error("Error when closing checkout", err);
591
+ }
592
+ }
593
+ this.checkoutToolKit = undefined;
594
+ this.isShow = false;
595
+ this.dialogRef.close(this.checkoutFailureMessage);
596
+ }
597
+ ;
598
+ startTimer() {
599
+ if (this.visaMasterTimer)
600
+ this.stopTimer();
601
+ this.visaMasterTimer = setInterval(() => {
602
+ if (this.visaMasterTimeout <= 0) {
603
+ this.closeDialog();
604
+ return;
605
+ }
606
+ this.visaMasterTimeout--;
607
+ this.displayTimer = `${this.pad(Math.floor(this.visaMasterTimeout / 60))}:${this.pad(this.visaMasterTimeout % 60)}`;
608
+ }, 1000);
609
+ }
610
+ stopTimer() {
611
+ clearInterval(this.visaMasterTimer);
612
+ }
613
+ pad(number) {
614
+ return `${number < 10 ? '0' : ''}${number}`;
615
+ }
616
+ displayCheckout() {
617
+ if (document.getElementById("rapyd-checkout")) {
618
+ this.checkoutToolKit.displayCheckout();
619
+ }
620
+ else {
621
+ setTimeout(() => {
622
+ this.displayCheckout();
623
+ }, 10);
624
+ }
625
+ }
626
+ isMobile() {
627
+ return true;
628
+ // return CommonUtil.isMobileTemplate();
629
+ }
630
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: RapydComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }, { token: i2.TranslocoService }], target: i0.ɵɵFactoryTarget.Component }); }
631
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: RapydComponent, isStandalone: true, selector: "v-rapyd", inputs: { checkout: "checkout" }, ngImport: i0, template: "@if(isMobile()) {\r\n <div class=\"v-dialog mobile\">\r\n <div class=\"v-flex-center-between header text-black-cs\">\r\n <div class=\"v-flex-center-none\">\r\n <span class=\"ml-8\">{{ 'mobile_payment_form_title' | transloco }}</span>\r\n </div>\r\n <div class=\"v-flex-center-between mr-8\">\r\n <div (click)=\"closeDialog()\">\r\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\r\n d=\"M11.0121 12.3959L16.6455 18.0293C16.8333 18.2107 17.0849 18.3111 17.346 18.3088C17.6071 18.3065 17.8569 18.2018 18.0415 18.0172C18.2261 17.8325 18.3309 17.5828 18.3331 17.3217C18.3354 17.0606 18.235 16.809 18.0536 16.6212L12.4202 10.9878L18.0536 5.35431C18.235 5.16649 18.3354 4.91494 18.3331 4.65384C18.3309 4.39273 18.2261 4.14297 18.0415 3.95833C17.8569 3.77369 17.6071 3.66896 17.346 3.66669C17.0849 3.66443 16.8333 3.7648 16.6455 3.9462L11.0121 9.57964L5.37863 3.9462C5.18997 3.76928 4.93988 3.67271 4.68128 3.67691C4.42268 3.68111 4.17585 3.78575 3.99304 3.9687C3.81022 4.15165 3.70575 4.39854 3.70173 4.65715C3.69772 4.91575 3.79447 5.16577 3.97152 5.35431L9.60396 10.9878L3.97052 16.6212C3.87541 16.7131 3.79954 16.8229 3.74735 16.9444C3.69516 17.0659 3.66769 17.1966 3.66654 17.3288C3.66539 17.4611 3.69059 17.5922 3.74066 17.7146C3.79073 17.837 3.86468 17.9481 3.95818 18.0416C4.05168 18.1352 4.16287 18.2091 4.28525 18.2592C4.40764 18.3092 4.53877 18.3344 4.67099 18.3333C4.80322 18.3321 4.93389 18.3047 5.05539 18.2525C5.17688 18.2003 5.28677 18.1244 5.37863 18.0293L11.0121 12.3959Z\" />\r\n </svg>\r\n </div>\r\n </div>\r\n </div>\r\n @if (isLoading) {\r\n <div class=\"v-spinner\">\r\n <mat-spinner diameter=\"50\" strokeWidth=\"4\"></mat-spinner>\r\n </div>\r\n }\r\n <div class=\"v-content\" id=\"deposit-id\">\r\n @if (!isLoading && !isShow) {\r\n <div class=\"visa-card-message\">\r\n {{ 'visaCardErrorMessage' | transloco }} <br> {{ 'visaCardErrorMessage2' | transloco }}\r\n </div>\r\n }\r\n <div class=\"vodds-checkout-deposit\">\r\n @if(!isLoading && isShow) {\r\n <div class=\"vodds-checkout-expiration\">\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 15\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M7 2.56067C9.76142 2.56067 12 4.79925 12 7.56067C12 10.3221 9.76142 12.5607 7 12.5607C4.23858 12.5607 2 10.3221 2 7.56067C2 4.79925 4.23858 2.56067 7 2.56067ZM6.25 4.06067V7.93567L6.5498 8.16028L8.5498 9.66028L9.4502 8.46106L7.75 7.18567V4.06067H6.25Z\"\r\n fill=\"#8C8C8C\" />\r\n <line x1=\"10.0303\" y1=\"0.530339\" x2=\"12.8588\" y2=\"3.35877\" stroke=\"#8C8C8C\" stroke-width=\"1.5\" />\r\n <line y1=\"-0.75\" x2=\"4\" y2=\"-0.75\" transform=\"matrix(-0.707107 0.707107 0.707107 0.707107 4.82843 1.06067)\"\r\n stroke=\"#8C8C8C\" stroke-width=\"1.5\" />\r\n </svg>\r\n <span>{{ 'visaCardTimeout' | transloco }} <span class=\"countdown-timer\">{{displayTimer}}</span></span>\r\n </div>\r\n }\r\n <div id=\"rapyd-checkout\" class=\"iframe-wrapper\"></div>\r\n </div>\r\n </div>\r\n </div>\r\n} @else {\r\n <div id=\"visa-card\">\r\n <div class=\"top\">\r\n <h2>{{ 'payment_form_title' | transloco }}</h2>\r\n <svg class=\"clsbtn my-account\" (click)=\"closeDialog()\" width=\"11\" height=\"11\" viewBox=\"0 0 11 11\" fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M9.89214 0L5.5 4.39214L1.10786 0L0 1.10786L4.39214 5.5L0 9.89214L1.10786 11L5.5 6.60786L9.89214 11L11 9.89214L6.60786 5.5L11 1.10786L9.89214 0Z\"\r\n fill=\"white\" />\r\n </svg>\r\n </div>\r\n <div class=\"flex-center\">\r\n <vodds-loader [showAjaxLoader]=\"isLoading\"></vodds-loader>\r\n </div>\r\n @if (!isLoading && !isShow) {\r\n <div class=\"visa-card-message\">\r\n {{ 'visaCardErrorMessage' | transloco }} <br> {{ 'visaCardErrorMessage2' | transloco }}\r\n </div>\r\n }\r\n <div class=\"visa-card-form\" [style]=\"{display: isShow ? 'flex' : 'none'}\">\r\n <div class=\"timer\">\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M7 2.56067C9.76142 2.56067 12 4.79925 12 7.56067C12 10.3221 9.76142 12.5607 7 12.5607C4.23858 12.5607 2 10.3221 2 7.56067C2 4.79925 4.23858 2.56067 7 2.56067ZM6.25 4.06067V7.93567L6.5498 8.16028L8.5498 9.66028L9.4502 8.46106L7.75 7.18567V4.06067H6.25Z\"\r\n fill=\"#B5B5B5\" />\r\n <line x1=\"10.0303\" y1=\"0.530339\" x2=\"12.8588\" y2=\"3.35877\" stroke=\"#B5B5B5\" stroke-width=\"1.5\" />\r\n <line y1=\"-0.75\" x2=\"4\" y2=\"-0.75\"\r\n transform=\"matrix(-0.707107 0.707107 0.707107 0.707107 4.82861 1.06067)\" stroke=\"#B5B5B5\"\r\n stroke-width=\"1.5\" />\r\n </svg>\r\n <span class=\"label\">&nbsp;{{ 'visaCardTimeout' | transloco }}&nbsp;</span> <span class=\"display-time\">\r\n {{displayTimer}}</span>\r\n </div>\r\n <div id=\"rapyd-checkout\"></div>\r\n </div>\r\n </div>\r\n}", styles: [".flex-center{display:flex;justify-content:center;align-items:center}#visa-card{height:auto;width:500px;top:0;left:710px;z-index:101}.top{width:100%;align-items:center;margin-bottom:8px;border-radius:0;background:#dd453c;position:relative;color:#fff;display:flex;justify-content:space-between}.top h2{padding-left:15px;text-align:left;font-size:16px;font-weight:800}.top svg{position:unset;padding-right:15px;width:18px;height:18px}.visa-card-form{display:flex;flex-direction:column;align-items:center;min-height:500px!important;width:100%}.visa-card-form .timer{display:flex;align-items:center}#rapyd-checkout{min-height:550px;max-height:550px;overflow-y:auto;scrollbar-width:none}#rapyd-checkout::-webkit-scrollbar{display:none}.ui-widget.ui-widget-content.vodds-visa-card-dialog{padding:0;border:none;border-radius:10px}.vodds-visa-card-dialog .ui-dialog-content{display:flex;align-items:center;flex-direction:column;padding:0;margin:0}.vodds-visa-card-dialog .ui-dialog-content .top{width:100%;display:flex;align-items:center;padding:6px 18px;margin-bottom:8px;border-radius:8px}.vodds-visa-card-dialog .ui-dialog-content .top h2{text-align:left;font-size:16px;font-weight:800}#trading-platform.dark .vodds-visa-card-dialog .label,.vodds-visa-card-dialog .label{color:#80807f!important}#trading-platform.dark .vodds-visa-card-dialog span{color:#000!important}#trading-platform.dark .vodds-visa-card-dialog{background:#fff!important}.mobile .header{font-weight:800;font-size:18px;line-height:18px;margin:0 7px;border-bottom:1px solid #96A2B3;padding:20px 0 15px}.mobile .header .dark{color:#fff}.mobile .header .light{color:#2c3644}.mobile .header svg{fill:#2c3644}.mobile .v-flex-center-between{display:flex;justify-content:space-between;align-items:center;padding-left:10px;padding-right:10px}.mobile .vodds-checkout-expiration{display:flex;justify-content:center;align-items:center;font-weight:700;gap:5px;color:#8c8c8c;font-size:12px}.mobile .countdown-timer{color:#000}.mobile .iframe-wrapper{position:relative;overflow:hidden}.mobile .v-dialog .v-content{padding:0!important;max-height:74vh}.mobile .vodds-checkout-deposit{overflow:auto;margin-top:10px}.mobile .v-dialog{background:#f3f2f9;color:#28303a}.mobile .v-spinner{display:flex;justify-content:center;width:100%}.mobile ::ng-deep .mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic{stroke:#dd443c!important}.mobile .visa-card-message{margin:28px 20px;color:#dd453c;font-size:14px}.mobile .v-dialog .v-content{background-color:#f1f1f1}\n"], dependencies: [{ kind: "component", type: VoddsLoaderComponent, selector: "vodds-loader", inputs: ["message", "showAjaxLoader"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i3.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i2.TranslocoPipe, name: "transloco" }] }); }
632
+ }
633
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: RapydComponent, decorators: [{
634
+ type: Component,
635
+ args: [{ selector: 'v-rapyd', standalone: true, imports: [NgStyle, VoddsLoaderComponent, MatDialogModule, MatProgressSpinnerModule, TranslocoModule], template: "@if(isMobile()) {\r\n <div class=\"v-dialog mobile\">\r\n <div class=\"v-flex-center-between header text-black-cs\">\r\n <div class=\"v-flex-center-none\">\r\n <span class=\"ml-8\">{{ 'mobile_payment_form_title' | transloco }}</span>\r\n </div>\r\n <div class=\"v-flex-center-between mr-8\">\r\n <div (click)=\"closeDialog()\">\r\n <svg width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\r\n d=\"M11.0121 12.3959L16.6455 18.0293C16.8333 18.2107 17.0849 18.3111 17.346 18.3088C17.6071 18.3065 17.8569 18.2018 18.0415 18.0172C18.2261 17.8325 18.3309 17.5828 18.3331 17.3217C18.3354 17.0606 18.235 16.809 18.0536 16.6212L12.4202 10.9878L18.0536 5.35431C18.235 5.16649 18.3354 4.91494 18.3331 4.65384C18.3309 4.39273 18.2261 4.14297 18.0415 3.95833C17.8569 3.77369 17.6071 3.66896 17.346 3.66669C17.0849 3.66443 16.8333 3.7648 16.6455 3.9462L11.0121 9.57964L5.37863 3.9462C5.18997 3.76928 4.93988 3.67271 4.68128 3.67691C4.42268 3.68111 4.17585 3.78575 3.99304 3.9687C3.81022 4.15165 3.70575 4.39854 3.70173 4.65715C3.69772 4.91575 3.79447 5.16577 3.97152 5.35431L9.60396 10.9878L3.97052 16.6212C3.87541 16.7131 3.79954 16.8229 3.74735 16.9444C3.69516 17.0659 3.66769 17.1966 3.66654 17.3288C3.66539 17.4611 3.69059 17.5922 3.74066 17.7146C3.79073 17.837 3.86468 17.9481 3.95818 18.0416C4.05168 18.1352 4.16287 18.2091 4.28525 18.2592C4.40764 18.3092 4.53877 18.3344 4.67099 18.3333C4.80322 18.3321 4.93389 18.3047 5.05539 18.2525C5.17688 18.2003 5.28677 18.1244 5.37863 18.0293L11.0121 12.3959Z\" />\r\n </svg>\r\n </div>\r\n </div>\r\n </div>\r\n @if (isLoading) {\r\n <div class=\"v-spinner\">\r\n <mat-spinner diameter=\"50\" strokeWidth=\"4\"></mat-spinner>\r\n </div>\r\n }\r\n <div class=\"v-content\" id=\"deposit-id\">\r\n @if (!isLoading && !isShow) {\r\n <div class=\"visa-card-message\">\r\n {{ 'visaCardErrorMessage' | transloco }} <br> {{ 'visaCardErrorMessage2' | transloco }}\r\n </div>\r\n }\r\n <div class=\"vodds-checkout-deposit\">\r\n @if(!isLoading && isShow) {\r\n <div class=\"vodds-checkout-expiration\">\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 15\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M7 2.56067C9.76142 2.56067 12 4.79925 12 7.56067C12 10.3221 9.76142 12.5607 7 12.5607C4.23858 12.5607 2 10.3221 2 7.56067C2 4.79925 4.23858 2.56067 7 2.56067ZM6.25 4.06067V7.93567L6.5498 8.16028L8.5498 9.66028L9.4502 8.46106L7.75 7.18567V4.06067H6.25Z\"\r\n fill=\"#8C8C8C\" />\r\n <line x1=\"10.0303\" y1=\"0.530339\" x2=\"12.8588\" y2=\"3.35877\" stroke=\"#8C8C8C\" stroke-width=\"1.5\" />\r\n <line y1=\"-0.75\" x2=\"4\" y2=\"-0.75\" transform=\"matrix(-0.707107 0.707107 0.707107 0.707107 4.82843 1.06067)\"\r\n stroke=\"#8C8C8C\" stroke-width=\"1.5\" />\r\n </svg>\r\n <span>{{ 'visaCardTimeout' | transloco }} <span class=\"countdown-timer\">{{displayTimer}}</span></span>\r\n </div>\r\n }\r\n <div id=\"rapyd-checkout\" class=\"iframe-wrapper\"></div>\r\n </div>\r\n </div>\r\n </div>\r\n} @else {\r\n <div id=\"visa-card\">\r\n <div class=\"top\">\r\n <h2>{{ 'payment_form_title' | transloco }}</h2>\r\n <svg class=\"clsbtn my-account\" (click)=\"closeDialog()\" width=\"11\" height=\"11\" viewBox=\"0 0 11 11\" fill=\"none\"\r\n xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M9.89214 0L5.5 4.39214L1.10786 0L0 1.10786L4.39214 5.5L0 9.89214L1.10786 11L5.5 6.60786L9.89214 11L11 9.89214L6.60786 5.5L11 1.10786L9.89214 0Z\"\r\n fill=\"white\" />\r\n </svg>\r\n </div>\r\n <div class=\"flex-center\">\r\n <vodds-loader [showAjaxLoader]=\"isLoading\"></vodds-loader>\r\n </div>\r\n @if (!isLoading && !isShow) {\r\n <div class=\"visa-card-message\">\r\n {{ 'visaCardErrorMessage' | transloco }} <br> {{ 'visaCardErrorMessage2' | transloco }}\r\n </div>\r\n }\r\n <div class=\"visa-card-form\" [style]=\"{display: isShow ? 'flex' : 'none'}\">\r\n <div class=\"timer\">\r\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path\r\n d=\"M7 2.56067C9.76142 2.56067 12 4.79925 12 7.56067C12 10.3221 9.76142 12.5607 7 12.5607C4.23858 12.5607 2 10.3221 2 7.56067C2 4.79925 4.23858 2.56067 7 2.56067ZM6.25 4.06067V7.93567L6.5498 8.16028L8.5498 9.66028L9.4502 8.46106L7.75 7.18567V4.06067H6.25Z\"\r\n fill=\"#B5B5B5\" />\r\n <line x1=\"10.0303\" y1=\"0.530339\" x2=\"12.8588\" y2=\"3.35877\" stroke=\"#B5B5B5\" stroke-width=\"1.5\" />\r\n <line y1=\"-0.75\" x2=\"4\" y2=\"-0.75\"\r\n transform=\"matrix(-0.707107 0.707107 0.707107 0.707107 4.82861 1.06067)\" stroke=\"#B5B5B5\"\r\n stroke-width=\"1.5\" />\r\n </svg>\r\n <span class=\"label\">&nbsp;{{ 'visaCardTimeout' | transloco }}&nbsp;</span> <span class=\"display-time\">\r\n {{displayTimer}}</span>\r\n </div>\r\n <div id=\"rapyd-checkout\"></div>\r\n </div>\r\n </div>\r\n}", styles: [".flex-center{display:flex;justify-content:center;align-items:center}#visa-card{height:auto;width:500px;top:0;left:710px;z-index:101}.top{width:100%;align-items:center;margin-bottom:8px;border-radius:0;background:#dd453c;position:relative;color:#fff;display:flex;justify-content:space-between}.top h2{padding-left:15px;text-align:left;font-size:16px;font-weight:800}.top svg{position:unset;padding-right:15px;width:18px;height:18px}.visa-card-form{display:flex;flex-direction:column;align-items:center;min-height:500px!important;width:100%}.visa-card-form .timer{display:flex;align-items:center}#rapyd-checkout{min-height:550px;max-height:550px;overflow-y:auto;scrollbar-width:none}#rapyd-checkout::-webkit-scrollbar{display:none}.ui-widget.ui-widget-content.vodds-visa-card-dialog{padding:0;border:none;border-radius:10px}.vodds-visa-card-dialog .ui-dialog-content{display:flex;align-items:center;flex-direction:column;padding:0;margin:0}.vodds-visa-card-dialog .ui-dialog-content .top{width:100%;display:flex;align-items:center;padding:6px 18px;margin-bottom:8px;border-radius:8px}.vodds-visa-card-dialog .ui-dialog-content .top h2{text-align:left;font-size:16px;font-weight:800}#trading-platform.dark .vodds-visa-card-dialog .label,.vodds-visa-card-dialog .label{color:#80807f!important}#trading-platform.dark .vodds-visa-card-dialog span{color:#000!important}#trading-platform.dark .vodds-visa-card-dialog{background:#fff!important}.mobile .header{font-weight:800;font-size:18px;line-height:18px;margin:0 7px;border-bottom:1px solid #96A2B3;padding:20px 0 15px}.mobile .header .dark{color:#fff}.mobile .header .light{color:#2c3644}.mobile .header svg{fill:#2c3644}.mobile .v-flex-center-between{display:flex;justify-content:space-between;align-items:center;padding-left:10px;padding-right:10px}.mobile .vodds-checkout-expiration{display:flex;justify-content:center;align-items:center;font-weight:700;gap:5px;color:#8c8c8c;font-size:12px}.mobile .countdown-timer{color:#000}.mobile .iframe-wrapper{position:relative;overflow:hidden}.mobile .v-dialog .v-content{padding:0!important;max-height:74vh}.mobile .vodds-checkout-deposit{overflow:auto;margin-top:10px}.mobile .v-dialog{background:#f3f2f9;color:#28303a}.mobile .v-spinner{display:flex;justify-content:center;width:100%}.mobile ::ng-deep .mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic{stroke:#dd443c!important}.mobile .visa-card-message{margin:28px 20px;color:#dd453c;font-size:14px}.mobile .v-dialog .v-content{background-color:#f1f1f1}\n"] }]
636
+ }], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
637
+ type: Inject,
638
+ args: [MAT_DIALOG_DATA]
639
+ }] }, { type: i2.TranslocoService }], propDecorators: { checkout: [{
640
+ type: Input
641
+ }] } });
642
+
643
+ class Payment {
644
+ constructor(dialog) {
645
+ this.dialog = dialog;
285
646
  this.cache = new Map();
286
647
  this.timer = new Timer(500); // 0.5s
287
648
  this.iframeMessageService = inject(IframeMessageService);
649
+ this.rapydScriptLoaded = false;
288
650
  /**
289
651
  * Listen OPEN_PAYMENT_FORM message to open 3th party page
290
652
  */
291
- this.iframeMessageService.messages().subscribe(message => {
653
+ this.iframeMessageService.onMessages().subscribe(message => {
292
654
  console.log('Received from iframe:', message);
293
655
  if (IframeMessageType.OPEN_PAYMENT_FORM == message.type) {
294
656
  const checkout = Object.assign(new Checkout(), message.payload);
295
- if (!checkout || this.cache.get(checkout.requestId))
657
+ if (!checkout || this.cache.get(checkout.requestId)) {
296
658
  return;
297
- if (this.cache.size > 0) {
298
- this.cache.clear();
299
- //TODO clear the current popup
300
659
  }
660
+ // if (this.cache.size > 0) {
661
+ // this.cache.clear();
662
+ // //TODO clear the current popup
663
+ // }
301
664
  switch (checkout.paymentType) {
302
665
  case PaymentType.JETON:
303
666
  case PaymentType.ECOPAYZ:
@@ -309,8 +672,11 @@ class PaymentService {
309
672
  default:
310
673
  }
311
674
  }
312
- if (IframeMessageType.PAYMENT_CALLBACK == message.type) {
313
- this.result = Object.assign(new Checkout(), message.payload);
675
+ if (IframeMessageType.THIRD_PARTY_CALLBACK == message.type) {
676
+ let checkout = new Checkout();
677
+ checkout.setCallback(message.payload);
678
+ this.timer.stopWatcher();
679
+ this.sendMessageToIframe(checkout);
314
680
  }
315
681
  });
316
682
  }
@@ -318,46 +684,86 @@ class PaymentService {
318
684
  * Open 3th party page on the popup windown or new tab
319
685
  */
320
686
  openWindow(checkout) {
687
+ this.cache.set(checkout.requestId, checkout);
321
688
  console.log("Open windown: ", this.cache);
322
689
  const width = 470;
323
690
  const height = 550;
324
- // var left = Math.max(0, (screen.width - width) / 2) + (screen.availLeft | 0),
325
- // top = Math.max(0, (screen.height - height) / 2) + (screen.availTop | 0);
691
+ var left = Math.max(0, (screen.width - width) / 2), top = Math.max(0, (screen.height - height) / 2);
326
692
  // var popup = window.open(url, "VOdds", 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',status=0,location=0,menubar=0,toolbar=0');
327
- const popup = window.open(checkout.url, 'VOdds', 'width=' + width + ',height=' + height + ',status=0,location=0,menubar=0,toolbar=0');
693
+ let popup = window.open(checkout.url, "VOdds", 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',status=0,location=0,menubar=0,toolbar=0');
328
694
  if (!popup) {
329
695
  checkout.errorMessage = 'Your setting prevents popups. Please change your setting to allow it.';
330
696
  this.sendMessageToIframe(checkout);
697
+ this.cache.delete(checkout.requestId);
331
698
  return;
332
699
  }
333
700
  checkout.popup = popup;
334
- window.addEventListener("beforeunload", () => {
335
- window.opener?.postMessage({ type: "vodds-popup-closing12" }, window.location.origin);
336
- });
337
- popup.postMessage({ type: "vodds-popup-closing" }, window.location.origin);
338
- this.cache.set(checkout.requestId, checkout);
339
701
  popup.focus();
340
- this.onThirdPartyPopupClose(checkout);
702
+ this.onThirdPartyMessage(checkout);
703
+ this.timer.oberserableTimer(checkout, () => this.sendMessageToIframe(checkout));
704
+ }
705
+ async openVisaCheckout(checkout) {
706
+ try {
707
+ await this.load();
708
+ this.dialog.open(RapydComponent, {
709
+ data: {
710
+ checkoutUrl: checkout.url,
711
+ expiration: checkout.expiration
712
+ },
713
+ width: '500px',
714
+ maxWidth: '90vw'
715
+ }).afterClosed().subscribe(checkoutFailureMessage => {
716
+ checkout.errorMessage = checkoutFailureMessage;
717
+ this.sendMessageToIframe(checkout);
718
+ });
719
+ }
720
+ catch (error) {
721
+ console.error(error);
722
+ }
723
+ }
724
+ load() {
725
+ if (this.rapydScriptLoaded) {
726
+ return Promise.resolve();
727
+ }
728
+ return new Promise((resolve, reject) => {
729
+ const script = document.createElement('script');
730
+ script.src = 'https://sandboxcheckouttoolkit.rapyd.net';
731
+ script.async = true;
732
+ script.onload = () => {
733
+ this.rapydScriptLoaded = true;
734
+ resolve();
735
+ };
736
+ script.onerror = () => {
737
+ reject(new Error('Failed to load Rapyd Checkout Toolkit'));
738
+ };
739
+ document.head.appendChild(script);
740
+ });
341
741
  }
342
742
  /**
343
743
  * Listen message or action from 3th party on the popup
744
+ * Skip for RAPYD - It will process when the dialog close
344
745
  */
345
- onThirdPartyPopupClose(checkout) {
346
- this.iframeMessageService.thirdPartyMessages().subscribe(event => {
746
+ onThirdPartyMessage(checkout) {
747
+ this.iframeMessageService.onThirdPartyMessages().subscribe(event => {
347
748
  if (this.iframeMessageService.isValidDomain(checkout.paymentType, event.origin)) {
749
+ switch (checkout.paymentType) {
750
+ case PaymentType.NA:
751
+ break;
752
+ case PaymentType.JETON:
753
+ case PaymentType.ECOPAYZ:
754
+ }
348
755
  console.log('Received from 3th party:', event.data);
349
756
  checkout.setCallback(event.data);
350
757
  this.timer.stopWatcher();
351
758
  this.sendMessageToIframe(checkout);
352
759
  }
353
760
  });
354
- this.timer.oberserableTimer(checkout, () => this.sendMessageToIframe(checkout));
355
761
  }
356
762
  /**
357
763
  * send the message from the parent to the iframe
358
764
  */
359
765
  sendMessageToIframe(checkout) {
360
- console.log("send message to iframe");
766
+ console.log("send message to iframe: ", checkout);
361
767
  if (this.iframe == undefined)
362
768
  return;
363
769
  let message = {
@@ -365,23 +771,17 @@ class PaymentService {
365
771
  payload: checkout
366
772
  };
367
773
  this.iframeMessageService.sendMessageToIframe(this.iframe, message);
368
- }
369
- // removePaymentIframe() {
370
- // //TODO
371
- // this.iframe = undefined;
372
- // }
373
- async openVisaCheckout(checkout) {
774
+ this.cache.delete(checkout.requestId);
374
775
  }
375
776
  }
376
777
 
377
778
  /*
378
779
  * Public API Surface of epp-lib
379
780
  */
380
- // Models
381
781
 
382
782
  /**
383
783
  * Generated bundle index. Do not edit.
384
784
  */
385
785
 
386
- export { ApiRoute, BaseForm, CallbackMessage, Checkout, Domain, IParam, IframeMessageService, IframeMessageType, PaymentService, PaymentType, VoddsHttpService };
786
+ export { Checkout, CommonUtil, CountDownTime, Domain, EppLibLoader, EppLibTranslationService, EventEmitterService, IParam, IframeMessageService, IframeMessageType, Payment, PaymentType, RapydComponent, Timer, TranslocoPipe, VoddsHttpService, VoddsLoaderComponent, provideEppLibTranslations };
387
787
  //# sourceMappingURL=epp-lib.mjs.map