@croeminc/croem-card-widget 0.6.0-beta.2
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.
- package/Constants.d.ts +8 -0
- package/README.md +125 -0
- package/esm2020/Constants.mjs +9 -0
- package/esm2020/croeminc-croem-card-widget.mjs +5 -0
- package/esm2020/lib/card-widget/Add-card-widget/add-card-widget/add-card-widget.component.mjs +195 -0
- package/esm2020/lib/card-widget/Pay-card-widget/payment-card-widget/payment-card-widget.component.mjs +149 -0
- package/esm2020/lib/card-widget/Update-card-widget/update-card-widget/update-card-widget.component.mjs +267 -0
- package/esm2020/lib/croem-card-widget.component.mjs +77 -0
- package/esm2020/lib/croem-card-widget.module.mjs +48 -0
- package/esm2020/lib/croem-card-widget.service.mjs +62 -0
- package/esm2020/lib/dynamic-form-builder/dynamic-form-fields/dropdown.mjs +32 -0
- package/esm2020/lib/dynamic-form-builder/dynamic-form-fields/textbox.mjs +21 -0
- package/esm2020/lib/dynamic-form-builder/field-builder.component.mjs +24 -0
- package/esm2020/lib/dynamic-form-builder/interfaces/CardModeEnum.mjs +7 -0
- package/esm2020/lib/dynamic-form-builder/interfaces/FormFields.Interface.mjs +2 -0
- package/esm2020/lib/dynamic-form-builder/interfaces/InputParams.Interface.mjs +2 -0
- package/esm2020/lib/dynamic-form-builder/interfaces/apiResponse.Interface.mjs +2 -0
- package/esm2020/lib/localizations/en.mjs +16 -0
- package/esm2020/lib/localizations/es.mjs +16 -0
- package/esm2020/lib/localizations/language.interface.mjs +2 -0
- package/esm2020/public-api.mjs +11 -0
- package/fesm2015/croeminc-croem-card-widget.mjs +876 -0
- package/fesm2015/croeminc-croem-card-widget.mjs.map +1 -0
- package/fesm2020/croeminc-croem-card-widget.mjs +868 -0
- package/fesm2020/croeminc-croem-card-widget.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/card-widget/Add-card-widget/add-card-widget/add-card-widget.component.d.ts +61 -0
- package/lib/card-widget/Pay-card-widget/payment-card-widget/payment-card-widget.component.d.ts +43 -0
- package/lib/card-widget/Update-card-widget/update-card-widget/update-card-widget.component.d.ts +64 -0
- package/lib/croem-card-widget.component.d.ts +49 -0
- package/lib/croem-card-widget.module.d.ts +16 -0
- package/lib/croem-card-widget.service.d.ts +11 -0
- package/lib/dynamic-form-builder/dynamic-form-fields/dropdown.d.ts +19 -0
- package/lib/dynamic-form-builder/dynamic-form-fields/textbox.d.ts +12 -0
- package/lib/dynamic-form-builder/field-builder.component.d.ts +14 -0
- package/lib/dynamic-form-builder/interfaces/CardModeEnum.d.ts +5 -0
- package/lib/dynamic-form-builder/interfaces/FormFields.Interface.d.ts +14 -0
- package/lib/dynamic-form-builder/interfaces/InputParams.Interface.d.ts +17 -0
- package/lib/dynamic-form-builder/interfaces/apiResponse.Interface.d.ts +24 -0
- package/lib/localizations/en.d.ts +2 -0
- package/lib/localizations/es.d.ts +2 -0
- package/lib/localizations/language.interface.d.ts +15 -0
- package/package.json +48 -0
- package/public-api.d.ts +7 -0
|
@@ -0,0 +1,868 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Component, Input, EventEmitter, Output, NgModule } from '@angular/core';
|
|
3
|
+
import * as i3 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import * as i1 from '@angular/forms';
|
|
6
|
+
import { Validators, FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
7
|
+
import * as cardValidator from 'card-validator';
|
|
8
|
+
import * as i3$1 from '@ng-select/ng-select';
|
|
9
|
+
import { NgSelectModule } from '@ng-select/ng-select';
|
|
10
|
+
|
|
11
|
+
const LANG_EN = {
|
|
12
|
+
CardNumber: "Card Number",
|
|
13
|
+
CardHolderName: "Card Holder Name",
|
|
14
|
+
ExpiryDate: "Expiry Date",
|
|
15
|
+
CardType: "Card Type",
|
|
16
|
+
DoYouWishTo: "Do you wish to proceed with this request?",
|
|
17
|
+
RequestCancelled: "The request has been cancelled.",
|
|
18
|
+
APIKeyNull: "APIKey is NULL",
|
|
19
|
+
lblSave: "Save",
|
|
20
|
+
CVV: "CVV",
|
|
21
|
+
ValidThru: "Valid Thru",
|
|
22
|
+
Proceed: "Proceed to Pay",
|
|
23
|
+
TokenEmpty: "Token is Empty",
|
|
24
|
+
Update: "Update"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const LANG_ES = {
|
|
28
|
+
CardNumber: "Número de tarjeta",
|
|
29
|
+
CardHolderName: "Nombre del titular de la tarjeta",
|
|
30
|
+
ExpiryDate: "Fecha de caducidad",
|
|
31
|
+
CardType: "Tipo de tarjeta",
|
|
32
|
+
RequestCancelled: "La solicitud ha sido cancelada.",
|
|
33
|
+
DoYouWishTo: "¿Desea continuar con esta solicitud?",
|
|
34
|
+
APIKeyNull: "APIKey es nula",
|
|
35
|
+
lblSave: "Ahorrar",
|
|
36
|
+
CVV: "CVV",
|
|
37
|
+
ValidThru: "Valid Thru",
|
|
38
|
+
Proceed: "Proceda a pagar",
|
|
39
|
+
TokenEmpty: "El token está vacío.",
|
|
40
|
+
Update: "Actualizar"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
class CroemCardWidgetService {
|
|
44
|
+
constructor() { }
|
|
45
|
+
async CardPayment(data, language, apiUrl, encryptedString) {
|
|
46
|
+
const queryString = `?request=${encodeURIComponent(encryptedString)}`;
|
|
47
|
+
const fullUrl = apiUrl + queryString;
|
|
48
|
+
if (language === 'en') {
|
|
49
|
+
this.currentLang = LANG_EN;
|
|
50
|
+
}
|
|
51
|
+
else if (language === 'es') {
|
|
52
|
+
this.currentLang = LANG_ES;
|
|
53
|
+
}
|
|
54
|
+
data.isSale = false;
|
|
55
|
+
if (data.APIKey != null) {
|
|
56
|
+
return this.apiCall(fullUrl);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
throw new Error(this.currentLang["APIKeyNull"]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async addUpdateCardAPICall(apiUrl, encryptedString) {
|
|
63
|
+
const queryString = `?request=${encodeURIComponent(encryptedString)}`;
|
|
64
|
+
const fullUrl = apiUrl + queryString;
|
|
65
|
+
return this.apiCall(fullUrl);
|
|
66
|
+
}
|
|
67
|
+
async apiCall(fullUrl) {
|
|
68
|
+
var response;
|
|
69
|
+
try {
|
|
70
|
+
if (fullUrl.includes('GetCreditCard')) {
|
|
71
|
+
response = await fetch(fullUrl, {
|
|
72
|
+
method: 'GET'
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
response = await fetch(fullUrl, {
|
|
77
|
+
method: 'POST'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
82
|
+
}
|
|
83
|
+
const responseText = await response.text();
|
|
84
|
+
return JSON.parse(responseText);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.log(error);
|
|
88
|
+
return error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
CroemCardWidgetService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
93
|
+
CroemCardWidgetService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetService, providedIn: 'root' });
|
|
94
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetService, decorators: [{
|
|
95
|
+
type: Injectable,
|
|
96
|
+
args: [{
|
|
97
|
+
providedIn: 'root'
|
|
98
|
+
}]
|
|
99
|
+
}], ctorParameters: function () { return []; } });
|
|
100
|
+
|
|
101
|
+
var CardMode;
|
|
102
|
+
(function (CardMode) {
|
|
103
|
+
CardMode["Add"] = "0";
|
|
104
|
+
CardMode["Edit"] = "1";
|
|
105
|
+
CardMode["Show"] = "2";
|
|
106
|
+
})(CardMode || (CardMode = {}));
|
|
107
|
+
|
|
108
|
+
const constants = {
|
|
109
|
+
urls: {
|
|
110
|
+
updateDTRUrl: "api/UIComponentApi/UpdateCreditCard",
|
|
111
|
+
addDTRUrl: "api/UIComponentApi/CreateCreditCard",
|
|
112
|
+
paymentDTRUrl: "api/UIComponentApi/PerformTransaction",
|
|
113
|
+
getCardInfoByToken: "api/UIComponentApi/GetCreditCard"
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
class TextBoxComponent {
|
|
118
|
+
get isValid() { return this.form.controls[this.field.name].valid; }
|
|
119
|
+
get isDirty() { return this.form.controls[this.field.name].dirty; }
|
|
120
|
+
constructor() {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
TextBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TextBoxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
124
|
+
TextBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TextBoxComponent, selector: "textbox", inputs: { field: "field", form: "form" }, ngImport: i0, template: "<div [formGroup]=\"form\">\r\n <input \r\n *ngIf=\"!field.multiline\" \r\n [attr.type]=\"field.type\"\r\n class=\"form-control\" \r\n [id]=\"field.name\" \r\n [name]=\"field.name\"\r\n [formControlName]=\"field.name\"\r\n [placeholder]=\"field.placeholder\" >\r\n\r\n <textarea *ngIf=\"field.multiline\" [formControlName]=\"field.name\" [id]=\"field.name\"\r\n rows=\"9\" class=\"form-control\" [placeholder]=\"field.placeholder\"></textarea>\r\n \r\n</div> ", dependencies: [{ kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
125
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TextBoxComponent, decorators: [{
|
|
126
|
+
type: Component,
|
|
127
|
+
args: [{ selector: 'textbox', template: "<div [formGroup]=\"form\">\r\n <input \r\n *ngIf=\"!field.multiline\" \r\n [attr.type]=\"field.type\"\r\n class=\"form-control\" \r\n [id]=\"field.name\" \r\n [name]=\"field.name\"\r\n [formControlName]=\"field.name\"\r\n [placeholder]=\"field.placeholder\" >\r\n\r\n <textarea *ngIf=\"field.multiline\" [formControlName]=\"field.name\" [id]=\"field.name\"\r\n rows=\"9\" class=\"form-control\" [placeholder]=\"field.placeholder\"></textarea>\r\n \r\n</div> " }]
|
|
128
|
+
}], ctorParameters: function () { return []; }, propDecorators: { field: [{
|
|
129
|
+
type: Input
|
|
130
|
+
}], form: [{
|
|
131
|
+
type: Input
|
|
132
|
+
}] } });
|
|
133
|
+
|
|
134
|
+
class DropDownComponent {
|
|
135
|
+
ngOnInit() {
|
|
136
|
+
this.originalOptions = this.field.options ? [...this.field.options] : undefined;
|
|
137
|
+
}
|
|
138
|
+
filterOptions(options, event) {
|
|
139
|
+
const searchTerm = event.target.value;
|
|
140
|
+
if (options) {
|
|
141
|
+
return options.filter(opt => opt.label.toLowerCase().includes(searchTerm.toLowerCase()));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
constructor() {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
DropDownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropDownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
151
|
+
DropDownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DropDownComponent, selector: "dropdown", inputs: { field: "field", form: "form" }, ngImport: i0, template: "<div [formGroup]=\"form\">\r\n <ng-select [placeholder]=\"'Select a ' + field.label\" [formControlName]=\"field.name\" [id]=\"field.name\"\r\n [searchable]=\"false\" class=\"custom-ng-select\" [readonly]=\"field.disable\">\r\n <ng-template ng-header-tmp>\r\n <input class=\"custom-ng-select-search\" style=\"width: 100%; line-height: 24px\" type=\"text\"\r\n (input)=\"field.options = filterOptions(originalOptions, $event)\" [formControlName]=\"field.name\"\r\n placeholder=\"\" />\r\n </ng-template>\r\n\r\n <ng-option *ngFor=\"let opt of field.options\" [value]=\"opt.key\" aria-readonly=\"true\">{{opt.label}}</ng-option>\r\n </ng-select>\r\n</div>", dependencies: [{ kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i3$1.NgSelectComponent, selector: "ng-select", inputs: ["bindLabel", "bindValue", "markFirst", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "appearance", "dropdownPosition", "appendTo", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "openOnEnter", "maxSelectedItems", "groupBy", "groupValue", "bufferAmount", "virtualScroll", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "tabIndex", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "typeahead", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }, { kind: "component", type: i3$1.NgOptionComponent, selector: "ng-option", inputs: ["value", "disabled"] }, { kind: "directive", type: i3$1.NgHeaderTemplateDirective, selector: "[ng-header-tmp]" }] });
|
|
152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DropDownComponent, decorators: [{
|
|
153
|
+
type: Component,
|
|
154
|
+
args: [{ selector: 'dropdown', template: "<div [formGroup]=\"form\">\r\n <ng-select [placeholder]=\"'Select a ' + field.label\" [formControlName]=\"field.name\" [id]=\"field.name\"\r\n [searchable]=\"false\" class=\"custom-ng-select\" [readonly]=\"field.disable\">\r\n <ng-template ng-header-tmp>\r\n <input class=\"custom-ng-select-search\" style=\"width: 100%; line-height: 24px\" type=\"text\"\r\n (input)=\"field.options = filterOptions(originalOptions, $event)\" [formControlName]=\"field.name\"\r\n placeholder=\"\" />\r\n </ng-template>\r\n\r\n <ng-option *ngFor=\"let opt of field.options\" [value]=\"opt.key\" aria-readonly=\"true\">{{opt.label}}</ng-option>\r\n </ng-select>\r\n</div>" }]
|
|
155
|
+
}], ctorParameters: function () { return []; }, propDecorators: { field: [{
|
|
156
|
+
type: Input
|
|
157
|
+
}], form: [{
|
|
158
|
+
type: Input
|
|
159
|
+
}] } });
|
|
160
|
+
|
|
161
|
+
class FieldBuilderComponent {
|
|
162
|
+
get isValid() { return this.form.controls[this.field.name].valid; }
|
|
163
|
+
get isDirty() { return this.form.controls[this.field.name].dirty; }
|
|
164
|
+
constructor() { }
|
|
165
|
+
ngOnInit() {
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
FieldBuilderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FieldBuilderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
169
|
+
FieldBuilderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: FieldBuilderComponent, selector: "field-builder", inputs: { field: "field", form: "form" }, ngImport: i0, template: "<div class=\"form-group row\" [formGroup]=\"form\">\r\n <label class=\"col-md-12 form-control-label\" [attr.for]=\"field.name\">\r\n {{field.label}}\r\n <strong class=\"text-danger\" *ngIf=\"field.required\">*</strong>\r\n </label>\r\n <div class=\"col-md-12\" [ngSwitch]=\"field.type\">\r\n <textbox *ngSwitchCase=\"'text'\" [field]=\"field\" [form]=\"form\"></textbox>\r\n <dropdown *ngSwitchCase=\"'dropdown'\" [field]=\"field\" [form]=\"form\"></dropdown>\r\n </div>\r\n</div>", dependencies: [{ kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "component", type: TextBoxComponent, selector: "textbox", inputs: ["field", "form"] }, { kind: "component", type: DropDownComponent, selector: "dropdown", inputs: ["field", "form"] }] });
|
|
170
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FieldBuilderComponent, decorators: [{
|
|
171
|
+
type: Component,
|
|
172
|
+
args: [{ selector: 'field-builder', template: "<div class=\"form-group row\" [formGroup]=\"form\">\r\n <label class=\"col-md-12 form-control-label\" [attr.for]=\"field.name\">\r\n {{field.label}}\r\n <strong class=\"text-danger\" *ngIf=\"field.required\">*</strong>\r\n </label>\r\n <div class=\"col-md-12\" [ngSwitch]=\"field.type\">\r\n <textbox *ngSwitchCase=\"'text'\" [field]=\"field\" [form]=\"form\"></textbox>\r\n <dropdown *ngSwitchCase=\"'dropdown'\" [field]=\"field\" [form]=\"form\"></dropdown>\r\n </div>\r\n</div>" }]
|
|
173
|
+
}], ctorParameters: function () { return []; }, propDecorators: { field: [{
|
|
174
|
+
type: Input
|
|
175
|
+
}], form: [{
|
|
176
|
+
type: Input
|
|
177
|
+
}] } });
|
|
178
|
+
|
|
179
|
+
class AddCardWidgetComponent {
|
|
180
|
+
constructor(formBuilder, croemCardService) {
|
|
181
|
+
this.formBuilder = formBuilder;
|
|
182
|
+
this.croemCardService = croemCardService;
|
|
183
|
+
this.widgetResponseEmitter = new EventEmitter();
|
|
184
|
+
this.fieldResponseEmitter = new EventEmitter();
|
|
185
|
+
this.loader = new EventEmitter();
|
|
186
|
+
this.fields = [];
|
|
187
|
+
this.dynamicFields = {};
|
|
188
|
+
this.showLoader = false;
|
|
189
|
+
this.showInputErrorNumber = true;
|
|
190
|
+
this.showInputErrorDate = true;
|
|
191
|
+
this.showInputErrorName = true;
|
|
192
|
+
this.maxLength = 19;
|
|
193
|
+
this.maxExpYear = 28;
|
|
194
|
+
}
|
|
195
|
+
ngOnInit() {
|
|
196
|
+
this.switchLanguage(this.inputParamsForWidgetForAdd.Culture);
|
|
197
|
+
//---Dynamic Form creation innitializing form group(i.e cardForm) to pass onto the dynamic form builder component ------
|
|
198
|
+
for (const field of this.fields) {
|
|
199
|
+
const validators = [];
|
|
200
|
+
if (field.required) {
|
|
201
|
+
validators.push(Validators.required);
|
|
202
|
+
}
|
|
203
|
+
this.dynamicFields[field.name] = [field.value || null, validators];
|
|
204
|
+
}
|
|
205
|
+
const predefinedControls = {
|
|
206
|
+
name: ['', [Validators.required]],
|
|
207
|
+
cardNumber: ['', [Validators.required, Validators.minLength(10), Validators.maxLength(19)]],
|
|
208
|
+
validityDate: ['', [Validators.required, Validators.minLength(5)]],
|
|
209
|
+
};
|
|
210
|
+
this.cardForm = this.formBuilder.group({
|
|
211
|
+
...predefinedControls,
|
|
212
|
+
...this.dynamicFields
|
|
213
|
+
});
|
|
214
|
+
let fieldsContrls = {};
|
|
215
|
+
for (let f of this.fields) {
|
|
216
|
+
if (f.type !== 'checkbox') {
|
|
217
|
+
fieldsContrls[f.name] = new FormControl(f.value || '', Validators.required);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
let opts = {};
|
|
221
|
+
if (f.options) {
|
|
222
|
+
for (let opt of f.options) {
|
|
223
|
+
opts[opt.key] = new FormControl(opt.label);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
fieldsContrls[f.name] = new FormGroup(opts);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
//---localization To add a new property to this go localization dir and add your property insdei en.ts and es.ts ------
|
|
231
|
+
switchLanguage(language) {
|
|
232
|
+
if (language === 'en') {
|
|
233
|
+
this.currentLang = LANG_EN;
|
|
234
|
+
}
|
|
235
|
+
else if (language === 'es') {
|
|
236
|
+
this.currentLang = LANG_ES;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
createCard() {
|
|
240
|
+
this.addCard();
|
|
241
|
+
}
|
|
242
|
+
async addCard() {
|
|
243
|
+
try {
|
|
244
|
+
this.showLoader = true;
|
|
245
|
+
this.loader.emit(this.showLoader);
|
|
246
|
+
const apiUrl = this.inputParamsForWidgetForAdd.DtrUrl + constants.urls.addDTRUrl;
|
|
247
|
+
//----encryption-------
|
|
248
|
+
var encode = this.encoding(); //--encoding parameters
|
|
249
|
+
this.encryptedString = this.innitializeKey(encode); //--innitializing DSA key
|
|
250
|
+
this.addCardResponse = await this.croemCardService.addUpdateCardAPICall(apiUrl, this.encryptedString); //--API Call to add card in DTR
|
|
251
|
+
this.showLoader = false;
|
|
252
|
+
this.fieldResponseEmitter.emit(this.cardForm.controls);
|
|
253
|
+
this.widgetResponseEmitter.emit(this.addCardResponse);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.log(error);
|
|
257
|
+
this.showLoader = false;
|
|
258
|
+
this.widgetResponseEmitter.emit(this.addCardResponse);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
encoding() {
|
|
262
|
+
return this.cardForm.value.cardNumber + "\\" +
|
|
263
|
+
this.cardForm.value.name + "\\" +
|
|
264
|
+
this.cardForm.value.validityDate.substring(0, 2) + "\\" +
|
|
265
|
+
this.cardForm.value.validityDate.substring(3) + "\\" +
|
|
266
|
+
"" + "\\" +
|
|
267
|
+
"" + "\\" +
|
|
268
|
+
this.inputParamsForWidgetForAdd.APIKey + "\\" +
|
|
269
|
+
this.inputParamsForWidgetForAdd.Culture + "\\" +
|
|
270
|
+
"" + "\\" +
|
|
271
|
+
(this.inputParamsForWidgetForAdd.IsSale ?? false) + "\\" +
|
|
272
|
+
(this.inputParamsForWidgetForAdd.Amount ?? "0") + "\\" +
|
|
273
|
+
(this.inputParamsForWidgetForAdd.ProductDetails ?? "0") + "\\" +
|
|
274
|
+
"" + "\\" +
|
|
275
|
+
"" + "\\" +
|
|
276
|
+
(this.inputParamsForWidgetForAdd.Itbms ?? "0") + "\\" +
|
|
277
|
+
this.inputParamsForWidgetForAdd.Mode;
|
|
278
|
+
}
|
|
279
|
+
innitializeKey(encode) {
|
|
280
|
+
var key = initializeKey(this.inputParamsForWidgetForAdd.Keys.EncKey1, this.inputParamsForWidgetForAdd.Keys.EncKey2);
|
|
281
|
+
return encryptedString(key, encode);
|
|
282
|
+
}
|
|
283
|
+
formatDate(event) {
|
|
284
|
+
let input = event.target.value;
|
|
285
|
+
input = input.replace(/\D/g, '');
|
|
286
|
+
const month = this.formatMonth(input.substring(0, 2));
|
|
287
|
+
const year = input.substring(2, 4);
|
|
288
|
+
const formattedDate = month + (year ? '/' + year : '');
|
|
289
|
+
event.target.value = formattedDate;
|
|
290
|
+
this.cardForm.controls['validityDate'].setValue(formattedDate);
|
|
291
|
+
this.validityDate = this.cardForm.controls['validityDate'].value;
|
|
292
|
+
this.validateDate();
|
|
293
|
+
}
|
|
294
|
+
formatMonth(month) {
|
|
295
|
+
const validMonth = parseInt(month, 10);
|
|
296
|
+
return (validMonth > 1 && validMonth <= 9) ? '0' + validMonth : month;
|
|
297
|
+
}
|
|
298
|
+
maskCardNumber() {
|
|
299
|
+
if (this.cardNumber && this.cardNumber.length > 0) {
|
|
300
|
+
const maskedNumber = '•'.repeat(Math.max(0, this.cardNumber.length - 4)) + this.cardNumber.slice(-4);
|
|
301
|
+
return maskedNumber.replace(/(•{4})/g, '$1 ');
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
return '•••• •••• •••• ••••';
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
maskName() {
|
|
308
|
+
return this.name ? this.name : 'Your Name';
|
|
309
|
+
}
|
|
310
|
+
maskDate() {
|
|
311
|
+
return this.validityDate ? this.validityDate : '••/••';
|
|
312
|
+
}
|
|
313
|
+
validateDate() {
|
|
314
|
+
if (!this.inputParamsForWidgetForAdd.IsSale) {
|
|
315
|
+
this.showInputErrorDate = cardValidator.expirationDate(this.validityDate, this.maxExpYear).isValid;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
this.showInputErrorDate = true;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
validateNumber() {
|
|
322
|
+
const valid = cardValidator.number(this.cardNumber).isValid;
|
|
323
|
+
this.showInputErrorNumber = valid;
|
|
324
|
+
}
|
|
325
|
+
bindNumber(event) {
|
|
326
|
+
this.cardNumber = event.target.value;
|
|
327
|
+
this.validateNumber();
|
|
328
|
+
}
|
|
329
|
+
bindName(event) {
|
|
330
|
+
this.name = event.target.value;
|
|
331
|
+
this.validateName();
|
|
332
|
+
}
|
|
333
|
+
restControl(controlname) {
|
|
334
|
+
const control = this.cardForm.get(controlname);
|
|
335
|
+
control.reset();
|
|
336
|
+
}
|
|
337
|
+
validateName() {
|
|
338
|
+
if (this.name.length > 4) {
|
|
339
|
+
this.showInputErrorName = true;
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
this.showInputErrorName = false;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
AddCardWidgetComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AddCardWidgetComponent, deps: [{ token: i1.FormBuilder }, { token: CroemCardWidgetService }], target: i0.ɵɵFactoryTarget.Component });
|
|
347
|
+
AddCardWidgetComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: AddCardWidgetComponent, selector: "lib-add-card-widget", inputs: { inputParamsForWidgetForAdd: "inputParamsForWidgetForAdd", fields: "fields" }, outputs: { widgetResponseEmitter: "widgetResponseEmitter", fieldResponseEmitter: "fieldResponseEmitter", loader: "loader" }, ngImport: i0, template: "<form class=\"container-fluid py-3\" [formGroup]=\"cardForm\" *ngIf=\"(inputParamsForWidgetForAdd.APIKey)\">\r\n <div class=\"p-0\">\r\n <div class=\"d-flex justify-content-center mb-4\">\r\n <div class=\"card\">\r\n <div class=\"card-inner\">\r\n <div class=\"front\">\r\n <!-- Top Bar: Chip & Brand Logo -->\r\n <div class=\"card-top-bar\">\r\n <div class=\"chip\"></div>\r\n <div class=\"card-brand\">\r\n <span class=\"brand-text\">SECURE CARD</span>\r\n </div>\r\n </div>\r\n\r\n <!-- Middle Bar: Card Number -->\r\n <div class=\"card-number-display\">\r\n <span>{{maskCardNumber()}}</span>\r\n </div>\r\n\r\n <!-- Bottom Bar: Cardholder Name & Expiration Date -->\r\n <div class=\"card-bottom-bar\">\r\n <div class=\"card-holder-info\">\r\n <label class=\"card-label\">CARDHOLDER</label>\r\n <span class=\"card-value\">{{maskName()}}</span>\r\n </div>\r\n <div class=\"card-expiry-info\">\r\n <label class=\"card-label\">{{currentLang[\"ValidThru\"]}}</label>\r\n <span class=\"card-value\">{{maskDate()}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Dynamic Form Fields -->\r\n <div class=\"dynamic-fields-container mb-3\">\r\n <div *ngFor=\"let field of fields\" class=\"mb-3\">\r\n <field-builder [field]=\"field\" [form]=\"cardForm\"></field-builder>\r\n </div>\r\n </div>\r\n\r\n <!-- Static Form Fields -->\r\n <div class=\"card-form-fields\">\r\n <div class=\"row mb-3\">\r\n <div class=\"col-12\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"card-number\" class=\"form-label-custom\">\r\n {{currentLang[\"CardNumber\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"card-number\"\r\n [class.inputError]=\"!showInputErrorNumber\" [placeholder]=\"currentLang['CardNumber']\"\r\n formControlName=\"cardNumber\" (input)=\"bindNumber($event)\" [maxlength]=\"maxLength\" />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-3\">\r\n <div class=\"col-12\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"name\" class=\"form-label-custom\">\r\n {{currentLang[\"CardHolderName\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"name\"\r\n [placeholder]=\"currentLang['CardHolderName']\" [class.inputError]=\"!showInputErrorName\"\r\n (input)=\"bindName($event)\" formControlName=\"name\" />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <div class=\"col-6\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"validity-date\" class=\"form-label-custom\">\r\n {{currentLang[\"ExpiryDate\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper date-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"validity-date\"\r\n [class.inputError]=\"!showInputErrorDate\" placeholder=\"MM/YY\"\r\n formControlName=\"validityDate\" (input)=\"formatDate($event)\" />\r\n <span class=\"calendar-icon\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"form-actions-custom\">\r\n <button class=\"btn-submit\" type=\"submit\" [disabled]=\"!cardForm.valid\" (click)=\"createCard()\">\r\n <span class=\"btn-text\">{{currentLang[\"lblSave\"]}}</span>\r\n </button>\r\n </div>\r\n</form>", styles: [".card{width:100%;max-width:400px;height:230px;color:#fff;perspective:1000px;border:none;background:transparent;margin:0 auto}.card-inner{width:100%;height:100%;position:relative;transition:transform .8s cubic-bezier(.175,.885,.32,1.275);transform-style:preserve-3d}.front{width:100%;height:100%;position:absolute;top:0;left:0;padding:24px 28px;border-radius:20px;overflow:hidden;z-index:1;backface-visibility:hidden;background:linear-gradient(135deg,rgba(17,24,39,.95) 0%,rgba(31,41,55,.95) 100%);box-shadow:0 20px 35px #00000040,inset 0 1px #ffffff26;border:1px solid rgba(255,255,255,.1);display:flex;flex-direction:column;justify-content:space-between;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;transition:all .3s ease}.front:before{content:\"\";position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:radial-gradient(circle,rgba(99,102,241,.12) 0%,transparent 70%);pointer-events:none}.card-top-bar{display:flex;justify-content:space-between;align-items:center}.chip{width:48px;height:35px;background:linear-gradient(135deg,#f59e0b 0%,#d97706 100%);border-radius:6px;position:relative;box-shadow:inset 0 1px 2px #ffffff4d}.chip:before{content:\"\";position:absolute;inset:0;border:1px solid rgba(0,0,0,.15);border-radius:6px;background-image:linear-gradient(90deg,transparent 50%,rgba(0,0,0,.1) 50%),linear-gradient(0deg,transparent 50%,rgba(0,0,0,.1) 50%);background-size:10px 10px}.brand-text{font-size:10px;letter-spacing:2px;color:#ffffffb3;font-weight:700;text-shadow:0 2px 4px rgba(0,0,0,.2)}.card-number-display{font-family:Courier New,Courier,monospace;font-size:20px;letter-spacing:3px;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.3);margin:18px 0;text-align:center;-webkit-user-select:none;user-select:none}.card-bottom-bar{display:flex;justify-content:space-between;align-items:flex-end}.card-label{display:block;font-size:8px;color:#fff6;letter-spacing:1.5px;margin-bottom:2px;text-transform:uppercase}.card-value{display:block;font-size:13px;color:#fff;letter-spacing:.5px;font-weight:600;max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.form-group-custom{display:flex;flex-direction:column;margin-bottom:12px}.form-label-custom{font-size:13px;font-weight:600;color:#374151;margin-bottom:6px;letter-spacing:.2px}.input-wrapper{position:relative;width:100%}.form-control-custom{width:100%;background-color:#f9fafb;border:1px solid #d1d5db;border-radius:8px;padding:10px 14px;font-size:14px;color:#1f2937;transition:all .2s ease-in-out;box-shadow:inset 0 1px 2px #00000005}.form-control-custom:focus{background-color:#fff;border-color:#4f46e5;box-shadow:0 0 0 3px #4f46e51f;outline:none}.inputError,.inputError:focus{border-color:#ef4444!important;box-shadow:0 0 0 3px #ef44441f!important}.date-wrapper{display:flex;align-items:center}.calendar-icon{width:18px;height:18px;position:absolute;right:12px;pointer-events:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-size:contain}.form-actions-custom{display:flex;justify-content:flex-end;margin-top:20px;border-top:1px solid #f3f4f6;padding-top:16px}.btn-submit{color:#fff;background-color:#5a75b6;border:solid 2px #5A75B6;border-radius:8px;padding:8px;min-width:120px;margin-right:10px}.btn-submit:hover{background-color:#3e578e;color:#fff}.btn-submit:disabled,.btn-previous:disabled,.btn-next:disabled{background-color:#ecebeb!important;border:solid 2px #ecebeb!important;color:#9c9c9c!important;cursor:not-allowed}.breathing-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0f172a99;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);z-index:9999}.show{display:block}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FieldBuilderComponent, selector: "field-builder", inputs: ["field", "form"] }] });
|
|
348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AddCardWidgetComponent, decorators: [{
|
|
349
|
+
type: Component,
|
|
350
|
+
args: [{ selector: 'lib-add-card-widget', template: "<form class=\"container-fluid py-3\" [formGroup]=\"cardForm\" *ngIf=\"(inputParamsForWidgetForAdd.APIKey)\">\r\n <div class=\"p-0\">\r\n <div class=\"d-flex justify-content-center mb-4\">\r\n <div class=\"card\">\r\n <div class=\"card-inner\">\r\n <div class=\"front\">\r\n <!-- Top Bar: Chip & Brand Logo -->\r\n <div class=\"card-top-bar\">\r\n <div class=\"chip\"></div>\r\n <div class=\"card-brand\">\r\n <span class=\"brand-text\">SECURE CARD</span>\r\n </div>\r\n </div>\r\n\r\n <!-- Middle Bar: Card Number -->\r\n <div class=\"card-number-display\">\r\n <span>{{maskCardNumber()}}</span>\r\n </div>\r\n\r\n <!-- Bottom Bar: Cardholder Name & Expiration Date -->\r\n <div class=\"card-bottom-bar\">\r\n <div class=\"card-holder-info\">\r\n <label class=\"card-label\">CARDHOLDER</label>\r\n <span class=\"card-value\">{{maskName()}}</span>\r\n </div>\r\n <div class=\"card-expiry-info\">\r\n <label class=\"card-label\">{{currentLang[\"ValidThru\"]}}</label>\r\n <span class=\"card-value\">{{maskDate()}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Dynamic Form Fields -->\r\n <div class=\"dynamic-fields-container mb-3\">\r\n <div *ngFor=\"let field of fields\" class=\"mb-3\">\r\n <field-builder [field]=\"field\" [form]=\"cardForm\"></field-builder>\r\n </div>\r\n </div>\r\n\r\n <!-- Static Form Fields -->\r\n <div class=\"card-form-fields\">\r\n <div class=\"row mb-3\">\r\n <div class=\"col-12\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"card-number\" class=\"form-label-custom\">\r\n {{currentLang[\"CardNumber\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"card-number\"\r\n [class.inputError]=\"!showInputErrorNumber\" [placeholder]=\"currentLang['CardNumber']\"\r\n formControlName=\"cardNumber\" (input)=\"bindNumber($event)\" [maxlength]=\"maxLength\" />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-3\">\r\n <div class=\"col-12\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"name\" class=\"form-label-custom\">\r\n {{currentLang[\"CardHolderName\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"name\"\r\n [placeholder]=\"currentLang['CardHolderName']\" [class.inputError]=\"!showInputErrorName\"\r\n (input)=\"bindName($event)\" formControlName=\"name\" />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <div class=\"col-6\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"validity-date\" class=\"form-label-custom\">\r\n {{currentLang[\"ExpiryDate\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper date-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"validity-date\"\r\n [class.inputError]=\"!showInputErrorDate\" placeholder=\"MM/YY\"\r\n formControlName=\"validityDate\" (input)=\"formatDate($event)\" />\r\n <span class=\"calendar-icon\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"form-actions-custom\">\r\n <button class=\"btn-submit\" type=\"submit\" [disabled]=\"!cardForm.valid\" (click)=\"createCard()\">\r\n <span class=\"btn-text\">{{currentLang[\"lblSave\"]}}</span>\r\n </button>\r\n </div>\r\n</form>", styles: [".card{width:100%;max-width:400px;height:230px;color:#fff;perspective:1000px;border:none;background:transparent;margin:0 auto}.card-inner{width:100%;height:100%;position:relative;transition:transform .8s cubic-bezier(.175,.885,.32,1.275);transform-style:preserve-3d}.front{width:100%;height:100%;position:absolute;top:0;left:0;padding:24px 28px;border-radius:20px;overflow:hidden;z-index:1;backface-visibility:hidden;background:linear-gradient(135deg,rgba(17,24,39,.95) 0%,rgba(31,41,55,.95) 100%);box-shadow:0 20px 35px #00000040,inset 0 1px #ffffff26;border:1px solid rgba(255,255,255,.1);display:flex;flex-direction:column;justify-content:space-between;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;transition:all .3s ease}.front:before{content:\"\";position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:radial-gradient(circle,rgba(99,102,241,.12) 0%,transparent 70%);pointer-events:none}.card-top-bar{display:flex;justify-content:space-between;align-items:center}.chip{width:48px;height:35px;background:linear-gradient(135deg,#f59e0b 0%,#d97706 100%);border-radius:6px;position:relative;box-shadow:inset 0 1px 2px #ffffff4d}.chip:before{content:\"\";position:absolute;inset:0;border:1px solid rgba(0,0,0,.15);border-radius:6px;background-image:linear-gradient(90deg,transparent 50%,rgba(0,0,0,.1) 50%),linear-gradient(0deg,transparent 50%,rgba(0,0,0,.1) 50%);background-size:10px 10px}.brand-text{font-size:10px;letter-spacing:2px;color:#ffffffb3;font-weight:700;text-shadow:0 2px 4px rgba(0,0,0,.2)}.card-number-display{font-family:Courier New,Courier,monospace;font-size:20px;letter-spacing:3px;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.3);margin:18px 0;text-align:center;-webkit-user-select:none;user-select:none}.card-bottom-bar{display:flex;justify-content:space-between;align-items:flex-end}.card-label{display:block;font-size:8px;color:#fff6;letter-spacing:1.5px;margin-bottom:2px;text-transform:uppercase}.card-value{display:block;font-size:13px;color:#fff;letter-spacing:.5px;font-weight:600;max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.form-group-custom{display:flex;flex-direction:column;margin-bottom:12px}.form-label-custom{font-size:13px;font-weight:600;color:#374151;margin-bottom:6px;letter-spacing:.2px}.input-wrapper{position:relative;width:100%}.form-control-custom{width:100%;background-color:#f9fafb;border:1px solid #d1d5db;border-radius:8px;padding:10px 14px;font-size:14px;color:#1f2937;transition:all .2s ease-in-out;box-shadow:inset 0 1px 2px #00000005}.form-control-custom:focus{background-color:#fff;border-color:#4f46e5;box-shadow:0 0 0 3px #4f46e51f;outline:none}.inputError,.inputError:focus{border-color:#ef4444!important;box-shadow:0 0 0 3px #ef44441f!important}.date-wrapper{display:flex;align-items:center}.calendar-icon{width:18px;height:18px;position:absolute;right:12px;pointer-events:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-size:contain}.form-actions-custom{display:flex;justify-content:flex-end;margin-top:20px;border-top:1px solid #f3f4f6;padding-top:16px}.btn-submit{color:#fff;background-color:#5a75b6;border:solid 2px #5A75B6;border-radius:8px;padding:8px;min-width:120px;margin-right:10px}.btn-submit:hover{background-color:#3e578e;color:#fff}.btn-submit:disabled,.btn-previous:disabled,.btn-next:disabled{background-color:#ecebeb!important;border:solid 2px #ecebeb!important;color:#9c9c9c!important;cursor:not-allowed}.breathing-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0f172a99;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);z-index:9999}.show{display:block}\n"] }]
|
|
351
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: CroemCardWidgetService }]; }, propDecorators: { inputParamsForWidgetForAdd: [{
|
|
352
|
+
type: Input
|
|
353
|
+
}], widgetResponseEmitter: [{
|
|
354
|
+
type: Output
|
|
355
|
+
}], fieldResponseEmitter: [{
|
|
356
|
+
type: Output
|
|
357
|
+
}], loader: [{
|
|
358
|
+
type: Output
|
|
359
|
+
}], fields: [{
|
|
360
|
+
type: Input
|
|
361
|
+
}] } });
|
|
362
|
+
|
|
363
|
+
class UpdateCardWidgetComponent {
|
|
364
|
+
constructor(formBuilder, croemCardService) {
|
|
365
|
+
this.formBuilder = formBuilder;
|
|
366
|
+
this.croemCardService = croemCardService;
|
|
367
|
+
this.widgetResponseEmitter = new EventEmitter();
|
|
368
|
+
this.getWidgetDataResponseEmitter = new EventEmitter();
|
|
369
|
+
this.fieldResponseEmitter = new EventEmitter();
|
|
370
|
+
this.loader = new EventEmitter();
|
|
371
|
+
this.fields = [];
|
|
372
|
+
this.dynamicFields = {};
|
|
373
|
+
this.showLoader = false;
|
|
374
|
+
this.showInputErrorDate = true;
|
|
375
|
+
this.showInputErrorName = true;
|
|
376
|
+
this.CardMode = CardMode;
|
|
377
|
+
this.maxLength = 19;
|
|
378
|
+
this.maxExpYear = 28;
|
|
379
|
+
}
|
|
380
|
+
ngOnInit() {
|
|
381
|
+
this.switchLanguage(this.inputParamsForWidgetForUpdate.Culture);
|
|
382
|
+
this.getCardDetails();
|
|
383
|
+
//---Dynamic Form creation innitializing form group(i.e cardForm) to pass onto the dynamic form builder component ------
|
|
384
|
+
for (const field of this.fields) {
|
|
385
|
+
const validators = [];
|
|
386
|
+
if (field.required) {
|
|
387
|
+
validators.push(Validators.required);
|
|
388
|
+
}
|
|
389
|
+
this.dynamicFields[field.name] = [field.value || null, validators];
|
|
390
|
+
}
|
|
391
|
+
const predefinedControls = {
|
|
392
|
+
name: ['', [Validators.required]],
|
|
393
|
+
validityDate: ['', [Validators.required, Validators.minLength(5)]],
|
|
394
|
+
};
|
|
395
|
+
this.cardForm = this.formBuilder.group({
|
|
396
|
+
...predefinedControls,
|
|
397
|
+
...this.dynamicFields
|
|
398
|
+
});
|
|
399
|
+
let fieldsContrls = {};
|
|
400
|
+
for (let f of this.fields) {
|
|
401
|
+
if (f.type !== 'checkbox') {
|
|
402
|
+
fieldsContrls[f.name] = new FormControl(f.value || '', Validators.required);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
let opts = {};
|
|
406
|
+
if (f.options) {
|
|
407
|
+
for (let opt of f.options) {
|
|
408
|
+
opts[opt.key] = new FormControl(opt.label);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
fieldsContrls[f.name] = new FormGroup(opts);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
ngOnChanges(changes) {
|
|
416
|
+
for (const field of this.fields) {
|
|
417
|
+
const validators = [];
|
|
418
|
+
if (field.required) {
|
|
419
|
+
validators.push(Validators.required);
|
|
420
|
+
}
|
|
421
|
+
this.dynamicFields[field.name] = [field.value || null, validators];
|
|
422
|
+
}
|
|
423
|
+
let fieldsContrls = {};
|
|
424
|
+
for (let f of this.fields) {
|
|
425
|
+
if (f.type !== 'checkbox') {
|
|
426
|
+
fieldsContrls[f.name] = new FormControl(f.value || '', Validators.required);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
let opts = {};
|
|
430
|
+
if (f.options) {
|
|
431
|
+
for (let opt of f.options) {
|
|
432
|
+
opts[opt.key] = new FormControl(opt.label);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
fieldsContrls[f.name] = new FormGroup(opts);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
//---localization To add a new property to this go localization dir and add your property insdei en.ts and es.ts ------
|
|
440
|
+
switchLanguage(language) {
|
|
441
|
+
if (language === 'en') {
|
|
442
|
+
this.currentLang = LANG_EN;
|
|
443
|
+
}
|
|
444
|
+
else if (language === 'es') {
|
|
445
|
+
this.currentLang = LANG_ES;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
UpdateCardDetails() {
|
|
449
|
+
this.EditCardDetails();
|
|
450
|
+
}
|
|
451
|
+
async getCardDetails() {
|
|
452
|
+
this.showLoader = true;
|
|
453
|
+
this.loader.emit(this.showLoader);
|
|
454
|
+
try {
|
|
455
|
+
const apiUrl = this.inputParamsForWidgetForUpdate.DtrUrl + constants.urls.getCardInfoByToken;
|
|
456
|
+
//----encryption-------
|
|
457
|
+
var encode = this.encodingForGet(); //--encoding parameters
|
|
458
|
+
this.encryptedString = this.innitializeKey(encode); //--innitializing DSA key
|
|
459
|
+
var getCardResponse = await this.croemCardService.addUpdateCardAPICall(apiUrl, this.encryptedString); //--API Call to add card in DTR
|
|
460
|
+
this.showLoader = false;
|
|
461
|
+
this.updateCardResponse = getCardResponse;
|
|
462
|
+
this.updateName(getCardResponse.ResponseData.CardHolderName || getCardResponse.ResponseData.CardholderName, getCardResponse.ResponseData.ExpirationDate, getCardResponse.ResponseData.Number);
|
|
463
|
+
this.getWidgetDataResponseEmitter.emit(this.updateCardResponse);
|
|
464
|
+
}
|
|
465
|
+
catch (error) {
|
|
466
|
+
console.log(error);
|
|
467
|
+
this.showLoader = false;
|
|
468
|
+
this.getWidgetDataResponseEmitter.emit(this.updateCardResponse);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
async EditCardDetails() {
|
|
472
|
+
try {
|
|
473
|
+
this.showLoader = true;
|
|
474
|
+
this.loader.emit(this.showLoader);
|
|
475
|
+
const apiUrl = this.inputParamsForWidgetForUpdate.DtrUrl + constants.urls.updateDTRUrl;
|
|
476
|
+
//----encryption-------
|
|
477
|
+
var encode = this.encoding(); //--encoding parameters
|
|
478
|
+
this.encryptedString = this.innitializeKey(encode); //--innitializing DSA key
|
|
479
|
+
this.updateCardResponse = await this.croemCardService.addUpdateCardAPICall(apiUrl, this.encryptedString); //--API Call to add card in DTR
|
|
480
|
+
this.showLoader = false;
|
|
481
|
+
this.fieldResponseEmitter.emit(this.cardForm.controls);
|
|
482
|
+
this.widgetResponseEmitter.emit(this.updateCardResponse);
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
console.log(error);
|
|
486
|
+
this.showLoader = false;
|
|
487
|
+
this.widgetResponseEmitter.emit(this.updateCardResponse);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
updateName(newName, newDate, newNumber = '') {
|
|
491
|
+
if (newDate.length === 4) {
|
|
492
|
+
newDate = newDate.substring(0, 2) + '/' + newDate.substring(2);
|
|
493
|
+
}
|
|
494
|
+
this.cardForm.patchValue({
|
|
495
|
+
name: newName,
|
|
496
|
+
validityDate: newDate
|
|
497
|
+
});
|
|
498
|
+
this.name = newName;
|
|
499
|
+
this.validityDate = newDate;
|
|
500
|
+
if (newNumber) {
|
|
501
|
+
this.cardNumber = newNumber;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
maskCardNumber() {
|
|
505
|
+
if (this.cardNumber && this.cardNumber.length > 0) {
|
|
506
|
+
const maskedNumber = '•'.repeat(Math.max(0, this.cardNumber.length - 4)) + this.cardNumber.slice(-4);
|
|
507
|
+
return maskedNumber.replace(/(•{4})/g, '$1 ');
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
return '•••• •••• •••• ••••';
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
encodingForGet() {
|
|
514
|
+
return "" + "\\" +
|
|
515
|
+
"" + "\\" +
|
|
516
|
+
"" + "\\" +
|
|
517
|
+
"" + "\\" +
|
|
518
|
+
this.inputParamsForWidgetForUpdate.Token + "\\" +
|
|
519
|
+
"" + "\\" +
|
|
520
|
+
this.inputParamsForWidgetForUpdate.APIKey + "\\" +
|
|
521
|
+
this.inputParamsForWidgetForUpdate.Culture + "\\" +
|
|
522
|
+
"" + "\\" +
|
|
523
|
+
this.inputParamsForWidgetForUpdate.IsSale + "\\" +
|
|
524
|
+
this.inputParamsForWidgetForUpdate.Amount + "\\" +
|
|
525
|
+
this.inputParamsForWidgetForUpdate.ProductDetails + "\\" +
|
|
526
|
+
"" + "\\" +
|
|
527
|
+
"" + "\\" +
|
|
528
|
+
this.inputParamsForWidgetForUpdate.Itbms + "\\" +
|
|
529
|
+
this.inputParamsForWidgetForUpdate.Mode;
|
|
530
|
+
}
|
|
531
|
+
encoding() {
|
|
532
|
+
return "" + "\\" +
|
|
533
|
+
this.cardForm.value.name + "\\" +
|
|
534
|
+
this.cardForm.value.validityDate.substring(0, 2) + "\\" +
|
|
535
|
+
this.cardForm.value.validityDate.substring(3) + "\\" +
|
|
536
|
+
this.inputParamsForWidgetForUpdate.Token + "\\" +
|
|
537
|
+
"" + "\\" +
|
|
538
|
+
this.inputParamsForWidgetForUpdate.APIKey + "\\" +
|
|
539
|
+
this.inputParamsForWidgetForUpdate.Culture + "\\" +
|
|
540
|
+
"" + "\\" +
|
|
541
|
+
(this.inputParamsForWidgetForUpdate.IsSale ?? false) + "\\" +
|
|
542
|
+
(this.inputParamsForWidgetForUpdate.Amount ?? "0") + "\\" +
|
|
543
|
+
(this.inputParamsForWidgetForUpdate.ProductDetails ?? "0") + "\\" +
|
|
544
|
+
"" + "\\" +
|
|
545
|
+
"" + "\\" +
|
|
546
|
+
(this.inputParamsForWidgetForUpdate.Itbms ?? "0") + "\\" +
|
|
547
|
+
this.inputParamsForWidgetForUpdate.Mode;
|
|
548
|
+
}
|
|
549
|
+
innitializeKey(encode) {
|
|
550
|
+
var key = initializeKey(this.inputParamsForWidgetForUpdate.Keys.EncKey1, this.inputParamsForWidgetForUpdate.Keys.EncKey2);
|
|
551
|
+
return encryptedString(key, encode);
|
|
552
|
+
}
|
|
553
|
+
formatDate(event) {
|
|
554
|
+
let input = event.target.value;
|
|
555
|
+
input = input.replace(/\D/g, '');
|
|
556
|
+
const month = this.formatMonth(input.substring(0, 2));
|
|
557
|
+
const year = input.substring(2, 4);
|
|
558
|
+
const formattedDate = month + (year ? '/' + year : '');
|
|
559
|
+
event.target.value = formattedDate;
|
|
560
|
+
this.cardForm.controls['validityDate'].setValue(formattedDate);
|
|
561
|
+
this.validityDate = this.cardForm.controls['validityDate'].value;
|
|
562
|
+
this.validateDate();
|
|
563
|
+
}
|
|
564
|
+
formatMonth(month) {
|
|
565
|
+
const validMonth = parseInt(month, 10);
|
|
566
|
+
return (validMonth > 1 && validMonth <= 9) ? '0' + validMonth : month;
|
|
567
|
+
}
|
|
568
|
+
maskName() {
|
|
569
|
+
return this.name ? this.name : 'Your Name';
|
|
570
|
+
}
|
|
571
|
+
maskDate() {
|
|
572
|
+
return this.validityDate ? this.validityDate : '••/••';
|
|
573
|
+
}
|
|
574
|
+
validateDate() {
|
|
575
|
+
if (!this.inputParamsForWidgetForUpdate.IsSale) {
|
|
576
|
+
this.showInputErrorDate = cardValidator.expirationDate(this.validityDate, this.maxExpYear).isValid;
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
this.showInputErrorDate = true;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
bindName(event) {
|
|
583
|
+
this.name = event.target.value;
|
|
584
|
+
this.validateName();
|
|
585
|
+
}
|
|
586
|
+
bindDate(event) {
|
|
587
|
+
this.validityDate = event.target.value;
|
|
588
|
+
;
|
|
589
|
+
}
|
|
590
|
+
validateName() {
|
|
591
|
+
if (this.name.length > 4) {
|
|
592
|
+
this.showInputErrorName = true;
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
this.showInputErrorName = false;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
UpdateCardWidgetComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: UpdateCardWidgetComponent, deps: [{ token: i1.FormBuilder }, { token: CroemCardWidgetService }], target: i0.ɵɵFactoryTarget.Component });
|
|
600
|
+
UpdateCardWidgetComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: UpdateCardWidgetComponent, selector: "lib-update-card-widget", inputs: { inputParamsForWidgetForUpdate: "inputParamsForWidgetForUpdate", fields: "fields" }, outputs: { widgetResponseEmitter: "widgetResponseEmitter", getWidgetDataResponseEmitter: "getWidgetDataResponseEmitter", fieldResponseEmitter: "fieldResponseEmitter", loader: "loader" }, usesOnChanges: true, ngImport: i0, template: "<form class=\"container-fluid py-3\" [formGroup]=\"cardForm\" *ngIf=\"(inputParamsForWidgetForUpdate.APIKey)\">\r\n <div class=\"p-0\">\r\n <div class=\"d-flex justify-content-center mb-4\">\r\n <div class=\"card\">\r\n <div class=\"card-inner\">\r\n <div class=\"front\">\r\n <!-- Top Bar: Chip & Brand Logo -->\r\n <div class=\"card-top-bar\">\r\n <div class=\"chip\"></div>\r\n <div class=\"card-brand\">\r\n <span class=\"brand-text\">SECURE CARD</span>\r\n </div>\r\n </div>\r\n \r\n <!-- Middle Bar: Card Number (Masked) -->\r\n <div class=\"card-number-display\">\r\n <span>{{maskCardNumber()}}</span>\r\n </div>\r\n \r\n <!-- Bottom Bar: Cardholder Name & Expiration Date -->\r\n <div class=\"card-bottom-bar\">\r\n <div class=\"card-holder-info\">\r\n <label class=\"card-label\">CARDHOLDER</label>\r\n <span class=\"card-value\">{{maskName()}}</span>\r\n </div>\r\n <div class=\"card-expiry-info\">\r\n <label class=\"card-label\">{{currentLang[\"ValidThru\"]}}</label>\r\n <span class=\"card-value\">{{maskDate()}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Dynamic Form Fields -->\r\n <div class=\"dynamic-fields-container mb-3\">\r\n <div *ngFor=\"let field of fields\" class=\"mb-3\">\r\n <field-builder [field]=\"field\" [form]=\"cardForm\"></field-builder>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Static Form Fields -->\r\n <div class=\"card-form-fields\">\r\n <div class=\"row mb-3\">\r\n <div class=\"col-12\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"name\" class=\"form-label-custom\">\r\n {{currentLang[\"CardHolderName\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"name\" [placeholder]=\"currentLang['CardHolderName']\"\r\n [class.inputError]=\"!showInputErrorName\" (input)=\"bindName($event)\" formControlName=\"name\" />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <div class=\"col-6\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"validity-date\" class=\"form-label-custom\">\r\n {{currentLang[\"ExpiryDate\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper date-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"validity-date\"\r\n [class.inputError]=\"!showInputErrorDate\" placeholder=\"MM/YY\"\r\n formControlName=\"validityDate\" (input)=\"formatDate($event)\" />\r\n <span class=\"calendar-icon\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"form-actions-custom\">\r\n <button class=\"btn-submit\" *ngIf=\"(inputParamsForWidgetForUpdate.Mode==CardMode.Edit)\" type=\"submit\" [disabled]=\"!cardForm.valid\"\r\n (click)=\"UpdateCardDetails()\">\r\n <span class=\"btn-text\">{{currentLang[\"Update\"]}}</span>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: [".card{width:100%;max-width:400px;height:230px;color:#fff;perspective:1000px;border:none;background:transparent;margin:0 auto}.card-inner{width:100%;height:100%;position:relative;transition:transform .8s cubic-bezier(.175,.885,.32,1.275);transform-style:preserve-3d}.front{width:100%;height:100%;position:absolute;top:0;left:0;padding:24px 28px;border-radius:20px;overflow:hidden;z-index:1;backface-visibility:hidden;background:linear-gradient(135deg,rgba(17,24,39,.95) 0%,rgba(31,41,55,.95) 100%);box-shadow:0 20px 35px #00000040,inset 0 1px #ffffff26;border:1px solid rgba(255,255,255,.1);display:flex;flex-direction:column;justify-content:space-between;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;transition:all .3s ease}.front:before{content:\"\";position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:radial-gradient(circle,rgba(99,102,241,.12) 0%,transparent 70%);pointer-events:none}.card-top-bar{display:flex;justify-content:space-between;align-items:center}.chip{width:48px;height:35px;background:linear-gradient(135deg,#f59e0b 0%,#d97706 100%);border-radius:6px;position:relative;box-shadow:inset 0 1px 2px #ffffff4d}.chip:before{content:\"\";position:absolute;inset:0;border:1px solid rgba(0,0,0,.15);border-radius:6px;background-image:linear-gradient(90deg,transparent 50%,rgba(0,0,0,.1) 50%),linear-gradient(0deg,transparent 50%,rgba(0,0,0,.1) 50%);background-size:10px 10px}.brand-text{font-size:10px;letter-spacing:2px;color:#ffffffb3;font-weight:700;text-shadow:0 2px 4px rgba(0,0,0,.2)}.card-number-display{font-family:Courier New,Courier,monospace;font-size:20px;letter-spacing:3px;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.3);margin:18px 0;text-align:center;-webkit-user-select:none;user-select:none}.card-bottom-bar{display:flex;justify-content:space-between;align-items:flex-end}.card-label{display:block;font-size:8px;color:#fff6;letter-spacing:1.5px;margin-bottom:2px;text-transform:uppercase}.card-value{display:block;font-size:13px;color:#fff;letter-spacing:.5px;font-weight:600;max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.form-group-custom{display:flex;flex-direction:column;margin-bottom:12px}.form-label-custom{font-size:13px;font-weight:600;color:#374151;margin-bottom:6px;letter-spacing:.2px}.input-wrapper{position:relative;width:100%}.form-control-custom{width:100%;background-color:#f9fafb;border:1px solid #d1d5db;border-radius:8px;padding:10px 14px;font-size:14px;color:#1f2937;transition:all .2s ease-in-out;box-shadow:inset 0 1px 2px #00000005}.form-control-custom:focus{background-color:#fff;border-color:#4f46e5;box-shadow:0 0 0 3px #4f46e51f;outline:none}.inputError,.inputError:focus{border-color:#ef4444!important;box-shadow:0 0 0 3px #ef44441f!important}.date-wrapper{display:flex;align-items:center}.calendar-icon{width:18px;height:18px;position:absolute;right:12px;pointer-events:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-size:contain}.form-actions-custom{display:flex;justify-content:flex-end;margin-top:20px;border-top:1px solid #f3f4f6;padding-top:16px}.btn-submit{color:#fff;background-color:#5a75b6;border:solid 2px #5A75B6;border-radius:8px;padding:8px;min-width:120px;margin-right:10px}.btn-submit:hover{background-color:#3e578e;color:#fff}.btn-submit:disabled,.btn-previous:disabled,.btn-next:disabled{background-color:#ecebeb!important;border:solid 2px #ecebeb!important;color:#9c9c9c!important;cursor:not-allowed}.breathing-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0f172a99;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);z-index:9999}.show{display:block}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FieldBuilderComponent, selector: "field-builder", inputs: ["field", "form"] }] });
|
|
601
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: UpdateCardWidgetComponent, decorators: [{
|
|
602
|
+
type: Component,
|
|
603
|
+
args: [{ selector: 'lib-update-card-widget', template: "<form class=\"container-fluid py-3\" [formGroup]=\"cardForm\" *ngIf=\"(inputParamsForWidgetForUpdate.APIKey)\">\r\n <div class=\"p-0\">\r\n <div class=\"d-flex justify-content-center mb-4\">\r\n <div class=\"card\">\r\n <div class=\"card-inner\">\r\n <div class=\"front\">\r\n <!-- Top Bar: Chip & Brand Logo -->\r\n <div class=\"card-top-bar\">\r\n <div class=\"chip\"></div>\r\n <div class=\"card-brand\">\r\n <span class=\"brand-text\">SECURE CARD</span>\r\n </div>\r\n </div>\r\n \r\n <!-- Middle Bar: Card Number (Masked) -->\r\n <div class=\"card-number-display\">\r\n <span>{{maskCardNumber()}}</span>\r\n </div>\r\n \r\n <!-- Bottom Bar: Cardholder Name & Expiration Date -->\r\n <div class=\"card-bottom-bar\">\r\n <div class=\"card-holder-info\">\r\n <label class=\"card-label\">CARDHOLDER</label>\r\n <span class=\"card-value\">{{maskName()}}</span>\r\n </div>\r\n <div class=\"card-expiry-info\">\r\n <label class=\"card-label\">{{currentLang[\"ValidThru\"]}}</label>\r\n <span class=\"card-value\">{{maskDate()}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Dynamic Form Fields -->\r\n <div class=\"dynamic-fields-container mb-3\">\r\n <div *ngFor=\"let field of fields\" class=\"mb-3\">\r\n <field-builder [field]=\"field\" [form]=\"cardForm\"></field-builder>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Static Form Fields -->\r\n <div class=\"card-form-fields\">\r\n <div class=\"row mb-3\">\r\n <div class=\"col-12\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"name\" class=\"form-label-custom\">\r\n {{currentLang[\"CardHolderName\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"name\" [placeholder]=\"currentLang['CardHolderName']\"\r\n [class.inputError]=\"!showInputErrorName\" (input)=\"bindName($event)\" formControlName=\"name\" />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mb-4\">\r\n <div class=\"col-6\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"validity-date\" class=\"form-label-custom\">\r\n {{currentLang[\"ExpiryDate\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper date-wrapper\">\r\n <input class=\"form-control-custom\" type=\"text\" id=\"validity-date\"\r\n [class.inputError]=\"!showInputErrorDate\" placeholder=\"MM/YY\"\r\n formControlName=\"validityDate\" (input)=\"formatDate($event)\" />\r\n <span class=\"calendar-icon\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div class=\"form-actions-custom\">\r\n <button class=\"btn-submit\" *ngIf=\"(inputParamsForWidgetForUpdate.Mode==CardMode.Edit)\" type=\"submit\" [disabled]=\"!cardForm.valid\"\r\n (click)=\"UpdateCardDetails()\">\r\n <span class=\"btn-text\">{{currentLang[\"Update\"]}}</span>\r\n </button>\r\n </div>\r\n</form>\r\n", styles: [".card{width:100%;max-width:400px;height:230px;color:#fff;perspective:1000px;border:none;background:transparent;margin:0 auto}.card-inner{width:100%;height:100%;position:relative;transition:transform .8s cubic-bezier(.175,.885,.32,1.275);transform-style:preserve-3d}.front{width:100%;height:100%;position:absolute;top:0;left:0;padding:24px 28px;border-radius:20px;overflow:hidden;z-index:1;backface-visibility:hidden;background:linear-gradient(135deg,rgba(17,24,39,.95) 0%,rgba(31,41,55,.95) 100%);box-shadow:0 20px 35px #00000040,inset 0 1px #ffffff26;border:1px solid rgba(255,255,255,.1);display:flex;flex-direction:column;justify-content:space-between;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;transition:all .3s ease}.front:before{content:\"\";position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:radial-gradient(circle,rgba(99,102,241,.12) 0%,transparent 70%);pointer-events:none}.card-top-bar{display:flex;justify-content:space-between;align-items:center}.chip{width:48px;height:35px;background:linear-gradient(135deg,#f59e0b 0%,#d97706 100%);border-radius:6px;position:relative;box-shadow:inset 0 1px 2px #ffffff4d}.chip:before{content:\"\";position:absolute;inset:0;border:1px solid rgba(0,0,0,.15);border-radius:6px;background-image:linear-gradient(90deg,transparent 50%,rgba(0,0,0,.1) 50%),linear-gradient(0deg,transparent 50%,rgba(0,0,0,.1) 50%);background-size:10px 10px}.brand-text{font-size:10px;letter-spacing:2px;color:#ffffffb3;font-weight:700;text-shadow:0 2px 4px rgba(0,0,0,.2)}.card-number-display{font-family:Courier New,Courier,monospace;font-size:20px;letter-spacing:3px;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.3);margin:18px 0;text-align:center;-webkit-user-select:none;user-select:none}.card-bottom-bar{display:flex;justify-content:space-between;align-items:flex-end}.card-label{display:block;font-size:8px;color:#fff6;letter-spacing:1.5px;margin-bottom:2px;text-transform:uppercase}.card-value{display:block;font-size:13px;color:#fff;letter-spacing:.5px;font-weight:600;max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.form-group-custom{display:flex;flex-direction:column;margin-bottom:12px}.form-label-custom{font-size:13px;font-weight:600;color:#374151;margin-bottom:6px;letter-spacing:.2px}.input-wrapper{position:relative;width:100%}.form-control-custom{width:100%;background-color:#f9fafb;border:1px solid #d1d5db;border-radius:8px;padding:10px 14px;font-size:14px;color:#1f2937;transition:all .2s ease-in-out;box-shadow:inset 0 1px 2px #00000005}.form-control-custom:focus{background-color:#fff;border-color:#4f46e5;box-shadow:0 0 0 3px #4f46e51f;outline:none}.inputError,.inputError:focus{border-color:#ef4444!important;box-shadow:0 0 0 3px #ef44441f!important}.date-wrapper{display:flex;align-items:center}.calendar-icon{width:18px;height:18px;position:absolute;right:12px;pointer-events:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-size:contain}.form-actions-custom{display:flex;justify-content:flex-end;margin-top:20px;border-top:1px solid #f3f4f6;padding-top:16px}.btn-submit{color:#fff;background-color:#5a75b6;border:solid 2px #5A75B6;border-radius:8px;padding:8px;min-width:120px;margin-right:10px}.btn-submit:hover{background-color:#3e578e;color:#fff}.btn-submit:disabled,.btn-previous:disabled,.btn-next:disabled{background-color:#ecebeb!important;border:solid 2px #ecebeb!important;color:#9c9c9c!important;cursor:not-allowed}.breathing-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0f172a99;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);z-index:9999}.show{display:block}\n"] }]
|
|
604
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: CroemCardWidgetService }]; }, propDecorators: { inputParamsForWidgetForUpdate: [{
|
|
605
|
+
type: Input
|
|
606
|
+
}], widgetResponseEmitter: [{
|
|
607
|
+
type: Output
|
|
608
|
+
}], getWidgetDataResponseEmitter: [{
|
|
609
|
+
type: Output
|
|
610
|
+
}], fieldResponseEmitter: [{
|
|
611
|
+
type: Output
|
|
612
|
+
}], loader: [{
|
|
613
|
+
type: Output
|
|
614
|
+
}], fields: [{
|
|
615
|
+
type: Input
|
|
616
|
+
}] } });
|
|
617
|
+
|
|
618
|
+
class PaymentCardWidgetComponent {
|
|
619
|
+
constructor(formBuilder, croemCardService) {
|
|
620
|
+
this.formBuilder = formBuilder;
|
|
621
|
+
this.croemCardService = croemCardService;
|
|
622
|
+
this.widgetResponseEmitter = new EventEmitter();
|
|
623
|
+
this.fieldResponseEmitter = new EventEmitter();
|
|
624
|
+
this.loader = new EventEmitter();
|
|
625
|
+
this.HandleError = new EventEmitter();
|
|
626
|
+
this.fields = [];
|
|
627
|
+
this.dynamicFields = {};
|
|
628
|
+
this.showCVVPrepend = false;
|
|
629
|
+
this.showInputError = true;
|
|
630
|
+
}
|
|
631
|
+
ngOnInit() {
|
|
632
|
+
this.switchLanguage(this.inputParamsForWidgetForPayment.Culture);
|
|
633
|
+
//---Dynamic Form creation innitializing form group(i.e cardForm) to pass onto the dynamic form builder component ------
|
|
634
|
+
for (const field of this.fields) {
|
|
635
|
+
const validators = [];
|
|
636
|
+
if (field.required) {
|
|
637
|
+
validators.push(Validators.required);
|
|
638
|
+
}
|
|
639
|
+
this.dynamicFields[field.name] = [field.value || null, validators];
|
|
640
|
+
}
|
|
641
|
+
const predefinedControls = {
|
|
642
|
+
cvv: ['', [Validators.required, Validators.maxLength(4)]]
|
|
643
|
+
};
|
|
644
|
+
this.cardForm = this.formBuilder.group({
|
|
645
|
+
...predefinedControls,
|
|
646
|
+
...this.dynamicFields
|
|
647
|
+
});
|
|
648
|
+
let fieldsContrls = {};
|
|
649
|
+
for (let f of this.fields) {
|
|
650
|
+
if (f.type !== 'checkbox') {
|
|
651
|
+
fieldsContrls[f.name] = new FormControl(f.value || '', Validators.required);
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
let opts = {};
|
|
655
|
+
if (f.options) {
|
|
656
|
+
for (let opt of f.options) {
|
|
657
|
+
opts[opt.key] = new FormControl(opt.label);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
fieldsContrls[f.name] = new FormGroup(opts);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
makePayment() {
|
|
665
|
+
this.makeTransactionWithToken();
|
|
666
|
+
}
|
|
667
|
+
switchLanguage(language) {
|
|
668
|
+
if (language === 'en') {
|
|
669
|
+
this.currentLang = LANG_EN;
|
|
670
|
+
}
|
|
671
|
+
else if (language === 'es') {
|
|
672
|
+
this.currentLang = LANG_ES;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
async makeTransactionWithToken() {
|
|
676
|
+
try {
|
|
677
|
+
this.showLoader = true;
|
|
678
|
+
this.loader.emit(this.showLoader);
|
|
679
|
+
const apiUrl = this.inputParamsForWidgetForPayment.DtrUrl + constants.urls.paymentDTRUrl;
|
|
680
|
+
//----encryption-------
|
|
681
|
+
var encode = this.encoding(); //--encoding parameters
|
|
682
|
+
this.encryptedString = this.innitializeKey(encode); //--innitializing DSA key
|
|
683
|
+
//-----request--------
|
|
684
|
+
this.paidCardResponse = await this.croemCardService.CardPayment(this.inputParamsForWidgetForPayment, this.inputParamsForWidgetForPayment.Culture, apiUrl, this.encryptedString); //--API Call to make sale through cardToken in DTR
|
|
685
|
+
this.showLoader = false;
|
|
686
|
+
this.fieldResponseEmitter.emit(this.cardForm.controls); //emmiting controls
|
|
687
|
+
this.widgetResponseEmitter.emit(this.paidCardResponse); // emitting response
|
|
688
|
+
}
|
|
689
|
+
catch (error) {
|
|
690
|
+
console.log(error);
|
|
691
|
+
this.showLoader = false;
|
|
692
|
+
this.widgetResponseEmitter.emit(this.paidCardResponse);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
encoding() {
|
|
696
|
+
return "" + "\\" +
|
|
697
|
+
"" + "\\" +
|
|
698
|
+
"" + "\\" +
|
|
699
|
+
"" + "\\" +
|
|
700
|
+
this.inputParamsForWidgetForPayment.Token + "\\" +
|
|
701
|
+
"" + "\\" +
|
|
702
|
+
this.inputParamsForWidgetForPayment.APIKey + "\\" +
|
|
703
|
+
this.inputParamsForWidgetForPayment.Culture + "\\" +
|
|
704
|
+
this.cardForm.value.cvv + "\\" +
|
|
705
|
+
this.inputParamsForWidgetForPayment.IsSale + "\\" +
|
|
706
|
+
this.inputParamsForWidgetForPayment.Amount + "\\" +
|
|
707
|
+
this.inputParamsForWidgetForPayment.ProductDetails + "\\" +
|
|
708
|
+
"" + "\\" +
|
|
709
|
+
"" + "\\" +
|
|
710
|
+
this.inputParamsForWidgetForPayment.Itbms + "\\" +
|
|
711
|
+
"";
|
|
712
|
+
}
|
|
713
|
+
innitializeKey(encode) {
|
|
714
|
+
var key = initializeKey(this.inputParamsForWidgetForPayment.Keys.EncKey1, this.inputParamsForWidgetForPayment.Keys.EncKey2);
|
|
715
|
+
return encryptedString(key, encode);
|
|
716
|
+
}
|
|
717
|
+
bindCVV(event) {
|
|
718
|
+
const inputElement = event.target;
|
|
719
|
+
const numericValue = inputElement.value.replace(/\D/g, ''); // Remove non-numeric characters
|
|
720
|
+
this.cvv = numericValue; // Update form control value
|
|
721
|
+
inputElement.value = numericValue; // Update input value to remove non-numeric characters
|
|
722
|
+
this.validateCvv();
|
|
723
|
+
}
|
|
724
|
+
validateCvv() {
|
|
725
|
+
this.showCVVPrepend = false;
|
|
726
|
+
if (cardValidator.cvv(this.cvv, 4).isValid || cardValidator.cvv(this.cvv).isValid) {
|
|
727
|
+
this.showInputError = true;
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
this.showInputError = false;
|
|
731
|
+
}
|
|
732
|
+
if (this.cvv) {
|
|
733
|
+
this.showCVVPrepend = true;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
PaymentCardWidgetComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PaymentCardWidgetComponent, deps: [{ token: i1.FormBuilder }, { token: CroemCardWidgetService }], target: i0.ɵɵFactoryTarget.Component });
|
|
738
|
+
PaymentCardWidgetComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: PaymentCardWidgetComponent, selector: "lib-payment-card-widget", inputs: { inputParamsForWidgetForPayment: "inputParamsForWidgetForPayment", fields: "fields" }, outputs: { widgetResponseEmitter: "widgetResponseEmitter", fieldResponseEmitter: "fieldResponseEmitter", loader: "loader", HandleError: "HandleError" }, ngImport: i0, template: "<form class=\"container-fluid py-3\" [formGroup]=\"cardForm\" *ngIf=\"(inputParamsForWidgetForPayment.APIKey)\">\r\n <div class=\"p-0\">\r\n <!-- Dynamic Form Fields -->\r\n <div class=\"dynamic-fields-container mb-3\">\r\n <div *ngFor=\"let field of fields\" class=\"mb-3\">\r\n <field-builder [field]=\"field\" [form]=\"cardForm\"></field-builder>\r\n </div>\r\n </div>\r\n\r\n <!-- CVV and Proceed Fields -->\r\n <div class=\"payment-fields-custom\">\r\n <div class=\"row align-items-end\">\r\n <div class=\"col-12 mb-3 mb-md-0\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"cvv\" class=\"form-label-custom\">\r\n {{currentLang[\"CVV\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper cvv-wrapper\">\r\n <input class=\"form-control-custom\" type=\"password\" id=\"cvv\" [class.inputError]=\"!showInputError\"\r\n placeholder=\"CVV\" pattern=\"[0-9]*\" formControlName=\"cvv\" (input)=\"bindCVV($event)\" minlength=\"3\"\r\n maxlength=\"4\" />\r\n <span *ngIf=\"!showCVVPrepend\" class=\"cvv-icon\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"col-12\">\r\n <button class=\"btn-submit-custom w-100 py-3\" type=\"submit\" [disabled]=\"!cardForm.valid\" (click)=\"makePayment()\">\r\n <span class=\"btn-text\">{{currentLang[\"Proceed\"]}}</span>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\n", styles: [".form-group-custom{display:flex;flex-direction:column;margin-bottom:12px}.form-label-custom{font-size:13px;font-weight:600;color:#374151;margin-bottom:6px;letter-spacing:.2px}.input-wrapper{position:relative;width:100%}.form-control-custom{width:100%;background-color:#f9fafb;border:1px solid #d1d5db;border-radius:8px;padding:10px 14px;font-size:14px;color:#1f2937;transition:all .2s ease-in-out;box-shadow:inset 0 1px 2px #00000005}.form-control-custom:focus{background-color:#fff;border-color:#4f46e5;box-shadow:0 0 0 3px #4f46e51f;outline:none}.inputError,.inputError:focus{border-color:#ef4444!important;box-shadow:0 0 0 3px #ef44441f!important}.cvv-wrapper{display:flex;align-items:center}.cvv-icon{width:20px;height:20px;position:absolute;right:12px;pointer-events:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-size:contain}.btn-submit-custom{background:#5A75B6;border:solid 2px #5A75B6;color:#fff;padding:10px 20px;font-weight:600;font-size:14px;border-radius:8px;transition:all .2s ease-in-out;box-shadow:0 4px 10px #5a75b640;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}.btn-submit-custom:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 6px 14px #5a75b659;background:#3E578E;border-color:#3e578e}.btn-submit-custom:active:not(:disabled){transform:translateY(0)}.btn-submit-custom:disabled{background:#ecebeb!important;border:solid 2px #ecebeb!important;color:#9c9c9c!important;cursor:not-allowed;box-shadow:none}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: FieldBuilderComponent, selector: "field-builder", inputs: ["field", "form"] }] });
|
|
739
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: PaymentCardWidgetComponent, decorators: [{
|
|
740
|
+
type: Component,
|
|
741
|
+
args: [{ selector: 'lib-payment-card-widget', template: "<form class=\"container-fluid py-3\" [formGroup]=\"cardForm\" *ngIf=\"(inputParamsForWidgetForPayment.APIKey)\">\r\n <div class=\"p-0\">\r\n <!-- Dynamic Form Fields -->\r\n <div class=\"dynamic-fields-container mb-3\">\r\n <div *ngFor=\"let field of fields\" class=\"mb-3\">\r\n <field-builder [field]=\"field\" [form]=\"cardForm\"></field-builder>\r\n </div>\r\n </div>\r\n\r\n <!-- CVV and Proceed Fields -->\r\n <div class=\"payment-fields-custom\">\r\n <div class=\"row align-items-end\">\r\n <div class=\"col-12 mb-3 mb-md-0\">\r\n <div class=\"form-group-custom\">\r\n <label for=\"cvv\" class=\"form-label-custom\">\r\n {{currentLang[\"CVV\"]}} <span class=\"text-danger\">*</span>\r\n </label>\r\n <div class=\"input-wrapper cvv-wrapper\">\r\n <input class=\"form-control-custom\" type=\"password\" id=\"cvv\" [class.inputError]=\"!showInputError\"\r\n placeholder=\"CVV\" pattern=\"[0-9]*\" formControlName=\"cvv\" (input)=\"bindCVV($event)\" minlength=\"3\"\r\n maxlength=\"4\" />\r\n <span *ngIf=\"!showCVVPrepend\" class=\"cvv-icon\"></span>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"col-12\">\r\n <button class=\"btn-submit-custom w-100 py-3\" type=\"submit\" [disabled]=\"!cardForm.valid\" (click)=\"makePayment()\">\r\n <span class=\"btn-text\">{{currentLang[\"Proceed\"]}}</span>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\n", styles: [".form-group-custom{display:flex;flex-direction:column;margin-bottom:12px}.form-label-custom{font-size:13px;font-weight:600;color:#374151;margin-bottom:6px;letter-spacing:.2px}.input-wrapper{position:relative;width:100%}.form-control-custom{width:100%;background-color:#f9fafb;border:1px solid #d1d5db;border-radius:8px;padding:10px 14px;font-size:14px;color:#1f2937;transition:all .2s ease-in-out;box-shadow:inset 0 1px 2px #00000005}.form-control-custom:focus{background-color:#fff;border-color:#4f46e5;box-shadow:0 0 0 3px #4f46e51f;outline:none}.inputError,.inputError:focus{border-color:#ef4444!important;box-shadow:0 0 0 3px #ef44441f!important}.cvv-wrapper{display:flex;align-items:center}.cvv-icon{width:20px;height:20px;position:absolute;right:12px;pointer-events:none;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-size:contain}.btn-submit-custom{background:#5A75B6;border:solid 2px #5A75B6;color:#fff;padding:10px 20px;font-weight:600;font-size:14px;border-radius:8px;transition:all .2s ease-in-out;box-shadow:0 4px 10px #5a75b640;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}.btn-submit-custom:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 6px 14px #5a75b659;background:#3E578E;border-color:#3e578e}.btn-submit-custom:active:not(:disabled){transform:translateY(0)}.btn-submit-custom:disabled{background:#ecebeb!important;border:solid 2px #ecebeb!important;color:#9c9c9c!important;cursor:not-allowed;box-shadow:none}\n"] }]
|
|
742
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: CroemCardWidgetService }]; }, propDecorators: { inputParamsForWidgetForPayment: [{
|
|
743
|
+
type: Input
|
|
744
|
+
}], widgetResponseEmitter: [{
|
|
745
|
+
type: Output
|
|
746
|
+
}], fieldResponseEmitter: [{
|
|
747
|
+
type: Output
|
|
748
|
+
}], loader: [{
|
|
749
|
+
type: Output
|
|
750
|
+
}], HandleError: [{
|
|
751
|
+
type: Output
|
|
752
|
+
}], fields: [{
|
|
753
|
+
type: Input
|
|
754
|
+
}] } });
|
|
755
|
+
|
|
756
|
+
class CroemCardWidgetComponent {
|
|
757
|
+
//-------------new updated-code---------------------//
|
|
758
|
+
handleError(data) {
|
|
759
|
+
this.HandleError.emit(data);
|
|
760
|
+
}
|
|
761
|
+
handleApiResponse(data) {
|
|
762
|
+
this.widgetResponseEmitter.emit(data);
|
|
763
|
+
}
|
|
764
|
+
getFormFields(data) {
|
|
765
|
+
this.fieldResponseEmitter.emit(data);
|
|
766
|
+
}
|
|
767
|
+
getUpdateApiResponse(data) {
|
|
768
|
+
this.getWidgetDataResponseEmitter.emit(data);
|
|
769
|
+
}
|
|
770
|
+
showloader(loader) {
|
|
771
|
+
this.loader.emit(loader);
|
|
772
|
+
}
|
|
773
|
+
constructor() {
|
|
774
|
+
this.widgetResponseEmitter = new EventEmitter();
|
|
775
|
+
this.getWidgetDataResponseEmitter = new EventEmitter();
|
|
776
|
+
this.fieldResponseEmitter = new EventEmitter();
|
|
777
|
+
this.HandleError = new EventEmitter();
|
|
778
|
+
this.loader = new EventEmitter();
|
|
779
|
+
this.fields = [];
|
|
780
|
+
this.showLoader = false;
|
|
781
|
+
}
|
|
782
|
+
ngOnInit() {
|
|
783
|
+
if (((this.inputParamsForWidget.Mode == CardMode.Edit) || (this.inputParamsForWidget.Mode == CardMode.Show)) && (!this.inputParamsForWidget.IsSale)) {
|
|
784
|
+
this.updateShow = true;
|
|
785
|
+
}
|
|
786
|
+
this.switchLanguage(this.inputParamsForWidget.Culture);
|
|
787
|
+
if (!this.inputParamsForWidget.APIKey) {
|
|
788
|
+
this.HandleError.emit("ApiKey404");
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
getFields() {
|
|
792
|
+
return this.fields;
|
|
793
|
+
}
|
|
794
|
+
switchLanguage(language) {
|
|
795
|
+
if (language === 'en') {
|
|
796
|
+
this.currentLang = LANG_EN;
|
|
797
|
+
}
|
|
798
|
+
else if (language === 'es') {
|
|
799
|
+
this.currentLang = LANG_ES;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
CroemCardWidgetComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
804
|
+
CroemCardWidgetComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: CroemCardWidgetComponent, selector: "lib-croem-card-widget", inputs: { inputParamsForWidget: "inputParamsForWidget", fields: "fields" }, outputs: { widgetResponseEmitter: "widgetResponseEmitter", getWidgetDataResponseEmitter: "getWidgetDataResponseEmitter", fieldResponseEmitter: "fieldResponseEmitter", HandleError: "HandleError", loader: "loader" }, ngImport: i0, template: "<lib-add-card-widget *ngIf=\"(this.inputParamsForWidget.APIKey)&&(inputParamsForWidget.Mode=='0')\"\r\n [inputParamsForWidgetForAdd]=\"inputParamsForWidget\" [fields]=\"getFields()\" (loader)=showloader($event)\r\n (widgetResponseEmitter)=\"handleApiResponse($event)\"\r\n (fieldResponseEmitter)=\"getFormFields($event)\"></lib-add-card-widget>\r\n\r\n\r\n<lib-payment-card-widget\r\n *ngIf=\"(this.inputParamsForWidget.APIKey)&&(inputParamsForWidget.Token)&&(inputParamsForWidget.IsSale)\" (HandleError)=\"handleError($event)\"\r\n [inputParamsForWidgetForPayment]=\"inputParamsForWidget\" [fields]=\"getFields()\"\r\n (widgetResponseEmitter)=\"handleApiResponse($event)\" (loader)=showloader($event)\r\n (fieldResponseEmitter)=\"getFormFields($event)\"></lib-payment-card-widget>\r\n\r\n\r\n<lib-update-card-widget\r\n *ngIf=\"updateShow\"\r\n [inputParamsForWidgetForUpdate]=\"inputParamsForWidget\" [fields]=\"getFields()\" (loader)=showloader($event)\r\n (widgetResponseEmitter)=\"handleApiResponse($event)\" (getWidgetDataResponseEmitter)=\"getUpdateApiResponse($event)\"\r\n (fieldResponseEmitter)=\"getFormFields($event)\"></lib-update-card-widget>\r\n ", styles: [""], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: AddCardWidgetComponent, selector: "lib-add-card-widget", inputs: ["inputParamsForWidgetForAdd", "fields"], outputs: ["widgetResponseEmitter", "fieldResponseEmitter", "loader"] }, { kind: "component", type: UpdateCardWidgetComponent, selector: "lib-update-card-widget", inputs: ["inputParamsForWidgetForUpdate", "fields"], outputs: ["widgetResponseEmitter", "getWidgetDataResponseEmitter", "fieldResponseEmitter", "loader"] }, { kind: "component", type: PaymentCardWidgetComponent, selector: "lib-payment-card-widget", inputs: ["inputParamsForWidgetForPayment", "fields"], outputs: ["widgetResponseEmitter", "fieldResponseEmitter", "loader", "HandleError"] }] });
|
|
805
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetComponent, decorators: [{
|
|
806
|
+
type: Component,
|
|
807
|
+
args: [{ selector: 'lib-croem-card-widget', template: "<lib-add-card-widget *ngIf=\"(this.inputParamsForWidget.APIKey)&&(inputParamsForWidget.Mode=='0')\"\r\n [inputParamsForWidgetForAdd]=\"inputParamsForWidget\" [fields]=\"getFields()\" (loader)=showloader($event)\r\n (widgetResponseEmitter)=\"handleApiResponse($event)\"\r\n (fieldResponseEmitter)=\"getFormFields($event)\"></lib-add-card-widget>\r\n\r\n\r\n<lib-payment-card-widget\r\n *ngIf=\"(this.inputParamsForWidget.APIKey)&&(inputParamsForWidget.Token)&&(inputParamsForWidget.IsSale)\" (HandleError)=\"handleError($event)\"\r\n [inputParamsForWidgetForPayment]=\"inputParamsForWidget\" [fields]=\"getFields()\"\r\n (widgetResponseEmitter)=\"handleApiResponse($event)\" (loader)=showloader($event)\r\n (fieldResponseEmitter)=\"getFormFields($event)\"></lib-payment-card-widget>\r\n\r\n\r\n<lib-update-card-widget\r\n *ngIf=\"updateShow\"\r\n [inputParamsForWidgetForUpdate]=\"inputParamsForWidget\" [fields]=\"getFields()\" (loader)=showloader($event)\r\n (widgetResponseEmitter)=\"handleApiResponse($event)\" (getWidgetDataResponseEmitter)=\"getUpdateApiResponse($event)\"\r\n (fieldResponseEmitter)=\"getFormFields($event)\"></lib-update-card-widget>\r\n " }]
|
|
808
|
+
}], ctorParameters: function () { return []; }, propDecorators: { inputParamsForWidget: [{
|
|
809
|
+
type: Input
|
|
810
|
+
}], widgetResponseEmitter: [{
|
|
811
|
+
type: Output
|
|
812
|
+
}], getWidgetDataResponseEmitter: [{
|
|
813
|
+
type: Output
|
|
814
|
+
}], fieldResponseEmitter: [{
|
|
815
|
+
type: Output
|
|
816
|
+
}], HandleError: [{
|
|
817
|
+
type: Output
|
|
818
|
+
}], loader: [{
|
|
819
|
+
type: Output
|
|
820
|
+
}], fields: [{
|
|
821
|
+
type: Input
|
|
822
|
+
}] } });
|
|
823
|
+
|
|
824
|
+
class CroemCardWidgetModule {
|
|
825
|
+
}
|
|
826
|
+
CroemCardWidgetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
827
|
+
CroemCardWidgetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetModule, declarations: [CroemCardWidgetComponent,
|
|
828
|
+
FieldBuilderComponent,
|
|
829
|
+
FieldBuilderComponent,
|
|
830
|
+
TextBoxComponent,
|
|
831
|
+
DropDownComponent,
|
|
832
|
+
AddCardWidgetComponent,
|
|
833
|
+
UpdateCardWidgetComponent,
|
|
834
|
+
PaymentCardWidgetComponent], imports: [FormsModule, ReactiveFormsModule, CommonModule, NgSelectModule], exports: [CroemCardWidgetComponent] });
|
|
835
|
+
CroemCardWidgetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetModule, providers: [CroemCardWidgetService], imports: [FormsModule, ReactiveFormsModule, CommonModule, NgSelectModule] });
|
|
836
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CroemCardWidgetModule, decorators: [{
|
|
837
|
+
type: NgModule,
|
|
838
|
+
args: [{
|
|
839
|
+
declarations: [
|
|
840
|
+
CroemCardWidgetComponent,
|
|
841
|
+
FieldBuilderComponent,
|
|
842
|
+
FieldBuilderComponent,
|
|
843
|
+
TextBoxComponent,
|
|
844
|
+
DropDownComponent,
|
|
845
|
+
AddCardWidgetComponent,
|
|
846
|
+
UpdateCardWidgetComponent,
|
|
847
|
+
PaymentCardWidgetComponent,
|
|
848
|
+
],
|
|
849
|
+
providers: [CroemCardWidgetService],
|
|
850
|
+
imports: [
|
|
851
|
+
FormsModule, ReactiveFormsModule, CommonModule, NgSelectModule
|
|
852
|
+
],
|
|
853
|
+
exports: [
|
|
854
|
+
CroemCardWidgetComponent
|
|
855
|
+
]
|
|
856
|
+
}]
|
|
857
|
+
}] });
|
|
858
|
+
|
|
859
|
+
/*
|
|
860
|
+
* Public API Surface of croem-card-widget
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Generated bundle index. Do not edit.
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
export { CroemCardWidgetComponent, CroemCardWidgetModule, CroemCardWidgetService, constants };
|
|
868
|
+
//# sourceMappingURL=croeminc-croem-card-widget.mjs.map
|