@ic-pay/icpay-widget 0.1.86 → 0.1.90
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/dist/index.d.ts +159 -2
- package/dist/index.global.js +580 -430
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +266 -116
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as lit from 'lit';
|
|
2
|
-
import { LitElement } from 'lit';
|
|
2
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
3
3
|
import { Icpay, PriceCalculationResult } from '@ic-pay/icpay-sdk';
|
|
4
4
|
|
|
5
5
|
type ThemeConfig = {
|
|
@@ -47,6 +47,7 @@ type CommonConfig = {
|
|
|
47
47
|
disablePaymentButton?: boolean;
|
|
48
48
|
disableAfterSuccess?: boolean;
|
|
49
49
|
showLedgerDropdown?: 'buttons' | 'dropdown' | 'none';
|
|
50
|
+
onramp?: OnrampConfig;
|
|
50
51
|
};
|
|
51
52
|
type CryptoOption = {
|
|
52
53
|
symbol: string;
|
|
@@ -118,6 +119,15 @@ type DonationThermometerConfig = CommonConfig & {
|
|
|
118
119
|
raised: number;
|
|
119
120
|
}) => void;
|
|
120
121
|
};
|
|
122
|
+
type OnrampConfig = {
|
|
123
|
+
environment?: 'STAGING' | 'PRODUCTION';
|
|
124
|
+
apiKey?: string | null;
|
|
125
|
+
width?: number | string;
|
|
126
|
+
height?: number | string;
|
|
127
|
+
autoOpen?: boolean;
|
|
128
|
+
creditCardLabel?: string;
|
|
129
|
+
enabled?: boolean;
|
|
130
|
+
};
|
|
121
131
|
type PayButtonConfig = CommonConfig & {
|
|
122
132
|
amountUsd?: number;
|
|
123
133
|
cryptoOptions?: CryptoOption[];
|
|
@@ -153,6 +163,10 @@ type WidgetSdk = {
|
|
|
153
163
|
client: InstanceType<typeof Icpay>;
|
|
154
164
|
quoteUsd(usdAmount: number, ledgerCanisterId: string): Promise<PriceCalculationResult>;
|
|
155
165
|
sendUsd(usdAmount: number, ledgerCanisterId: string, metadata?: Record<string, any>): Promise<any>;
|
|
166
|
+
startOnrampUsd(usdAmount: number, ledgerCanisterId: string, metadata?: Record<string, any>): Promise<any>;
|
|
167
|
+
notifyIntentUntilComplete(paymentIntentId: string, intervalMs?: number, orderId?: string): {
|
|
168
|
+
stop: () => void;
|
|
169
|
+
};
|
|
156
170
|
};
|
|
157
171
|
declare function createSdk(config: CommonConfig): WidgetSdk;
|
|
158
172
|
|
|
@@ -182,6 +196,7 @@ declare class ICPayProgressBar extends LitElement {
|
|
|
182
196
|
private currentAmount;
|
|
183
197
|
private currentCurrency;
|
|
184
198
|
private currentLedgerSymbol;
|
|
199
|
+
private confirmLoadingStartedAt;
|
|
185
200
|
private progressionTimer;
|
|
186
201
|
theme?: {
|
|
187
202
|
primaryColor?: string;
|
|
@@ -200,6 +215,7 @@ declare class ICPayProgressBar extends LitElement {
|
|
|
200
215
|
private onTransactionUpdated;
|
|
201
216
|
private onTransactionCompleted;
|
|
202
217
|
private onTransactionFailed;
|
|
218
|
+
private onTransactionMismatched;
|
|
203
219
|
private onMethodError;
|
|
204
220
|
private onSDKError;
|
|
205
221
|
private onWalletConnected;
|
|
@@ -225,6 +241,7 @@ declare class ICPayProgressBar extends LitElement {
|
|
|
225
241
|
private renderSuccessState;
|
|
226
242
|
private renderErrorState;
|
|
227
243
|
private renderProgressContent;
|
|
244
|
+
private renderConfirmTip;
|
|
228
245
|
private retryTransaction;
|
|
229
246
|
private closeProgress;
|
|
230
247
|
private renderStep;
|
|
@@ -247,10 +264,21 @@ declare class ICPayTokenSelector extends LitElement {
|
|
|
247
264
|
primaryColor?: string;
|
|
248
265
|
secondaryColor?: string;
|
|
249
266
|
};
|
|
267
|
+
open: boolean;
|
|
268
|
+
showLabel: boolean;
|
|
269
|
+
private triggerEl?;
|
|
270
|
+
private wrapperEl?;
|
|
271
|
+
private menuPos;
|
|
250
272
|
connectedCallback(): void;
|
|
251
273
|
updated(changed: Map<string, unknown>): void;
|
|
274
|
+
firstUpdated(): void;
|
|
275
|
+
disconnectedCallback(): void;
|
|
252
276
|
private get effectiveSymbol();
|
|
277
|
+
private getOptionBySymbol;
|
|
278
|
+
private getLogoUrl;
|
|
253
279
|
private onSelect;
|
|
280
|
+
private toggleDropdown;
|
|
281
|
+
private closeDropdown;
|
|
254
282
|
render(): lit.TemplateResult<1>;
|
|
255
283
|
}
|
|
256
284
|
declare global {
|
|
@@ -274,12 +302,26 @@ declare class ICPayPremiumContent extends LitElement {
|
|
|
274
302
|
private pendingAction;
|
|
275
303
|
private showWalletModal;
|
|
276
304
|
private pnp;
|
|
305
|
+
private showOnrampModal;
|
|
306
|
+
private onrampSessionId;
|
|
307
|
+
private onrampPaymentIntentId;
|
|
308
|
+
private onrampErrorMessage;
|
|
309
|
+
private transakMessageHandlerBound;
|
|
310
|
+
private onrampPollTimer;
|
|
311
|
+
private onrampPollingActive;
|
|
312
|
+
private onrampNotifyController;
|
|
277
313
|
private tryAutoConnectPNP;
|
|
278
314
|
private get cryptoOptions();
|
|
279
315
|
connectedCallback(): void;
|
|
280
316
|
protected updated(changed: Map<string, unknown>): void;
|
|
281
317
|
private loadVerifiedLedgers;
|
|
282
318
|
private onPay;
|
|
319
|
+
private attachTransakMessageListener;
|
|
320
|
+
private detachTransakMessageListener;
|
|
321
|
+
private onTransakMessage;
|
|
322
|
+
private startOnramp;
|
|
323
|
+
private createOnrampIntent;
|
|
324
|
+
private startOnrampPolling;
|
|
283
325
|
private select;
|
|
284
326
|
private getWalletId;
|
|
285
327
|
private getWalletLabel;
|
|
@@ -309,6 +351,14 @@ declare class ICPayTipJar extends LitElement {
|
|
|
309
351
|
private pendingAction;
|
|
310
352
|
private showWalletModal;
|
|
311
353
|
private pnp;
|
|
354
|
+
private showOnrampModal;
|
|
355
|
+
private onrampSessionId;
|
|
356
|
+
private onrampPaymentIntentId;
|
|
357
|
+
private onrampErrorMessage;
|
|
358
|
+
private transakMessageHandlerBound;
|
|
359
|
+
private onrampPollTimer;
|
|
360
|
+
private onrampPollingActive;
|
|
361
|
+
private onrampNotifyController;
|
|
312
362
|
private tryAutoConnectPNP;
|
|
313
363
|
private get amounts();
|
|
314
364
|
private get cryptoOptions();
|
|
@@ -319,6 +369,12 @@ declare class ICPayTipJar extends LitElement {
|
|
|
319
369
|
private selectSymbol;
|
|
320
370
|
private get fillPercentage();
|
|
321
371
|
private tip;
|
|
372
|
+
private attachTransakMessageListener;
|
|
373
|
+
private detachTransakMessageListener;
|
|
374
|
+
private onTransakMessage;
|
|
375
|
+
private startOnramp;
|
|
376
|
+
private createOnrampIntent;
|
|
377
|
+
private startOnrampPolling;
|
|
322
378
|
private getWalletId;
|
|
323
379
|
private getWalletLabel;
|
|
324
380
|
private getWalletIcon;
|
|
@@ -350,7 +406,21 @@ declare class ICPayArticlePaywall extends LitElement {
|
|
|
350
406
|
private pendingAction;
|
|
351
407
|
private showWalletModal;
|
|
352
408
|
private pnp;
|
|
409
|
+
private showOnrampModal;
|
|
410
|
+
private onrampSessionId;
|
|
411
|
+
private onrampPaymentIntentId;
|
|
412
|
+
private onrampErrorMessage;
|
|
413
|
+
private transakMessageHandlerBound;
|
|
414
|
+
private onrampPollTimer;
|
|
415
|
+
private onrampPollingActive;
|
|
416
|
+
private onrampNotifyController;
|
|
353
417
|
private tryAutoConnectPNP;
|
|
418
|
+
private attachTransakMessageListener;
|
|
419
|
+
private detachTransakMessageListener;
|
|
420
|
+
private onTransakMessage;
|
|
421
|
+
private startOnramp;
|
|
422
|
+
private createOnrampIntent;
|
|
423
|
+
private startOnrampPolling;
|
|
354
424
|
private get cryptoOptions();
|
|
355
425
|
connectedCallback(): void;
|
|
356
426
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -383,6 +453,14 @@ declare class ICPayCoffeeShop extends LitElement {
|
|
|
383
453
|
private pendingAction;
|
|
384
454
|
private showWalletModal;
|
|
385
455
|
private pnp;
|
|
456
|
+
private showOnrampModal;
|
|
457
|
+
private onrampSessionId;
|
|
458
|
+
private onrampPaymentIntentId;
|
|
459
|
+
private onrampErrorMessage;
|
|
460
|
+
private transakMessageHandlerBound;
|
|
461
|
+
private onrampPollTimer;
|
|
462
|
+
private onrampPollingActive;
|
|
463
|
+
private onrampNotifyController;
|
|
386
464
|
private get cryptoOptions();
|
|
387
465
|
connectedCallback(): void;
|
|
388
466
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -391,6 +469,12 @@ declare class ICPayCoffeeShop extends LitElement {
|
|
|
391
469
|
private selectSymbol;
|
|
392
470
|
private get selectedItem();
|
|
393
471
|
private order;
|
|
472
|
+
private attachTransakMessageListener;
|
|
473
|
+
private detachTransakMessageListener;
|
|
474
|
+
private onTransakMessage;
|
|
475
|
+
private startOnramp;
|
|
476
|
+
private createOnrampIntent;
|
|
477
|
+
private startOnrampPolling;
|
|
394
478
|
private getWalletId;
|
|
395
479
|
private getWalletLabel;
|
|
396
480
|
private getWalletIcon;
|
|
@@ -419,6 +503,14 @@ declare class ICPayDonationThermometer extends LitElement {
|
|
|
419
503
|
private pendingAction;
|
|
420
504
|
private showWalletModal;
|
|
421
505
|
private pnp;
|
|
506
|
+
private showOnrampModal;
|
|
507
|
+
private onrampSessionId;
|
|
508
|
+
private onrampPaymentIntentId;
|
|
509
|
+
private onrampErrorMessage;
|
|
510
|
+
private transakMessageHandlerBound;
|
|
511
|
+
private onrampPollTimer;
|
|
512
|
+
private onrampPollingActive;
|
|
513
|
+
private onrampNotifyController;
|
|
422
514
|
private tryAutoConnectPNP;
|
|
423
515
|
private get amounts();
|
|
424
516
|
private get cryptoOptions();
|
|
@@ -429,6 +521,12 @@ declare class ICPayDonationThermometer extends LitElement {
|
|
|
429
521
|
private selectSymbol;
|
|
430
522
|
private get fillPercentage();
|
|
431
523
|
private donate;
|
|
524
|
+
private attachTransakMessageListener;
|
|
525
|
+
private detachTransakMessageListener;
|
|
526
|
+
private onTransakMessage;
|
|
527
|
+
private startOnramp;
|
|
528
|
+
private createOnrampIntent;
|
|
529
|
+
private startOnrampPolling;
|
|
432
530
|
private getWalletId;
|
|
433
531
|
private getWalletLabel;
|
|
434
532
|
private getWalletIcon;
|
|
@@ -454,7 +552,17 @@ declare class ICPayPayButton extends LitElement {
|
|
|
454
552
|
private walletConnected;
|
|
455
553
|
private pendingAction;
|
|
456
554
|
private showWalletModal;
|
|
555
|
+
private showOnrampModal;
|
|
556
|
+
private onrampSessionId;
|
|
557
|
+
private onrampPaymentIntentId;
|
|
558
|
+
private onrampErrorMessage;
|
|
559
|
+
private onrampPollTimer;
|
|
560
|
+
private transakMessageHandlerBound;
|
|
457
561
|
private pnp;
|
|
562
|
+
private sdk;
|
|
563
|
+
private onrampPollingActive;
|
|
564
|
+
private onrampNotifyController;
|
|
565
|
+
private getSdk;
|
|
458
566
|
private get cryptoOptions();
|
|
459
567
|
connectedCallback(): void;
|
|
460
568
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -466,6 +574,12 @@ declare class ICPayPayButton extends LitElement {
|
|
|
466
574
|
private getWalletIcon;
|
|
467
575
|
private connectWithWallet;
|
|
468
576
|
private renderWalletModal;
|
|
577
|
+
private startOnramp;
|
|
578
|
+
private createOnrampIntent;
|
|
579
|
+
private attachTransakMessageListener;
|
|
580
|
+
private detachTransakMessageListener;
|
|
581
|
+
private onTransakMessage;
|
|
582
|
+
private startOnrampPolling;
|
|
469
583
|
private pay;
|
|
470
584
|
render(): lit.TemplateResult<1>;
|
|
471
585
|
}
|
|
@@ -490,7 +604,15 @@ declare class ICPayAmountInput extends LitElement {
|
|
|
490
604
|
private walletConnected;
|
|
491
605
|
private pendingAction;
|
|
492
606
|
private showWalletModal;
|
|
607
|
+
private showOnrampModal;
|
|
608
|
+
private onrampSessionId;
|
|
609
|
+
private onrampPaymentIntentId;
|
|
610
|
+
private onrampErrorMessage;
|
|
493
611
|
private pnp;
|
|
612
|
+
private transakMessageHandlerBound;
|
|
613
|
+
private onrampPollTimer;
|
|
614
|
+
private onrampPollingActive;
|
|
615
|
+
private onrampNotifyController;
|
|
494
616
|
private get cryptoOptions();
|
|
495
617
|
connectedCallback(): void;
|
|
496
618
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -503,6 +625,12 @@ declare class ICPayAmountInput extends LitElement {
|
|
|
503
625
|
private getWalletLabel;
|
|
504
626
|
private getWalletIcon;
|
|
505
627
|
private connectWithWallet;
|
|
628
|
+
private attachTransakMessageListener;
|
|
629
|
+
private detachTransakMessageListener;
|
|
630
|
+
private onTransakMessage;
|
|
631
|
+
private startOnramp;
|
|
632
|
+
private createOnrampIntent;
|
|
633
|
+
private startOnrampPolling;
|
|
506
634
|
private pay;
|
|
507
635
|
render(): lit.TemplateResult<1>;
|
|
508
636
|
}
|
|
@@ -512,4 +640,33 @@ declare global {
|
|
|
512
640
|
}
|
|
513
641
|
}
|
|
514
642
|
|
|
515
|
-
|
|
643
|
+
type Environment = 'STAGING' | 'PRODUCTION';
|
|
644
|
+
type TransakOnrampOptions = {
|
|
645
|
+
visible: boolean;
|
|
646
|
+
/** If provided, will embed Transak directly with session id */
|
|
647
|
+
sessionId?: string | null;
|
|
648
|
+
/** Optional error message to show when sessionId is missing */
|
|
649
|
+
errorMessage?: string | null;
|
|
650
|
+
/** Transak apiKey (public key). Required if using double-iframe helper */
|
|
651
|
+
apiKey?: string | null;
|
|
652
|
+
/** Controls staging vs production */
|
|
653
|
+
environment?: Environment;
|
|
654
|
+
/** Optional width/height for inner iframe */
|
|
655
|
+
width?: number | string;
|
|
656
|
+
height?: number | string;
|
|
657
|
+
/** Called when user closes modal */
|
|
658
|
+
onClose: () => void;
|
|
659
|
+
/** Called when user clicks to go back to wallet selector */
|
|
660
|
+
onBack?: () => void;
|
|
661
|
+
};
|
|
662
|
+
/**
|
|
663
|
+
* Renders a modal containing Transak onramp widget.
|
|
664
|
+
* - If sessionId is present, we embed Transak directly using the session flow URL.
|
|
665
|
+
* - Otherwise, we fall back to Transak's double-iframe helper page that loads an inner iframe
|
|
666
|
+
* pointing to global-stg/global with the provided apiKey.
|
|
667
|
+
*
|
|
668
|
+
* Reference: https://docs.transak.com/docs/double-embed-iframe-webapp
|
|
669
|
+
*/
|
|
670
|
+
declare function renderTransakOnrampModal(opts: TransakOnrampOptions): TemplateResult | null;
|
|
671
|
+
|
|
672
|
+
export { type AmountInputConfig, type ArticlePaywallConfig, type CoffeeShopConfig, type CommonConfig, type CryptoOption, type DonationThermometerConfig, ICPayAmountInput, ICPayArticlePaywall, ICPayCoffeeShop, ICPayDonationThermometer, ICPayPayButton, ICPayPremiumContent, ICPayTipJar, type OnrampConfig, type PayButtonConfig, type PlugNPlayConfig, type PremiumContentConfig, type ProgressBarConfig, type ThemeConfig, type TipJarConfig, type WidgetSdk, applyThemeVars, baseStyles, createSdk, renderTransakOnrampModal };
|