@miden-npm/angular 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,826 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { EventEmitter, Output, Input, ChangeDetectionStrategy, Component, ViewChild } from '@angular/core';
3
3
  import * as i1 from '@miden-npm/angular';
4
- import { getValidationErrorMessage, formatAmount, cardType, checkObjectTruthy, getQueryParams, ButtonComponent, InputComponent, SelectComponent, LabelInfoComponent, CopyComponent, CurrencyAmountComponent, IconArrowSwapComponent, RadioGroupComponent, ImageComponent, SuccessComponent, CardComponent, IconLoaderComponent, InputErrorComponent } from '@miden-npm/angular';
5
- import * as i2 from '@angular/forms';
6
- import { FormGroup, FormControl, Validators, ReactiveFormsModule } from '@angular/forms';
7
- import { tap, finalize } from 'rxjs';
8
- import * as i2$1 from '@angular/common';
4
+ import { formatAmount, RadioGroupComponent, ImageComponent, PayByCardComponent, PayByTransferComponent, PayByStableCoinComponent, SuccessComponent, CardComponent, checkObjectTruthy, IconLoaderComponent, ButtonComponent, InputErrorComponent } from '@miden-npm/angular';
5
+ import * as i2 from '@angular/common';
9
6
  import { CommonModule } from '@angular/common';
10
-
11
- class PayByCardComponent {
12
- resources;
13
- cdr;
14
- checkout;
15
- encryptService;
16
- constructor(resources, cdr, checkout, encryptService) {
17
- this.resources = resources;
18
- this.cdr = cdr;
19
- this.checkout = checkout;
20
- this.encryptService = encryptService;
21
- }
22
- secretKey = '';
23
- environment = 'sandbox';
24
- paymentObject = {
25
- merchantName: '',
26
- amount: 0,
27
- currency: '',
28
- email: '',
29
- phoneNumber: '',
30
- narration: '',
31
- redirectUrl: '',
32
- };
33
- paymentAuthorized = new EventEmitter();
34
- onError = new EventEmitter();
35
- loading = false;
36
- loadingCountries = false;
37
- loadingStates = false;
38
- isMakingPayment = false;
39
- cardType = '';
40
- message = '';
41
- transactionReference = '';
42
- rawCountries = [];
43
- countries = [];
44
- countryStates = [];
45
- formIndex = 0;
46
- setFormIndex(index) {
47
- this.formIndex = index;
48
- }
49
- billingForm = new FormGroup({
50
- address1: new FormControl('', [Validators.required]),
51
- address2: new FormControl(''),
52
- postalCode: new FormControl('', [Validators.required]),
53
- state: new FormControl('', [Validators.required]),
54
- city: new FormControl('', [Validators.required]),
55
- country: new FormControl('', [Validators.required]),
56
- emailAddress: new FormControl('', [Validators.required, Validators.email]),
57
- phoneNumber: new FormControl('', [Validators.required]),
58
- });
59
- payForm = new FormGroup({
60
- customerName: new FormControl('', [Validators.required]),
61
- cardNo: new FormControl('', [Validators.required]),
62
- expireDate: new FormControl('', [Validators.required]),
63
- cvv: new FormControl('', [Validators.required]),
64
- cardPin: new FormControl(''), // Only required for Verve cards
65
- });
66
- getError(formKey, controlName, label) {
67
- const control = formKey === 'billing' ? this.billingForm.get(controlName) : this.payForm.get(controlName);
68
- return getValidationErrorMessage(control, label);
69
- }
70
- get formatAmountHandler() {
71
- return formatAmount(this.paymentObject.amount, this.paymentObject.currency);
72
- }
73
- cardNumberInputHandler(event) {
74
- this.cardType = cardType(event);
75
- this.updatePinValidation();
76
- }
77
- updatePinValidation() {
78
- const cardPinControl = this.payForm.get('cardPin');
79
- if (this.cardType === 'Verve') {
80
- cardPinControl?.setValidators([Validators.required]);
81
- }
82
- else {
83
- cardPinControl?.clearValidators();
84
- }
85
- cardPinControl?.updateValueAndValidity();
86
- }
87
- async getAllCountries() {
88
- this.loadingCountries = true;
89
- this.cdr.markForCheck();
90
- this.resources
91
- .getCountries(this.environment, this.secretKey)
92
- .pipe(tap((res) => {
93
- if (res?.isSuccessful) {
94
- this.rawCountries = res.data ?? [];
95
- this.countries = (res.data ?? []).map((c) => {
96
- return { label: c.countryName, value: c.iso2 };
97
- });
98
- }
99
- }), finalize(() => {
100
- this.loadingCountries = false;
101
- this.cdr.markForCheck();
102
- }))
103
- .subscribe();
104
- }
105
- async getCountryStates(countryIso2) {
106
- const country = this.rawCountries.filter((c) => c.iso2 === countryIso2);
107
- this.loadingStates = true;
108
- this.cdr.markForCheck();
109
- this.resources
110
- .getCountryStates(country[0].iso3, this.environment, this.secretKey)
111
- .pipe(tap((res) => {
112
- if (res?.isSuccessful) {
113
- this.countryStates = (res.data ?? []).map((s) => {
114
- return { label: s.name, value: s.name };
115
- });
116
- }
117
- }), finalize(() => {
118
- this.loadingStates = false;
119
- this.cdr.markForCheck();
120
- }))
121
- .subscribe();
122
- }
123
- async generatePaymentLinkHandler() {
124
- if (!this.secretKey) {
125
- return (this.message = 'Secret key is required.');
126
- }
127
- if (!checkObjectTruthy(this.paymentObject)) {
128
- return (this.message = 'Kindly ensure you are passing all the required data.');
129
- }
130
- this.loading = true;
131
- this.cdr.markForCheck();
132
- this.checkout
133
- .createPaymentLink(this.paymentObject, this.environment, this.secretKey)
134
- .pipe(tap((res) => {
135
- if (res?.isSuccessful) {
136
- this.message = 'Payment link created successfully';
137
- const queryParams = getQueryParams(res.launchUrl ?? '');
138
- this.transactionReference = queryParams['paymentReference'];
139
- }
140
- else {
141
- this.message = 'Failed to create payment link';
142
- }
143
- }), finalize(() => {
144
- this.loading = false;
145
- this.cdr.markForCheck();
146
- }))
147
- .subscribe();
148
- }
149
- async proceedHandler() {
150
- if (this.formIndex === 0) {
151
- if (this.billingForm && this.billingForm.valid) {
152
- this.checkout.setBillingInfo({ ...this.billingForm.value });
153
- this.setFormIndex(1);
154
- }
155
- else {
156
- this.billingForm.markAllAsTouched();
157
- }
158
- }
159
- else {
160
- if (this.payForm && this.payForm.valid) {
161
- try {
162
- this.isMakingPayment = true;
163
- // Create card details object for encryption
164
- const cardDetails = {
165
- pan: this.payForm.value.cardNo ?? '',
166
- expiryDate: this.payForm.value.expireDate ?? '',
167
- cvv: this.payForm.value.cvv ?? '',
168
- cardScheme: this.cardType,
169
- nameOnCard: this.payForm.value.customerName ?? '',
170
- ...(this.cardType === 'Verve' && { pin: this.payForm.value.cardPin ?? '' }),
171
- };
172
- // Get billing details from the form control
173
- const billingDetails = {
174
- address2: this.billingForm.value.address2 ?? '',
175
- address1: this.billingForm.value.address1 ?? '',
176
- postalCode: this.billingForm.value.postalCode ?? '',
177
- state: this.billingForm.value.state ?? '',
178
- city: this.billingForm.value.city ?? '',
179
- country: this.billingForm.value.country ?? '',
180
- emailAddress: this.billingForm.value.emailAddress ?? '',
181
- phoneNumber: this.billingForm.value.phoneNumber ?? '',
182
- };
183
- // Encrypt card details using payload encryption method
184
- const encryptedCardDetails = this.encryptService.encryptPayload(this.secretKey, cardDetails);
185
- // Test: Decrypt to verify encryption works
186
- // const decryptedTest = this.encryptService.decryptPayload(
187
- // this.environment,
188
- // encryptedCardDetails.requestParam,
189
- // );
190
- const payload = {
191
- customerId: this.paymentObject?.email || this.payForm.value.customerName || '',
192
- amount: this.paymentObject?.amount.toString(),
193
- currency: this.paymentObject?.currency || 'USD',
194
- narration: this.paymentObject?.narration || 'Test transaction',
195
- encryptedCardDetails: encryptedCardDetails.requestParam, // Use the encrypted card details
196
- billingDetails: billingDetails,
197
- redirectUrl: this.paymentObject?.redirectUrl || '',
198
- paymentReference: this.transactionReference,
199
- isCheckout: true,
200
- };
201
- this.checkout
202
- .authorizeCardPayment(this.environment, {
203
- ...payload,
204
- merchantId: this.secretKey,
205
- })
206
- .subscribe({
207
- next: async (response) => {
208
- let processedResponse = response;
209
- // Check if response is encrypted (has responseParam)
210
- if (response?.responseParam) {
211
- // Decrypt the response
212
- processedResponse = this.encryptService.decryptPayload(this.environment, response.responseParam);
213
- }
214
- if (processedResponse?.isSuccessful) {
215
- // Check for 3DS authentication requirement
216
- if (processedResponse.threeDsInteractionRequired === true) {
217
- // Store 3DS data for the authentication page
218
- const threeDsData = {
219
- transactionReference: processedResponse.transactionReference,
220
- threeDsHtml: processedResponse.threeDsHtml,
221
- amount: processedResponse.amount,
222
- responseMessage: processedResponse.responseMessage,
223
- // Pass all 3DS details
224
- paReq: processedResponse.threeDsHtml?.paReq,
225
- termUrl: processedResponse.threeDsHtml?.termUrl,
226
- action: processedResponse.threeDsHtml?.action,
227
- acsUrl: processedResponse.threeDsHtml?.acsUrl,
228
- md: processedResponse.threeDsHtml?.md,
229
- };
230
- // Encrypt 3DS data to pass as url param
231
- const stringifiedThreeDsData = btoa(JSON.stringify(threeDsData));
232
- // Open 3DS authentication page in a new tab
233
- const threeDsUrl = `https://sandbox-merchant.buzapay.com/account/three-ds-confirm?threeDsData=${encodeURIComponent(stringifiedThreeDsData)}&paymentReference=${processedResponse.transactionReference}`;
234
- window.open(threeDsUrl, '_self', 'noopener,noreferrer');
235
- this.message =
236
- '3D Secure authentication opened in new tab. Please complete the verification';
237
- this.isMakingPayment = false;
238
- return;
239
- }
240
- // Fallback check: if response message indicates 3DS is required
241
- if (processedResponse.responseMessage === 'Payer Interaction Required' &&
242
- processedResponse.threeDsHtml) {
243
- // Store 3DS data for the authentication page
244
- const threeDsData = {
245
- transactionReference: processedResponse.transactionReference,
246
- threeDsHtml: processedResponse.threeDsHtml,
247
- amount: processedResponse.amount,
248
- responseMessage: processedResponse.responseMessage,
249
- // Pass all 3DS details
250
- paReq: processedResponse.threeDsHtml?.paReq,
251
- termUrl: processedResponse.threeDsHtml?.termUrl,
252
- action: processedResponse.threeDsHtml?.action,
253
- acsUrl: processedResponse.threeDsHtml?.acsUrl,
254
- md: processedResponse.threeDsHtml?.md,
255
- };
256
- // Encrypt 3DS data to pass as url param
257
- const stringifiedThreeDsData = btoa(JSON.stringify(threeDsData));
258
- // Open 3DS authentication page in a new tab
259
- const threeDsUrl = `https://sandbox-merchant.buzapay.com/account/three-ds-confirm?threeDsData=${encodeURIComponent(stringifiedThreeDsData)}&paymentReference=${processedResponse.transactionReference}`;
260
- window.open(threeDsUrl, '_self', 'noopener,noreferrer');
261
- this.message =
262
- '3D Secure authentication opened in new tab. Please complete the verification';
263
- this.isMakingPayment = false;
264
- return;
265
- }
266
- // Emit the transaction reference to parent component
267
- if (processedResponse.transactionReference &&
268
- processedResponse.transactionReference.trim() !== '') {
269
- this.paymentAuthorized.emit({
270
- paymentId: processedResponse.transactionReference,
271
- paymentDate: response.data.updatedAt,
272
- paymentStatus: 'authorized',
273
- message: this.message,
274
- });
275
- }
276
- this.message = 'Card payment authorized successfully';
277
- // Handle legacy 3DS logic for backward compatibility
278
- // if (processedResponse.provider === 'myRoute2') {
279
- // if (processedResponse.requires3DS === true) {
280
- // this.router.navigateByUrl('account/visa-card-payment-confirm');
281
- // } else {
282
- // if (processedResponse.responseCode === 'T00') {
283
- // } else if (processedResponse.responseCode === '000') {
284
- // this.message = 'Please confirm transaction !!';
285
- // } else {
286
- // this.message = processedResponse.responseMessage;
287
- // }
288
- // }
289
- // } else if (processedResponse.provider === 'myRoute1') {
290
- // if (processedResponse.requires3DS === true) {
291
- // this.router.navigateByUrl('account/visa-card-payment-confirm2');
292
- // }
293
- // }
294
- this.isMakingPayment = false;
295
- }
296
- else {
297
- this.isMakingPayment = false;
298
- this.message = processedResponse.responseMessage || 'Payment failed';
299
- this.paymentAuthorized.emit({
300
- paymentId: processedResponse.transactionReference,
301
- paymentDate: response.data.updatedAt,
302
- paymentStatus: 'payment failed',
303
- message: this.message,
304
- });
305
- }
306
- },
307
- error: (err) => {
308
- this.isMakingPayment = false;
309
- if (err.error?.responseParam) {
310
- // Decrypt error response
311
- const decryptedErrorResponse = this.encryptService.decryptPayload(this.environment, err.error.responseParam);
312
- this.message = decryptedErrorResponse.responseMessage || 'Payment failed';
313
- }
314
- else {
315
- this.message = err.error.responseMessage || err.error.message || 'Payment failed';
316
- }
317
- this.onError.emit({ errorMessage: this.message });
318
- },
319
- });
320
- }
321
- catch (error) {
322
- this.isMakingPayment = false;
323
- this.message = 'An unexpected error occurred';
324
- this.onError.emit({ errorMessage: this.message });
325
- }
326
- }
327
- else {
328
- this.payForm.markAllAsTouched();
329
- }
330
- }
331
- }
332
- async ngOnInit() {
333
- await this.generatePaymentLinkHandler();
334
- await this.getAllCountries();
335
- }
336
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: PayByCardComponent, deps: [{ token: i1.ResourceService }, { token: i0.ChangeDetectorRef }, { token: i1.CheckoutService }, { token: i1.EncryptService }], target: i0.ɵɵFactoryTarget.Component });
337
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: PayByCardComponent, isStandalone: true, selector: "pay-by-card", inputs: { secretKey: "secretKey", environment: "environment", paymentObject: "paymentObject" }, outputs: { paymentAuthorized: "paymentAuthorized", onError: "onError" }, ngImport: i0, template: "<div class=\"flex flex-col gap-6\">\n <!-- Billing Details -->\n @if (formIndex === 0) {\n <form [formGroup]=\"billingForm\">\n <div class=\"grid grid-cols-2 gap-6 overflow-y-auto\">\n <div class=\"col-span-2\">\n <base-input\n formControlName=\"address1\"\n label=\"Address Line 1\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'address1', 'Address Line 1') || ''\"\n ></base-input>\n </div>\n <div class=\"col-span-2\">\n <base-input formControlName=\"address2\" label=\"Address Line 2\"></base-input>\n </div>\n <base-select\n formControlName=\"country\"\n label=\"Select Country\"\n [required]=\"true\"\n [options]=\"countries\"\n [loading]=\"loadingCountries\"\n [validationError]=\"getError('billing', 'country', 'Country') || ''\"\n (onSelectChange)=\"getCountryStates($event)\"\n ></base-select>\n <base-select\n formControlName=\"state\"\n label=\"Select State\"\n [required]=\"true\"\n [options]=\"countryStates\"\n [loading]=\"loadingStates\"\n [validationError]=\"getError('billing', 'state', 'State') || ''\"\n ></base-select>\n <base-input\n formControlName=\"city\"\n label=\"City\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'city', 'City') || ''\"\n ></base-input>\n <base-input\n formControlName=\"postalCode\"\n label=\"Postal Code\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'postalCode', 'Postal Code') || ''\"\n ></base-input>\n <base-input\n formControlName=\"emailAddress\"\n label=\"Email\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'emailAddress', 'Email Address') || ''\"\n ></base-input>\n <base-input\n formControlName=\"phoneNumber\"\n label=\"Phone Number\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'phoneNumber', 'Phone Number') || ''\"\n ></base-input>\n </div>\n </form>\n }\n\n <!-- Card Details -->\n @if (formIndex === 1) {\n <form [formGroup]=\"payForm\">\n <div class=\"grid grid-cols-2 gap-6 overflow-y-auto\" style=\"max-height: 320px\">\n <div class=\"col-span-2\">\n <base-input\n formControlName=\"customerName\"\n label=\"Card Name\"\n [required]=\"true\"\n [validationError]=\"getError('pay', 'customerName', 'Customer Name') || ''\"\n ></base-input>\n </div>\n <div class=\"col-span-2\">\n <base-input\n formControlName=\"cardNo\"\n label=\"Card Number\"\n [required]=\"true\"\n mask=\"0000 0000 0000 0000\"\n placeholder=\"0000 0000 0000 0000\"\n [preventPaste]=\"true\"\n [validationError]=\"getError('pay', 'cardNo', 'Card Number') || ''\"\n (onInputChange)=\"cardNumberInputHandler($event)\"\n ></base-input>\n </div>\n <base-input\n formControlName=\"expireDate\"\n label=\"Expiry Date\"\n [required]=\"true\"\n mask=\"00/00\"\n placeholder=\"00/00\"\n [validationError]=\"getError('pay', 'expireDate', 'Expiry Date') || ''\"\n ></base-input>\n <base-input\n formControlName=\"cvv\"\n label=\"CVV\"\n [required]=\"true\"\n mask=\"000\"\n placeholder=\"000\"\n [validationError]=\"getError('pay', 'cvv', 'CVV') || ''\"\n ></base-input>\n\n @if (cardType === 'Verve') {\n <base-input\n formControlName=\"cardPin\"\n label=\"Card Pin\"\n type=\"password\"\n placeholder=\"0000\"\n mask=\"0000\"\n [required]=\"true\"\n [validationError]=\"getError('pay', 'cardPin', 'Card Pin') || ''\"\n ></base-input>\n <div class=\"text-sm text-blue-600 mb-4\">\n <i class=\"fas fa-info-circle mr-1\"></i>\n Pin is required for Verve cards\n </div>\n }\n </div>\n </form>\n }\n\n <base-button\n [label]=\"formIndex === 0 ? 'Proceed' : 'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isMakingPayment\"\n (onClick)=\"proceedHandler()\"\n ></base-button>\n</div>\n", dependencies: [{ kind: "component", type: ButtonComponent, selector: "base-button", inputs: ["label", "type", "size", "paddingClassX", "disabled", "loading", "customClass"], outputs: ["onClick"] }, { kind: "component", type: InputComponent, selector: "base-input", inputs: ["label", "type", "placeholder", "validationError", "hint", "mask", "rules", "isAmountInput", "required", "disabled", "loading", "showCopyIcon", "preventPaste"], outputs: ["onInputChange", "onInputBlur"] }, { kind: "component", type: SelectComponent, selector: "base-select", inputs: ["options", "placeholder", "hasSearch", "disabled", "loading", "validationError", "label", "hint", "required", "itemImageType"], outputs: ["onSelectChange"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
338
- }
339
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: PayByCardComponent, decorators: [{
340
- type: Component,
341
- args: [{ selector: 'pay-by-card', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [ButtonComponent, InputComponent, SelectComponent, ReactiveFormsModule], template: "<div class=\"flex flex-col gap-6\">\n <!-- Billing Details -->\n @if (formIndex === 0) {\n <form [formGroup]=\"billingForm\">\n <div class=\"grid grid-cols-2 gap-6 overflow-y-auto\">\n <div class=\"col-span-2\">\n <base-input\n formControlName=\"address1\"\n label=\"Address Line 1\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'address1', 'Address Line 1') || ''\"\n ></base-input>\n </div>\n <div class=\"col-span-2\">\n <base-input formControlName=\"address2\" label=\"Address Line 2\"></base-input>\n </div>\n <base-select\n formControlName=\"country\"\n label=\"Select Country\"\n [required]=\"true\"\n [options]=\"countries\"\n [loading]=\"loadingCountries\"\n [validationError]=\"getError('billing', 'country', 'Country') || ''\"\n (onSelectChange)=\"getCountryStates($event)\"\n ></base-select>\n <base-select\n formControlName=\"state\"\n label=\"Select State\"\n [required]=\"true\"\n [options]=\"countryStates\"\n [loading]=\"loadingStates\"\n [validationError]=\"getError('billing', 'state', 'State') || ''\"\n ></base-select>\n <base-input\n formControlName=\"city\"\n label=\"City\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'city', 'City') || ''\"\n ></base-input>\n <base-input\n formControlName=\"postalCode\"\n label=\"Postal Code\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'postalCode', 'Postal Code') || ''\"\n ></base-input>\n <base-input\n formControlName=\"emailAddress\"\n label=\"Email\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'emailAddress', 'Email Address') || ''\"\n ></base-input>\n <base-input\n formControlName=\"phoneNumber\"\n label=\"Phone Number\"\n [required]=\"true\"\n [validationError]=\"getError('billing', 'phoneNumber', 'Phone Number') || ''\"\n ></base-input>\n </div>\n </form>\n }\n\n <!-- Card Details -->\n @if (formIndex === 1) {\n <form [formGroup]=\"payForm\">\n <div class=\"grid grid-cols-2 gap-6 overflow-y-auto\" style=\"max-height: 320px\">\n <div class=\"col-span-2\">\n <base-input\n formControlName=\"customerName\"\n label=\"Card Name\"\n [required]=\"true\"\n [validationError]=\"getError('pay', 'customerName', 'Customer Name') || ''\"\n ></base-input>\n </div>\n <div class=\"col-span-2\">\n <base-input\n formControlName=\"cardNo\"\n label=\"Card Number\"\n [required]=\"true\"\n mask=\"0000 0000 0000 0000\"\n placeholder=\"0000 0000 0000 0000\"\n [preventPaste]=\"true\"\n [validationError]=\"getError('pay', 'cardNo', 'Card Number') || ''\"\n (onInputChange)=\"cardNumberInputHandler($event)\"\n ></base-input>\n </div>\n <base-input\n formControlName=\"expireDate\"\n label=\"Expiry Date\"\n [required]=\"true\"\n mask=\"00/00\"\n placeholder=\"00/00\"\n [validationError]=\"getError('pay', 'expireDate', 'Expiry Date') || ''\"\n ></base-input>\n <base-input\n formControlName=\"cvv\"\n label=\"CVV\"\n [required]=\"true\"\n mask=\"000\"\n placeholder=\"000\"\n [validationError]=\"getError('pay', 'cvv', 'CVV') || ''\"\n ></base-input>\n\n @if (cardType === 'Verve') {\n <base-input\n formControlName=\"cardPin\"\n label=\"Card Pin\"\n type=\"password\"\n placeholder=\"0000\"\n mask=\"0000\"\n [required]=\"true\"\n [validationError]=\"getError('pay', 'cardPin', 'Card Pin') || ''\"\n ></base-input>\n <div class=\"text-sm text-blue-600 mb-4\">\n <i class=\"fas fa-info-circle mr-1\"></i>\n Pin is required for Verve cards\n </div>\n }\n </div>\n </form>\n }\n\n <base-button\n [label]=\"formIndex === 0 ? 'Proceed' : 'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isMakingPayment\"\n (onClick)=\"proceedHandler()\"\n ></base-button>\n</div>\n" }]
342
- }], ctorParameters: () => [{ type: i1.ResourceService }, { type: i0.ChangeDetectorRef }, { type: i1.CheckoutService }, { type: i1.EncryptService }], propDecorators: { secretKey: [{
343
- type: Input
344
- }], environment: [{
345
- type: Input
346
- }], paymentObject: [{
347
- type: Input
348
- }], paymentAuthorized: [{
349
- type: Output
350
- }], onError: [{
351
- type: Output
352
- }] } });
353
-
354
- class PayByTransferComponent {
355
- checkout;
356
- cdr;
357
- constructor(checkout, cdr) {
358
- this.checkout = checkout;
359
- this.cdr = cdr;
360
- }
361
- secretKey = '';
362
- environment = '';
363
- paymentObject = {
364
- merchantName: '',
365
- amount: 0,
366
- currency: '',
367
- email: '',
368
- phoneNumber: '',
369
- narration: '',
370
- redirectUrl: '',
371
- };
372
- paymentAuthorized = new EventEmitter();
373
- onError = new EventEmitter();
374
- message = '';
375
- generatingLink = false;
376
- isMakingPayment = false;
377
- isFetchingPaymentDetails = false;
378
- isConfirmCall = false;
379
- paymentMade = false;
380
- isPaymentConfirmed = false;
381
- paymentAccountDetails = null;
382
- paymentReferenceDetails = null;
383
- transactionReference = '';
384
- paymentReferenceStatus = '';
385
- countDownTime = '';
386
- remainingSeconds = 30 * 60;
387
- intervalId = null;
388
- updateDisplay() {
389
- const minutes = Math.floor(this.remainingSeconds / 60);
390
- const seconds = this.remainingSeconds % 60;
391
- this.countDownTime = `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
392
- this.cdr.markForCheck(); // 👈 notify OnPush to re-render
393
- }
394
- transferForm = new FormGroup({
395
- customerName: new FormControl('', [Validators.required]),
396
- });
397
- getError(controlName, label) {
398
- const control = this.transferForm.get(controlName);
399
- return getValidationErrorMessage(control, label);
400
- }
401
- get formatAmountHandler() {
402
- return formatAmount(this.paymentObject.amount, this.paymentObject.currency);
403
- }
404
- startTimer() {
405
- if (this.intervalId) {
406
- clearInterval(this.intervalId);
407
- this.intervalId = null;
408
- }
409
- this.updateDisplay();
410
- this.intervalId = setInterval(() => {
411
- this.remainingSeconds--;
412
- if (this.remainingSeconds < 0) {
413
- clearInterval(this.intervalId);
414
- this.intervalId = null;
415
- this.countDownTime = '00:00';
416
- this.cdr.markForCheck();
417
- return;
418
- }
419
- this.updateDisplay();
420
- }, 1000);
421
- }
422
- async generatePaymentLinkHandler() {
423
- if (!this.secretKey) {
424
- return (this.message = 'Secret key is required.');
425
- }
426
- if (!checkObjectTruthy(this.paymentObject)) {
427
- return (this.message = 'Kindly ensure you are passing all the required data.');
428
- }
429
- this.generatingLink = true;
430
- this.cdr.markForCheck();
431
- this.checkout
432
- .createPaymentLink(this.paymentObject, this.environment, this.secretKey)
433
- .pipe(tap((res) => {
434
- if (res?.isSuccessful) {
435
- this.message = 'Payment link created successfully';
436
- const queryParams = getQueryParams(res.launchUrl ?? '');
437
- this.transactionReference = queryParams['paymentReference'];
438
- }
439
- else {
440
- this.message = 'Failed to create payment link';
441
- }
442
- }), finalize(() => {
443
- this.generatingLink = false;
444
- this.cdr.markForCheck();
445
- }))
446
- .subscribe();
447
- }
448
- async payHandler() {
449
- if (this.transferForm && this.transferForm.valid) {
450
- const payload = {
451
- paymentReference: this.transactionReference,
452
- channel: 'virtual_account',
453
- customerName: this.transferForm.value.customerName ?? '',
454
- merchantId: this.secretKey,
455
- };
456
- this.isMakingPayment = true;
457
- await this.checkout.generatePaymentAccount(this.environment, payload).subscribe({
458
- next: async (response) => {
459
- if (response?.isSuccessful) {
460
- this.paymentAccountDetails = response.data;
461
- this.startTimer();
462
- this.message = 'Virtual account generated successfully for payment.';
463
- this.isMakingPayment = false;
464
- }
465
- },
466
- error: (err) => {
467
- this.isMakingPayment = false;
468
- this.message = err.error.responseMessage || err.error.message;
469
- this.onError.emit({ errorMessage: this.message });
470
- },
471
- });
472
- }
473
- else {
474
- this.transferForm?.markAllAsTouched();
475
- }
476
- }
477
- async getReferenceDetails() {
478
- this.isFetchingPaymentDetails = true;
479
- await this.checkout
480
- .getPaymentReferenceDetails(this.environment, this.transactionReference)
481
- .subscribe({
482
- next: async (response) => {
483
- if (response?.isSuccessful) {
484
- this.paymentReferenceDetails = response.data;
485
- // Check if payment has been made (paymentStatus is "Payment Received")
486
- if (response.data?.paymentStatus === 'Payment Received') {
487
- this.paymentMade = true;
488
- }
489
- if (response.data?.finalTransactionStatus === null ||
490
- response.data?.paymentStatus === null) {
491
- if (this.isConfirmCall) {
492
- this.message = 'Transaction not confirmed !!';
493
- }
494
- // Only set to pending if payment hasn't been confirmed locally or made locally
495
- if (!this.isPaymentConfirmed && !this.paymentMade) {
496
- this.paymentReferenceStatus = 'pending';
497
- this.paymentAuthorized.emit({
498
- paymentId: this.transactionReference,
499
- paymentDate: response.data.updatedAt,
500
- paymentStatus: this.paymentReferenceStatus,
501
- message: this.message,
502
- });
503
- }
504
- else {
505
- this.paymentReferenceStatus = 'confirmed';
506
- this.paymentAuthorized.emit({
507
- paymentId: this.transactionReference,
508
- paymentDate: response.data.updatedAt,
509
- paymentStatus: this.paymentReferenceStatus,
510
- message: this.message,
511
- });
512
- }
513
- }
514
- else if (response.data?.finalTransactionStatus === 'Success' ||
515
- response.data?.paymentStatus === 'Received' ||
516
- response.data?.paymentStatus === 'Payment Received') {
517
- this.paymentAuthorized.emit({
518
- paymentId: this.transactionReference,
519
- paymentDate: response.data.updatedAt,
520
- paymentStatus: this.paymentReferenceStatus,
521
- message: this.message,
522
- });
523
- this.message = 'Transaction confirmed !!';
524
- this.paymentReferenceStatus = 'confirmed';
525
- this.isPaymentConfirmed = true;
526
- }
527
- }
528
- else if (!response?.isSuccessful && response?.responseCode === '119') {
529
- this.paymentReferenceStatus = 'used';
530
- this.message = response.responseMessage;
531
- this.paymentAuthorized.emit({
532
- paymentId: this.transactionReference,
533
- paymentDate: null,
534
- paymentStatus: this.paymentReferenceStatus,
535
- message: this.message,
536
- });
537
- }
538
- this.isFetchingPaymentDetails = false;
539
- },
540
- error: (err) => {
541
- this.paymentReferenceStatus = '';
542
- this.isFetchingPaymentDetails = false;
543
- this.message = err.error.responseMessage || err.error.message;
544
- this.onError.emit({ errorMessage: this.message });
545
- },
546
- });
547
- }
548
- async ngOnInit() {
549
- this.startTimer();
550
- await this.generatePaymentLinkHandler();
551
- }
552
- ngOnDestroy() {
553
- if (this.intervalId) {
554
- clearInterval(this.intervalId);
555
- this.intervalId = null;
556
- }
557
- }
558
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: PayByTransferComponent, deps: [{ token: i1.CheckoutService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
559
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: PayByTransferComponent, isStandalone: true, selector: "pay-by-transfer", inputs: { secretKey: "secretKey", environment: "environment", paymentObject: "paymentObject" }, outputs: { paymentAuthorized: "paymentAuthorized", onError: "onError" }, ngImport: i0, template: "<div class=\"flex flex-col gap-10\">\n @if (!paymentAccountDetails) {\n <form [formGroup]=\"transferForm\">\n <div class=\"flex flex-col gap-10\">\n <base-input\n formControlName=\"customerName\"\n label=\"Customer Name\"\n [required]=\"true\"\n [validationError]=\"getError('customerName', 'Customer Name') || ''\"\n ></base-input>\n\n <base-button\n [label]=\"'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isMakingPayment\"\n (onClick)=\"payHandler()\"\n ></base-button>\n </div>\n </form>\n }\n\n @if (paymentAccountDetails) {\n <div class=\"flex flex-col gap-10\">\n <div class=\"bg-[#EFF7FF] p-4 rounded-lg flex flex-col gap-6\">\n <base-label-info\n label=\"Bank Name\"\n [value]=\"paymentAccountDetails.bank + ' - ' + paymentAccountDetails.accountName\"\n ></base-label-info>\n <div class=\"flex items-center justify-between\">\n <base-label-info\n label=\"Account Number\"\n [value]=\"paymentAccountDetails.accountNumber\"\n ></base-label-info>\n <base-copy color=\"#9DBFDE\" [copyText]=\"paymentAccountDetails.accountNumber\"></base-copy>\n </div>\n <div class=\"flex items-center justify-between\">\n <base-label-info label=\"Amount\" [value]=\"formatAmountHandler\"></base-label-info>\n <base-copy color=\"#9DBFDE\" [copyText]=\"formatAmountHandler\"></base-copy>\n </div>\n </div>\n\n <p class=\"w-2/3 mx-auto text-center text-body-2xs font-medium text-sub-copy\">\n This account is for this transaction only and expires in\n <span class=\"text-orange-500\">{{ countDownTime }}</span>\n </p>\n\n <div class=\"flex flex-col gap-4\">\n <base-button\n label=\"I have paid the money\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isFetchingPaymentDetails\"\n (onClick)=\"getReferenceDetails()\"\n ></base-button>\n <p class=\"text-heading-text text-body-2xs font-medium text-center py-2 cursor-pointer\">\n Cancel Payment\n </p>\n </div>\n </div>\n }\n</div>\n", dependencies: [{ kind: "component", type: LabelInfoComponent, selector: "base-label-info", inputs: ["type", "label", "labelCustomClass", "valueImageSrc", "valueImageCustomClass", "valueImagePosition", "hasValueCopy", "value", "valueCustomClass", "alignRight"] }, { kind: "component", type: CopyComponent, selector: "base-copy", inputs: ["copyText", "color"] }, { kind: "component", type: ButtonComponent, selector: "base-button", inputs: ["label", "type", "size", "paddingClassX", "disabled", "loading", "customClass"], outputs: ["onClick"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: InputComponent, selector: "base-input", inputs: ["label", "type", "placeholder", "validationError", "hint", "mask", "rules", "isAmountInput", "required", "disabled", "loading", "showCopyIcon", "preventPaste"], outputs: ["onInputChange", "onInputBlur"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
560
- }
561
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: PayByTransferComponent, decorators: [{
562
- type: Component,
563
- args: [{ selector: 'pay-by-transfer', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
564
- LabelInfoComponent,
565
- CopyComponent,
566
- ButtonComponent,
567
- ReactiveFormsModule,
568
- InputComponent,
569
- ], template: "<div class=\"flex flex-col gap-10\">\n @if (!paymentAccountDetails) {\n <form [formGroup]=\"transferForm\">\n <div class=\"flex flex-col gap-10\">\n <base-input\n formControlName=\"customerName\"\n label=\"Customer Name\"\n [required]=\"true\"\n [validationError]=\"getError('customerName', 'Customer Name') || ''\"\n ></base-input>\n\n <base-button\n [label]=\"'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isMakingPayment\"\n (onClick)=\"payHandler()\"\n ></base-button>\n </div>\n </form>\n }\n\n @if (paymentAccountDetails) {\n <div class=\"flex flex-col gap-10\">\n <div class=\"bg-[#EFF7FF] p-4 rounded-lg flex flex-col gap-6\">\n <base-label-info\n label=\"Bank Name\"\n [value]=\"paymentAccountDetails.bank + ' - ' + paymentAccountDetails.accountName\"\n ></base-label-info>\n <div class=\"flex items-center justify-between\">\n <base-label-info\n label=\"Account Number\"\n [value]=\"paymentAccountDetails.accountNumber\"\n ></base-label-info>\n <base-copy color=\"#9DBFDE\" [copyText]=\"paymentAccountDetails.accountNumber\"></base-copy>\n </div>\n <div class=\"flex items-center justify-between\">\n <base-label-info label=\"Amount\" [value]=\"formatAmountHandler\"></base-label-info>\n <base-copy color=\"#9DBFDE\" [copyText]=\"formatAmountHandler\"></base-copy>\n </div>\n </div>\n\n <p class=\"w-2/3 mx-auto text-center text-body-2xs font-medium text-sub-copy\">\n This account is for this transaction only and expires in\n <span class=\"text-orange-500\">{{ countDownTime }}</span>\n </p>\n\n <div class=\"flex flex-col gap-4\">\n <base-button\n label=\"I have paid the money\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isFetchingPaymentDetails\"\n (onClick)=\"getReferenceDetails()\"\n ></base-button>\n <p class=\"text-heading-text text-body-2xs font-medium text-center py-2 cursor-pointer\">\n Cancel Payment\n </p>\n </div>\n </div>\n }\n</div>\n" }]
570
- }], ctorParameters: () => [{ type: i1.CheckoutService }, { type: i0.ChangeDetectorRef }], propDecorators: { secretKey: [{
571
- type: Input
572
- }], environment: [{
573
- type: Input
574
- }], paymentObject: [{
575
- type: Input
576
- }], paymentAuthorized: [{
577
- type: Output
578
- }], onError: [{
579
- type: Output
580
- }] } });
581
-
582
- class PayByStableCoinComponent {
583
- resource;
584
- checkout;
585
- cdr;
586
- constructor(resource, checkout, cdr) {
587
- this.resource = resource;
588
- this.checkout = checkout;
589
- this.cdr = cdr;
590
- }
591
- secretKey = '';
592
- environment = '';
593
- paymentObject = {
594
- merchantName: '',
595
- amount: 0,
596
- currency: '',
597
- email: '',
598
- phoneNumber: '',
599
- narration: '',
600
- redirectUrl: '',
601
- };
602
- paymentAuthorized = new EventEmitter();
603
- onError = new EventEmitter();
604
- message = '';
605
- transactionReference = '';
606
- paymentReferenceStatus = '';
607
- generateAddressPayload = null;
608
- addressDetails = null;
609
- paymentReferenceDetails = null;
610
- stableCoins = [];
611
- networkList = [];
612
- loadingStableCoins = false;
613
- generatingAddress = false;
614
- isConfirmingPayment = false;
615
- loading = false;
616
- loadingStableCoinNetworks = false;
617
- formIndex = 0;
618
- setFormIndex(index) {
619
- this.formIndex = index;
620
- }
621
- stableCoinForm = new FormGroup({
622
- stableCoin: new FormControl('', [Validators.required]),
623
- network: new FormControl('', [Validators.required]),
624
- });
625
- getError(controlName, label) {
626
- const control = this.stableCoinForm.get(controlName);
627
- return getValidationErrorMessage(control, label);
628
- }
629
- get formatAmountHandler() {
630
- return formatAmount(this.paymentObject.amount, this.paymentObject.currency);
631
- }
632
- get amountPlusNetworkFee() {
633
- return this.addressDetails
634
- ? Number(this.addressDetails.transactionAmount) + this.addressDetails.networkFee
635
- : 0;
636
- }
637
- async generatePaymentLinkHandler() {
638
- if (!this.secretKey) {
639
- return (this.message = 'Secret key is required.');
640
- }
641
- if (!checkObjectTruthy(this.paymentObject)) {
642
- return (this.message = 'Kindly ensure you are passing all the required data.');
643
- }
644
- this.loading = true;
645
- this.cdr.markForCheck();
646
- this.checkout
647
- .createPaymentLink(this.paymentObject, this.environment, this.secretKey)
648
- .pipe(tap((res) => {
649
- if (res?.isSuccessful) {
650
- this.message = 'Payment link created successfully';
651
- const queryParams = getQueryParams(res.launchUrl ?? '');
652
- this.transactionReference = queryParams['paymentReference'];
653
- }
654
- else {
655
- this.message = 'Failed to create payment link';
656
- }
657
- }), finalize(() => {
658
- this.loading = false;
659
- this.cdr.markForCheck();
660
- }))
661
- .subscribe();
662
- }
663
- generateAddress() {
664
- if (!this.generateAddressPayload)
665
- return;
666
- this.generatingAddress = true;
667
- this.cdr.markForCheck();
668
- this.checkout
669
- .generateStableCoinAddress(this.environment, this.generateAddressPayload)
670
- .pipe(tap((response) => {
671
- if (response?.isSuccessful) {
672
- this.addressDetails = response.data;
673
- this.setFormIndex(1);
674
- }
675
- }), finalize(() => {
676
- this.generatingAddress = false;
677
- this.cdr.markForCheck();
678
- }))
679
- .subscribe({
680
- error: (err) => {
681
- this.message = err.error.responseMessage || err.error.message;
682
- this.onError.emit({ errorMessage: this.message });
683
- },
684
- });
685
- }
686
- async payHandler() {
687
- if (this.stableCoinForm && this.stableCoinForm.valid) {
688
- this.generateAddressPayload = {
689
- paymentReference: this.transactionReference,
690
- currency: this.stableCoinForm.get('stableCoin')?.value ?? '',
691
- chain: this.stableCoinForm.get('network')?.value ?? '',
692
- transactionAmount: this.paymentObject?.amount,
693
- merchantId: this.secretKey,
694
- };
695
- await this.generateAddress();
696
- }
697
- else {
698
- this.stableCoinForm?.markAllAsTouched();
699
- }
700
- }
701
- async getStableCoins() {
702
- this.loadingStableCoins = true;
703
- await this.resource.getStableCoins(this.environment).subscribe({
704
- next: async (response) => {
705
- if (response?.isSuccessful) {
706
- this.stableCoins =
707
- response.data?.map((c) => ({
708
- label: c.name,
709
- value: c.name,
710
- })) ?? [];
711
- this.loadingStableCoins = false;
712
- }
713
- },
714
- error: (err) => {
715
- this.loadingStableCoins = false;
716
- this.message = err.error.responseMessage || err.error.message;
717
- this.onError.emit({ errorMessage: this.message });
718
- },
719
- });
720
- }
721
- async getStableCoinNetworks() {
722
- const stableCoin = this.stableCoinForm.get('stableCoin')?.value;
723
- this.loadingStableCoinNetworks = true;
724
- await this.resource.getStableCoinNetworks(this.environment, stableCoin ?? '').subscribe({
725
- next: async (response) => {
726
- if (response?.isSuccessful) {
727
- this.networkList =
728
- response.networks?.map((n) => ({
729
- label: n,
730
- value: n,
731
- })) ?? [];
732
- this.loadingStableCoinNetworks = false;
733
- }
734
- },
735
- error: (err) => {
736
- this.loadingStableCoinNetworks = false;
737
- this.message = err.error.responseMessage || err.error.message;
738
- this.onError.emit({ errorMessage: this.message });
739
- },
740
- });
741
- }
742
- async confirmPaymentHandler() {
743
- this.isConfirmingPayment = true;
744
- await this.checkout
745
- .getPaymentReferenceDetails(this.environment, this.transactionReference)
746
- .subscribe({
747
- next: async (response) => {
748
- if (response?.isSuccessful) {
749
- this.paymentReferenceDetails = response.data;
750
- if (response.data?.finalTransactionStatus === null ||
751
- response.data?.paymentStatus === null) {
752
- this.message = 'Transaction not confirmed !!';
753
- this.paymentReferenceStatus = 'pending';
754
- this.paymentAuthorized.emit({
755
- paymentId: this.transactionReference,
756
- paymentDate: response.data.updatedAt,
757
- paymentStatus: this.paymentReferenceStatus,
758
- message: this.message,
759
- });
760
- }
761
- else if (response.data?.finalTransactionStatus === 'Success' ||
762
- response.data?.paymentStatus === 'Payment Received') {
763
- this.message = 'Transaction confirmed !!';
764
- this.paymentReferenceStatus = 'confirmed';
765
- this.paymentAuthorized.emit({
766
- paymentId: this.transactionReference,
767
- paymentDate: response.data.updatedAt,
768
- paymentStatus: this.paymentReferenceStatus,
769
- message: this.message,
770
- });
771
- }
772
- }
773
- else if (!response?.isSuccessful && response?.responseCode === '119') {
774
- this.paymentReferenceStatus = 'used';
775
- this.message = response.responseMessage;
776
- this.paymentAuthorized.emit({
777
- paymentId: this.transactionReference,
778
- paymentDate: null,
779
- paymentStatus: this.paymentReferenceStatus,
780
- message: this.message,
781
- });
782
- }
783
- this.isConfirmingPayment = false;
784
- },
785
- error: (err) => {
786
- this.paymentReferenceStatus = '';
787
- this.isConfirmingPayment = false;
788
- this.message = err.error.responseMessage || err.error.message;
789
- this.onError.emit({ errorMessage: this.message });
790
- },
791
- });
792
- }
793
- async ngOnInit() {
794
- await this.generatePaymentLinkHandler();
795
- await this.getStableCoins();
796
- }
797
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: PayByStableCoinComponent, deps: [{ token: i1.ResourceService }, { token: i1.CheckoutService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
798
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: PayByStableCoinComponent, isStandalone: true, selector: "pay-by-stable-coin", inputs: { secretKey: "secretKey", environment: "environment", paymentObject: "paymentObject" }, outputs: { paymentAuthorized: "paymentAuthorized", onError: "onError" }, ngImport: i0, template: "<div class=\"flex flex-col gap-6\">\n @if (formIndex === 0) {\n <form [formGroup]=\"stableCoinForm\" class=\"grid grid-cols-1 gap-6\">\n <div class=\"grid grid-cols-1 gap-6\">\n <base-select\n formControlName=\"stableCoin\"\n label=\"Select Crypto\"\n [required]=\"true\"\n [options]=\"stableCoins\"\n [validationError]=\"getError('stableCoin', 'Select Crypto') ?? ''\"\n [loading]=\"loadingStableCoins\"\n (onSelectChange)=\"getStableCoinNetworks()\"\n ></base-select>\n <base-select\n formControlName=\"network\"\n label=\"Select Network\"\n [required]=\"true\"\n [options]=\"networkList\"\n [validationError]=\"getError('network', 'Network') ?? ''\"\n [loading]=\"loadingStableCoinNetworks\"\n ></base-select>\n </div>\n\n <base-button\n [label]=\"'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"generatingAddress\"\n (onClick)=\"payHandler()\"\n ></base-button>\n </form>\n }\n\n @if (formIndex === 1) {\n <div class=\"flex flex-col gap-6\">\n <div class=\"mx-auto\">\n <!-- <base-image\n src=\"../../../assets/images/stable-coin-qr-code.png\"\n alt=\"QR Code\"\n [width]=\"122\"\n [height]=\"122\"\n class=\"mb-1\"\n ></base-image> -->\n <p class=\"mb-0 text-body-4xs text-light-copy font-normal text-center\">\n {{ generateAddressPayload?.currency }}\n </p>\n </div>\n\n <div class=\"flex flex-col gap-6 border-c border-grey-100 p-4 rounded-2xl bg-light-white-50\">\n <div class=\"border-b border-grey-border pb-4 flex flex-col gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">Network</p>\n <div class=\"flex justify-between\">\n <div class=\"flex flex-col gap-1\">\n <p class=\"mb-0 text-body-2xs font-medium text-sub-copy\">\n {{ addressDetails?.chain }}\n </p>\n <div class=\"flex items-center gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">*Est. arrival = 3 mins</p>\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">|</p>\n <base-currency-amount\n [currency]=\"generateAddressPayload?.currency ?? ''\"\n [amount]=\"addressDetails?.networkFee ?? 0\"\n textClass=\"mb-0 text-body-3xs text-light-copy font-normal\"\n iconColorClass=\"#557591\"\n iconWidth=\"12\"\n iconHeight=\"12\"\n ></base-currency-amount>\n </div>\n </div>\n <icon-arrow-swap></icon-arrow-swap>\n </div>\n </div>\n\n <div class=\"pb-4 flex flex-col gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">Deposit Address ></p>\n <div class=\"flex justify-between\">\n <p class=\"mb-0 text-body-2xs font-medium text-sub-copy w-2/3 break-words\">\n {{ addressDetails?.walletAddress }}\n </p>\n <base-copy [copyText]=\"addressDetails?.walletAddress ?? ''\"></base-copy>\n </div>\n </div>\n\n <!-- <div class=\"pb-4 flex flex-col gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">Memo ></p>\n <div class=\"flex justify-between\">\n <p\n class=\"mb-0 text-body-2xs font-medium text-sub-copy w-2/3 break-words\"\n >\n 0j8938ysheeee8333c162883a4d4f5g6t111nhk8uey37777yt6\n </p>\n <app-copy\n [isCopyIcon]=\"true\"\n [copyText]=\"'0j8938ysheeee8333c162883a4d4f5g6t111nhk8uey37777yt6'\"\n ></app-copy>\n </div>\n </div> -->\n </div>\n\n <div class=\"flex flex-col gap-2\">\n <div class=\"flex items-center justify-between border-b border-grey-border py-3\">\n <p class=\"mb-0 text-body-2xs font-medium text-primary-black\">Network fee</p>\n <base-currency-amount\n [currency]=\"generateAddressPayload?.currency ?? ''\"\n [amount]=\"addressDetails?.networkFee ?? 0\"\n textClass=\"mb-0 text-body-2xs font-extrabold text-primary-black\"\n iconColorClass=\"#231F20\"\n ></base-currency-amount>\n </div>\n\n <div class=\"flex items-center justify-between py-4\">\n <p class=\"mb-0 text-body-lg font-semibold text-primary-black\">Pay</p>\n <base-currency-amount\n [currency]=\"generateAddressPayload?.currency ?? ''\"\n [amount]=\"amountPlusNetworkFee\"\n textClass=\"mb-0 text-body-lg font-extrabold text-primary-black\"\n iconColorClass=\"#231F20\"\n iconWidth=\"20\"\n iconHeight=\"20\"\n ></base-currency-amount>\n </div>\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <base-button\n label=\"Confirm Payment\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isConfirmingPayment\"\n (onClick)=\"confirmPaymentHandler()\"\n ></base-button>\n </div>\n </div>\n }\n</div>\n", dependencies: [{ kind: "component", type: SelectComponent, selector: "base-select", inputs: ["options", "placeholder", "hasSearch", "disabled", "loading", "validationError", "label", "hint", "required", "itemImageType"], outputs: ["onSelectChange"] }, { kind: "component", type: ButtonComponent, selector: "base-button", inputs: ["label", "type", "size", "paddingClassX", "disabled", "loading", "customClass"], outputs: ["onClick"] }, { kind: "component", type:
799
- // ImageComponent,
800
- CurrencyAmountComponent, selector: "base-currency-amount", inputs: ["currency", "amount", "textClass", "iconColorClass", "iconWidth", "iconHeight"] }, { kind: "component", type: CopyComponent, selector: "base-copy", inputs: ["copyText", "color"] }, { kind: "component", type: IconArrowSwapComponent, selector: "icon-arrow-swap", inputs: ["color", "width", "height"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
801
- }
802
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: PayByStableCoinComponent, decorators: [{
803
- type: Component,
804
- args: [{ selector: 'pay-by-stable-coin', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
805
- SelectComponent,
806
- ButtonComponent,
807
- // ImageComponent,
808
- CurrencyAmountComponent,
809
- CopyComponent,
810
- IconArrowSwapComponent,
811
- ReactiveFormsModule,
812
- ], template: "<div class=\"flex flex-col gap-6\">\n @if (formIndex === 0) {\n <form [formGroup]=\"stableCoinForm\" class=\"grid grid-cols-1 gap-6\">\n <div class=\"grid grid-cols-1 gap-6\">\n <base-select\n formControlName=\"stableCoin\"\n label=\"Select Crypto\"\n [required]=\"true\"\n [options]=\"stableCoins\"\n [validationError]=\"getError('stableCoin', 'Select Crypto') ?? ''\"\n [loading]=\"loadingStableCoins\"\n (onSelectChange)=\"getStableCoinNetworks()\"\n ></base-select>\n <base-select\n formControlName=\"network\"\n label=\"Select Network\"\n [required]=\"true\"\n [options]=\"networkList\"\n [validationError]=\"getError('network', 'Network') ?? ''\"\n [loading]=\"loadingStableCoinNetworks\"\n ></base-select>\n </div>\n\n <base-button\n [label]=\"'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"generatingAddress\"\n (onClick)=\"payHandler()\"\n ></base-button>\n </form>\n }\n\n @if (formIndex === 1) {\n <div class=\"flex flex-col gap-6\">\n <div class=\"mx-auto\">\n <!-- <base-image\n src=\"../../../assets/images/stable-coin-qr-code.png\"\n alt=\"QR Code\"\n [width]=\"122\"\n [height]=\"122\"\n class=\"mb-1\"\n ></base-image> -->\n <p class=\"mb-0 text-body-4xs text-light-copy font-normal text-center\">\n {{ generateAddressPayload?.currency }}\n </p>\n </div>\n\n <div class=\"flex flex-col gap-6 border-c border-grey-100 p-4 rounded-2xl bg-light-white-50\">\n <div class=\"border-b border-grey-border pb-4 flex flex-col gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">Network</p>\n <div class=\"flex justify-between\">\n <div class=\"flex flex-col gap-1\">\n <p class=\"mb-0 text-body-2xs font-medium text-sub-copy\">\n {{ addressDetails?.chain }}\n </p>\n <div class=\"flex items-center gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">*Est. arrival = 3 mins</p>\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">|</p>\n <base-currency-amount\n [currency]=\"generateAddressPayload?.currency ?? ''\"\n [amount]=\"addressDetails?.networkFee ?? 0\"\n textClass=\"mb-0 text-body-3xs text-light-copy font-normal\"\n iconColorClass=\"#557591\"\n iconWidth=\"12\"\n iconHeight=\"12\"\n ></base-currency-amount>\n </div>\n </div>\n <icon-arrow-swap></icon-arrow-swap>\n </div>\n </div>\n\n <div class=\"pb-4 flex flex-col gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">Deposit Address ></p>\n <div class=\"flex justify-between\">\n <p class=\"mb-0 text-body-2xs font-medium text-sub-copy w-2/3 break-words\">\n {{ addressDetails?.walletAddress }}\n </p>\n <base-copy [copyText]=\"addressDetails?.walletAddress ?? ''\"></base-copy>\n </div>\n </div>\n\n <!-- <div class=\"pb-4 flex flex-col gap-2\">\n <p class=\"mb-0 text-body-3xs text-light-copy font-normal\">Memo ></p>\n <div class=\"flex justify-between\">\n <p\n class=\"mb-0 text-body-2xs font-medium text-sub-copy w-2/3 break-words\"\n >\n 0j8938ysheeee8333c162883a4d4f5g6t111nhk8uey37777yt6\n </p>\n <app-copy\n [isCopyIcon]=\"true\"\n [copyText]=\"'0j8938ysheeee8333c162883a4d4f5g6t111nhk8uey37777yt6'\"\n ></app-copy>\n </div>\n </div> -->\n </div>\n\n <div class=\"flex flex-col gap-2\">\n <div class=\"flex items-center justify-between border-b border-grey-border py-3\">\n <p class=\"mb-0 text-body-2xs font-medium text-primary-black\">Network fee</p>\n <base-currency-amount\n [currency]=\"generateAddressPayload?.currency ?? ''\"\n [amount]=\"addressDetails?.networkFee ?? 0\"\n textClass=\"mb-0 text-body-2xs font-extrabold text-primary-black\"\n iconColorClass=\"#231F20\"\n ></base-currency-amount>\n </div>\n\n <div class=\"flex items-center justify-between py-4\">\n <p class=\"mb-0 text-body-lg font-semibold text-primary-black\">Pay</p>\n <base-currency-amount\n [currency]=\"generateAddressPayload?.currency ?? ''\"\n [amount]=\"amountPlusNetworkFee\"\n textClass=\"mb-0 text-body-lg font-extrabold text-primary-black\"\n iconColorClass=\"#231F20\"\n iconWidth=\"20\"\n iconHeight=\"20\"\n ></base-currency-amount>\n </div>\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <base-button\n label=\"Confirm Payment\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"isConfirmingPayment\"\n (onClick)=\"confirmPaymentHandler()\"\n ></base-button>\n </div>\n </div>\n }\n</div>\n" }]
813
- }], ctorParameters: () => [{ type: i1.ResourceService }, { type: i1.CheckoutService }, { type: i0.ChangeDetectorRef }], propDecorators: { secretKey: [{
814
- type: Input
815
- }], environment: [{
816
- type: Input
817
- }], paymentObject: [{
818
- type: Input
819
- }], paymentAuthorized: [{
820
- type: Output
821
- }], onError: [{
822
- type: Output
823
- }] } });
7
+ import { tap, finalize } from 'rxjs';
824
8
 
825
9
  class CheckoutCardComponent {
826
10
  options = null;
@@ -883,10 +67,10 @@ class CheckoutCardComponent {
883
67
  }
884
68
  setSuccess(event) {
885
69
  this.successObject = { ...event };
886
- if (this.successObject.paymentStatus === 'Authorized') {
70
+ if (this.successObject.paymentStatus === 'authorized') {
887
71
  this.checkoutState = 'SUCCESS';
888
72
  }
889
- else if (this.successObject.paymentStatus === 'Payment failed') {
73
+ else if (this.successObject.paymentStatus === 'payment failed') {
890
74
  this.checkoutState = 'PENDING';
891
75
  }
892
76
  else if (this.successObject.paymentStatus === 'used') {
@@ -901,7 +85,7 @@ class CheckoutCardComponent {
901
85
  this.onError.emit(e);
902
86
  }
903
87
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: CheckoutCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
904
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: CheckoutCardComponent, isStandalone: true, selector: "bzp-checkout-card", inputs: { options: "options", secretKey: "secretKey", environment: "environment", paymentObject: "paymentObject" }, outputs: { ready: "ready", validityChange: "validityChange", tokenize: "tokenize", paymentAuthorized: "paymentAuthorized", onError: "onError" }, ngImport: i0, template: "<base-card>\n <div class=\"grid grid-cols-3\">\n @if (checkoutState === 'PENDING') {\n <div class=\"bg-[#EFF7FF] px-6 py-8 flex flex-col gap-5 col-span-1 rounded-l-xl\">\n <p class=\"text-heading-text text-body-xs font-semibold\">Pay with</p>\n <base-radio-group\n [options]=\"filteredPaymentTypeOptions\"\n (selectedChange)=\"paymentTypeHandler($event)\"\n ></base-radio-group>\n </div>\n }\n\n <div [class]=\"checkoutState === 'SUCCESS' ? 'col-span-3' : 'col-span-2'\">\n @if (checkoutState === 'PENDING') {\n <div class=\"flex items-center justify-between px-12 py-8\">\n @if (options?.imageUrl) {\n <base-image\n [src]=\"options?.imageUrl ?? ''\"\n alt=\"Merchant Logo\"\n [width]=\"52\"\n [height]=\"52\"\n class=\"rounded-lg\"\n ></base-image>\n } @else {\n <div\n class=\"bg-heading-text rounded flex flex-col justify-center\"\n style=\"width: 52px; height: 52px\"\n >\n <p class=\"text-white text-center text-body-2xs font-medium\">Logo</p>\n </div>\n }\n\n <div class=\"flex flex-col gap-1\">\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n {{ paymentObject.merchantName }}\n </p>\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n Pay:\n <span class=\"text-orange-500 font-extrabold\">{{ formatAmountHandler }}</span>\n </p>\n </div>\n </div>\n\n <div class=\"overflow-y-scroll px-10 pb-10 pt-2\">\n @if (paymentType === 'CARD') {\n <pay-by-card\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-card>\n } @else if (paymentType === 'BANK_TRANSFER') {\n <pay-by-transfer\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-transfer>\n } @else {\n <pay-by-stable-coin\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-stable-coin>\n }\n </div>\n } @else if (checkoutState === 'SUCCESS') {\n <base-success\n [amount]=\"paymentObject.amount\"\n [currency]=\"paymentObject.currency\"\n [redirectUrl]=\"paymentObject.redirectUrl ?? ''\"\n [successObject]=\"successObject\"\n ></base-success>\n }\n </div>\n </div>\n</base-card>\n", dependencies: [{ kind: "component", type: RadioGroupComponent, selector: "base-radio-group", inputs: ["options", "type"], outputs: ["selectedChange"] }, { kind: "component", type: ImageComponent, selector: "base-image", inputs: ["src", "alt", "isFullWidth", "width", "height", "customClass"], outputs: ["onClick"] }, { kind: "component", type: PayByCardComponent, selector: "pay-by-card", inputs: ["secretKey", "environment", "paymentObject"], outputs: ["paymentAuthorized", "onError"] }, { kind: "component", type: PayByTransferComponent, selector: "pay-by-transfer", inputs: ["secretKey", "environment", "paymentObject"], outputs: ["paymentAuthorized", "onError"] }, { kind: "component", type: PayByStableCoinComponent, selector: "pay-by-stable-coin", inputs: ["secretKey", "environment", "paymentObject"], outputs: ["paymentAuthorized", "onError"] }, { kind: "component", type: SuccessComponent, selector: "base-success", inputs: ["successObject", "amount", "currency", "redirectUrl"] }, { kind: "component", type: CardComponent, selector: "base-card", inputs: ["showBackButton"], outputs: ["back"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
88
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: CheckoutCardComponent, isStandalone: true, selector: "bzp-checkout-card", inputs: { options: "options", secretKey: "secretKey", environment: "environment", paymentObject: "paymentObject" }, outputs: { ready: "ready", validityChange: "validityChange", tokenize: "tokenize", paymentAuthorized: "paymentAuthorized", onError: "onError" }, ngImport: i0, template: "<base-card>\n <div class=\"grid grid-cols-3\" buzapay>\n @if (checkoutState === 'PENDING') {\n <div class=\"bg-[#EFF7FF] px-6 py-8 flex flex-col gap-5 col-span-1 rounded-l-xl\">\n <p class=\"text-heading-text text-body-xs font-semibold\">Pay with</p>\n <base-radio-group\n [options]=\"filteredPaymentTypeOptions\"\n (selectedChange)=\"paymentTypeHandler($event)\"\n ></base-radio-group>\n </div>\n }\n\n <div [class]=\"checkoutState === 'SUCCESS' ? 'col-span-3' : 'col-span-2'\">\n @if (checkoutState === 'PENDING') {\n <div class=\"flex items-center justify-between px-12 py-8\">\n @if (options?.imageUrl) {\n <base-image\n [src]=\"options?.imageUrl ?? ''\"\n alt=\"Merchant Logo\"\n [width]=\"52\"\n [height]=\"52\"\n class=\"rounded-lg\"\n ></base-image>\n } @else {\n <div\n class=\"bg-heading-text rounded flex flex-col justify-center\"\n style=\"width: 52px; height: 52px\"\n >\n <p class=\"text-white text-center text-body-2xs font-medium\">Logo</p>\n </div>\n }\n\n <div class=\"flex flex-col gap-1\">\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n {{ paymentObject.merchantName }}\n </p>\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n Pay:\n <span class=\"text-orange-500 font-extrabold\">{{ formatAmountHandler }}</span>\n </p>\n </div>\n </div>\n\n <div class=\"max-h-[32rem] overflow-y-scroll px-10 pb-10 pt-2\">\n @if (paymentType === 'CARD') {\n <pay-by-card\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n caller=\"buzapay\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-card>\n } @else if (paymentType === 'BANK_TRANSFER') {\n <pay-by-transfer\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n caller=\"buzapay\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-transfer>\n } @else {\n <pay-by-stable-coin\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n caller=\"buzapay\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-stable-coin>\n }\n </div>\n } @else if (checkoutState === 'SUCCESS') {\n <base-success\n [amount]=\"paymentObject.amount\"\n [currency]=\"paymentObject.currency\"\n [redirectUrl]=\"paymentObject.redirectUrl ?? ''\"\n [successObject]=\"successObject\"\n ></base-success>\n }\n </div>\n </div>\n</base-card>\n", dependencies: [{ kind: "component", type: RadioGroupComponent, selector: "base-radio-group", inputs: ["caller", "options", "type"], outputs: ["selectedChange"] }, { kind: "component", type: ImageComponent, selector: "base-image", inputs: ["src", "alt", "isFullWidth", "width", "height", "customClass"], outputs: ["onClick"] }, { kind: "component", type: PayByCardComponent, selector: "pay-by-card", inputs: ["secretKey", "environment", "caller", "paymentObject"], outputs: ["paymentAuthorized", "onError"] }, { kind: "component", type: PayByTransferComponent, selector: "pay-by-transfer", inputs: ["secretKey", "environment", "caller", "paymentObject"], outputs: ["paymentAuthorized", "onError"] }, { kind: "component", type: PayByStableCoinComponent, selector: "pay-by-stable-coin", inputs: ["secretKey", "environment", "caller", "paymentObject"], outputs: ["paymentAuthorized", "onError"] }, { kind: "component", type: SuccessComponent, selector: "base-success", inputs: ["successObject", "caller", "amount", "currency", "redirectUrl"] }, { kind: "component", type: CardComponent, selector: "base-card", inputs: ["showBackButton", "caller"], outputs: ["back"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
905
89
  }
906
90
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: CheckoutCardComponent, decorators: [{
907
91
  type: Component,
@@ -913,7 +97,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImpor
913
97
  PayByStableCoinComponent,
914
98
  SuccessComponent,
915
99
  CardComponent,
916
- ], template: "<base-card>\n <div class=\"grid grid-cols-3\">\n @if (checkoutState === 'PENDING') {\n <div class=\"bg-[#EFF7FF] px-6 py-8 flex flex-col gap-5 col-span-1 rounded-l-xl\">\n <p class=\"text-heading-text text-body-xs font-semibold\">Pay with</p>\n <base-radio-group\n [options]=\"filteredPaymentTypeOptions\"\n (selectedChange)=\"paymentTypeHandler($event)\"\n ></base-radio-group>\n </div>\n }\n\n <div [class]=\"checkoutState === 'SUCCESS' ? 'col-span-3' : 'col-span-2'\">\n @if (checkoutState === 'PENDING') {\n <div class=\"flex items-center justify-between px-12 py-8\">\n @if (options?.imageUrl) {\n <base-image\n [src]=\"options?.imageUrl ?? ''\"\n alt=\"Merchant Logo\"\n [width]=\"52\"\n [height]=\"52\"\n class=\"rounded-lg\"\n ></base-image>\n } @else {\n <div\n class=\"bg-heading-text rounded flex flex-col justify-center\"\n style=\"width: 52px; height: 52px\"\n >\n <p class=\"text-white text-center text-body-2xs font-medium\">Logo</p>\n </div>\n }\n\n <div class=\"flex flex-col gap-1\">\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n {{ paymentObject.merchantName }}\n </p>\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n Pay:\n <span class=\"text-orange-500 font-extrabold\">{{ formatAmountHandler }}</span>\n </p>\n </div>\n </div>\n\n <div class=\"overflow-y-scroll px-10 pb-10 pt-2\">\n @if (paymentType === 'CARD') {\n <pay-by-card\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-card>\n } @else if (paymentType === 'BANK_TRANSFER') {\n <pay-by-transfer\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-transfer>\n } @else {\n <pay-by-stable-coin\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-stable-coin>\n }\n </div>\n } @else if (checkoutState === 'SUCCESS') {\n <base-success\n [amount]=\"paymentObject.amount\"\n [currency]=\"paymentObject.currency\"\n [redirectUrl]=\"paymentObject.redirectUrl ?? ''\"\n [successObject]=\"successObject\"\n ></base-success>\n }\n </div>\n </div>\n</base-card>\n" }]
100
+ ], template: "<base-card>\n <div class=\"grid grid-cols-3\" buzapay>\n @if (checkoutState === 'PENDING') {\n <div class=\"bg-[#EFF7FF] px-6 py-8 flex flex-col gap-5 col-span-1 rounded-l-xl\">\n <p class=\"text-heading-text text-body-xs font-semibold\">Pay with</p>\n <base-radio-group\n [options]=\"filteredPaymentTypeOptions\"\n (selectedChange)=\"paymentTypeHandler($event)\"\n ></base-radio-group>\n </div>\n }\n\n <div [class]=\"checkoutState === 'SUCCESS' ? 'col-span-3' : 'col-span-2'\">\n @if (checkoutState === 'PENDING') {\n <div class=\"flex items-center justify-between px-12 py-8\">\n @if (options?.imageUrl) {\n <base-image\n [src]=\"options?.imageUrl ?? ''\"\n alt=\"Merchant Logo\"\n [width]=\"52\"\n [height]=\"52\"\n class=\"rounded-lg\"\n ></base-image>\n } @else {\n <div\n class=\"bg-heading-text rounded flex flex-col justify-center\"\n style=\"width: 52px; height: 52px\"\n >\n <p class=\"text-white text-center text-body-2xs font-medium\">Logo</p>\n </div>\n }\n\n <div class=\"flex flex-col gap-1\">\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n {{ paymentObject.merchantName }}\n </p>\n <p class=\"text-body-2xs font-regular text-sub-copy text-right\">\n Pay:\n <span class=\"text-orange-500 font-extrabold\">{{ formatAmountHandler }}</span>\n </p>\n </div>\n </div>\n\n <div class=\"max-h-[32rem] overflow-y-scroll px-10 pb-10 pt-2\">\n @if (paymentType === 'CARD') {\n <pay-by-card\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n caller=\"buzapay\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-card>\n } @else if (paymentType === 'BANK_TRANSFER') {\n <pay-by-transfer\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n caller=\"buzapay\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-transfer>\n } @else {\n <pay-by-stable-coin\n [environment]=\"environment\"\n [secretKey]=\"secretKey\"\n [paymentObject]=\"paymentObject\"\n caller=\"buzapay\"\n (paymentAuthorized)=\"setSuccess($event)\"\n (onError)=\"onErrorHandler($event)\"\n ></pay-by-stable-coin>\n }\n </div>\n } @else if (checkoutState === 'SUCCESS') {\n <base-success\n [amount]=\"paymentObject.amount\"\n [currency]=\"paymentObject.currency\"\n [redirectUrl]=\"paymentObject.redirectUrl ?? ''\"\n [successObject]=\"successObject\"\n ></base-success>\n }\n </div>\n </div>\n</base-card>\n" }]
917
101
  }], propDecorators: { options: [{
918
102
  type: Input
919
103
  }], secretKey: [{
@@ -1000,7 +184,7 @@ class CheckoutIframeComponent {
1000
184
  this.loading = true;
1001
185
  this.cdr.markForCheck();
1002
186
  this.checkout
1003
- .createPaymentLink(this.paymentObject, this.environment, this.secretKey)
187
+ .createPaymentLink(this.paymentObject, this.environment, this.secretKey, 'buzapay')
1004
188
  .pipe(tap((res) => {
1005
189
  if (res?.isSuccessful) {
1006
190
  this.launchUrl = res.launchUrl ?? '';
@@ -1027,7 +211,7 @@ class CheckoutIframeComponent {
1027
211
  await this.generatePaymentLinkHandler();
1028
212
  }
1029
213
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: CheckoutIframeComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i1.CheckoutService }], target: i0.ɵɵFactoryTarget.Component });
1030
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: CheckoutIframeComponent, isStandalone: true, selector: "bzp-checkout-iframe", inputs: { secretKey: "secretKey", url: "url", style: "style", environment: "environment", paymentObject: "paymentObject" }, outputs: { onError: "onError" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: "<div class=\"relative\" [ngStyle]=\"blockStyle\">\n <div #container class=\"w-full h-full\"></div>\n\n @if (loading) {\n <div class=\"absolute inset-0 grid place-items-center bg-white/60\">\n <icon-loader></icon-loader>\n </div>\n }\n</div>\n", dependencies: [{ kind: "component", type: IconLoaderComponent, selector: "icon-loader", inputs: ["color", "size"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
214
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: CheckoutIframeComponent, isStandalone: true, selector: "bzp-checkout-iframe", inputs: { secretKey: "secretKey", url: "url", style: "style", environment: "environment", paymentObject: "paymentObject" }, outputs: { onError: "onError" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: "<div class=\"relative\" [ngStyle]=\"blockStyle\">\n <div #container class=\"w-full h-full\"></div>\n\n @if (loading) {\n <div class=\"absolute inset-0 grid place-items-center bg-white/60\">\n <icon-loader></icon-loader>\n </div>\n }\n</div>\n", dependencies: [{ kind: "component", type: IconLoaderComponent, selector: "icon-loader", inputs: ["color", "size"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1031
215
  }
1032
216
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: CheckoutIframeComponent, decorators: [{
1033
217
  type: Component,
@@ -1074,6 +258,9 @@ class CheckoutButtonComponent {
1074
258
  redirectUrl: 'https://sandbox-merchant.buzapay.com/account/three-ds-status',
1075
259
  };
1076
260
  onError = new EventEmitter();
261
+ get formatAmountHandler() {
262
+ return formatAmount(this.paymentObject.amount, this.paymentObject.currency);
263
+ }
1077
264
  async generatePaymentLinkHandler() {
1078
265
  if (!this.secretKey) {
1079
266
  return (this.errorMessage = 'Secret key is required.');
@@ -1084,7 +271,7 @@ class CheckoutButtonComponent {
1084
271
  this.loading = true;
1085
272
  this.cdr.markForCheck();
1086
273
  this.checkout
1087
- .createPaymentLink(this.paymentObject, this.environment, this.secretKey)
274
+ .createPaymentLink(this.paymentObject, this.environment, this.secretKey, 'buzapay')
1088
275
  .pipe(tap((res) => {
1089
276
  if (res?.isSuccessful) {
1090
277
  this.launchUrl = res.launchUrl ?? '';
@@ -1109,11 +296,11 @@ class CheckoutButtonComponent {
1109
296
  });
1110
297
  }
1111
298
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: CheckoutButtonComponent, deps: [{ token: i1.CheckoutService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1112
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: CheckoutButtonComponent, isStandalone: true, selector: "bzp-checkout-button", inputs: { secretKey: "secretKey", timeout: "timeout", environment: "environment", mode: "mode", paymentObject: "paymentObject" }, outputs: { onError: "onError" }, ngImport: i0, template: "@if (urlLaunchUrl && mode === 'iframe') {\n <bzp-checkout-iframe\n [url]=\"urlLaunchUrl\"\n [secretKey]=\"secretKey\"\n [environment]=\"environment\"\n ></bzp-checkout-iframe>\n} @else {\n <base-button\n label=\"Pay\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"loading\"\n (onClick)=\"generatePaymentLinkHandler()\"\n ></base-button>\n <base-input-error [errorMessage]=\"errorMessage\"></base-input-error>\n}\n", dependencies: [{ kind: "component", type: ButtonComponent, selector: "base-button", inputs: ["label", "type", "size", "paddingClassX", "disabled", "loading", "customClass"], outputs: ["onClick"] }, { kind: "component", type: InputErrorComponent, selector: "base-input-error", inputs: ["errorMessage"] }, { kind: "component", type: CheckoutIframeComponent, selector: "bzp-checkout-iframe", inputs: ["secretKey", "url", "style", "environment", "paymentObject"], outputs: ["onError"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
299
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.1", type: CheckoutButtonComponent, isStandalone: true, selector: "bzp-checkout-button", inputs: { secretKey: "secretKey", timeout: "timeout", environment: "environment", mode: "mode", paymentObject: "paymentObject" }, outputs: { onError: "onError" }, ngImport: i0, template: "@if (urlLaunchUrl && mode === 'iframe') {\n <bzp-checkout-iframe\n [url]=\"urlLaunchUrl\"\n [secretKey]=\"secretKey\"\n [environment]=\"environment\"\n ></bzp-checkout-iframe>\n} @else {\n <base-button\n [label]=\"'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"loading\"\n (onClick)=\"generatePaymentLinkHandler()\"\n ></base-button>\n <base-input-error [errorMessage]=\"errorMessage\"></base-input-error>\n}\n", dependencies: [{ kind: "component", type: ButtonComponent, selector: "base-button", inputs: ["label", "type", "caller", "size", "paddingClassX", "disabled", "loading", "customClass"], outputs: ["onClick"] }, { kind: "component", type: InputErrorComponent, selector: "base-input-error", inputs: ["errorMessage"] }, { kind: "component", type: CheckoutIframeComponent, selector: "bzp-checkout-iframe", inputs: ["secretKey", "url", "style", "environment", "paymentObject"], outputs: ["onError"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1113
300
  }
1114
301
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: CheckoutButtonComponent, decorators: [{
1115
302
  type: Component,
1116
- args: [{ selector: 'bzp-checkout-button', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [ButtonComponent, InputErrorComponent, InputErrorComponent, CheckoutIframeComponent], template: "@if (urlLaunchUrl && mode === 'iframe') {\n <bzp-checkout-iframe\n [url]=\"urlLaunchUrl\"\n [secretKey]=\"secretKey\"\n [environment]=\"environment\"\n ></bzp-checkout-iframe>\n} @else {\n <base-button\n label=\"Pay\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"loading\"\n (onClick)=\"generatePaymentLinkHandler()\"\n ></base-button>\n <base-input-error [errorMessage]=\"errorMessage\"></base-input-error>\n}\n" }]
303
+ args: [{ selector: 'bzp-checkout-button', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [ButtonComponent, InputErrorComponent, InputErrorComponent, CheckoutIframeComponent], template: "@if (urlLaunchUrl && mode === 'iframe') {\n <bzp-checkout-iframe\n [url]=\"urlLaunchUrl\"\n [secretKey]=\"secretKey\"\n [environment]=\"environment\"\n ></bzp-checkout-iframe>\n} @else {\n <base-button\n [label]=\"'Pay ' + formatAmountHandler\"\n type=\"primary\"\n customClass=\"w-full\"\n [loading]=\"loading\"\n (onClick)=\"generatePaymentLinkHandler()\"\n ></base-button>\n <base-input-error [errorMessage]=\"errorMessage\"></base-input-error>\n}\n" }]
1117
304
  }], ctorParameters: () => [{ type: i1.CheckoutService }, { type: i0.ChangeDetectorRef }], propDecorators: { secretKey: [{
1118
305
  type: Input
1119
306
  }], timeout: [{
@@ -1132,5 +319,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImpor
1132
319
  * Generated bundle index. Do not edit.
1133
320
  */
1134
321
 
1135
- export { CheckoutButtonComponent, CheckoutCardComponent, CheckoutIframeComponent, PayByCardComponent, PayByStableCoinComponent, PayByTransferComponent };
322
+ export { CheckoutButtonComponent, CheckoutCardComponent, CheckoutIframeComponent };
1136
323
  //# sourceMappingURL=miden-npm-angular-buzapay-checkout.mjs.map