@ic-pay/icpay-widget 0.1.88 → 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 +148 -2
- package/dist/index.global.js +448 -393
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +142 -87
- 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;
|
|
@@ -285,12 +302,26 @@ declare class ICPayPremiumContent extends LitElement {
|
|
|
285
302
|
private pendingAction;
|
|
286
303
|
private showWalletModal;
|
|
287
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;
|
|
288
313
|
private tryAutoConnectPNP;
|
|
289
314
|
private get cryptoOptions();
|
|
290
315
|
connectedCallback(): void;
|
|
291
316
|
protected updated(changed: Map<string, unknown>): void;
|
|
292
317
|
private loadVerifiedLedgers;
|
|
293
318
|
private onPay;
|
|
319
|
+
private attachTransakMessageListener;
|
|
320
|
+
private detachTransakMessageListener;
|
|
321
|
+
private onTransakMessage;
|
|
322
|
+
private startOnramp;
|
|
323
|
+
private createOnrampIntent;
|
|
324
|
+
private startOnrampPolling;
|
|
294
325
|
private select;
|
|
295
326
|
private getWalletId;
|
|
296
327
|
private getWalletLabel;
|
|
@@ -320,6 +351,14 @@ declare class ICPayTipJar extends LitElement {
|
|
|
320
351
|
private pendingAction;
|
|
321
352
|
private showWalletModal;
|
|
322
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;
|
|
323
362
|
private tryAutoConnectPNP;
|
|
324
363
|
private get amounts();
|
|
325
364
|
private get cryptoOptions();
|
|
@@ -330,6 +369,12 @@ declare class ICPayTipJar extends LitElement {
|
|
|
330
369
|
private selectSymbol;
|
|
331
370
|
private get fillPercentage();
|
|
332
371
|
private tip;
|
|
372
|
+
private attachTransakMessageListener;
|
|
373
|
+
private detachTransakMessageListener;
|
|
374
|
+
private onTransakMessage;
|
|
375
|
+
private startOnramp;
|
|
376
|
+
private createOnrampIntent;
|
|
377
|
+
private startOnrampPolling;
|
|
333
378
|
private getWalletId;
|
|
334
379
|
private getWalletLabel;
|
|
335
380
|
private getWalletIcon;
|
|
@@ -361,7 +406,21 @@ declare class ICPayArticlePaywall extends LitElement {
|
|
|
361
406
|
private pendingAction;
|
|
362
407
|
private showWalletModal;
|
|
363
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;
|
|
364
417
|
private tryAutoConnectPNP;
|
|
418
|
+
private attachTransakMessageListener;
|
|
419
|
+
private detachTransakMessageListener;
|
|
420
|
+
private onTransakMessage;
|
|
421
|
+
private startOnramp;
|
|
422
|
+
private createOnrampIntent;
|
|
423
|
+
private startOnrampPolling;
|
|
365
424
|
private get cryptoOptions();
|
|
366
425
|
connectedCallback(): void;
|
|
367
426
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -394,6 +453,14 @@ declare class ICPayCoffeeShop extends LitElement {
|
|
|
394
453
|
private pendingAction;
|
|
395
454
|
private showWalletModal;
|
|
396
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;
|
|
397
464
|
private get cryptoOptions();
|
|
398
465
|
connectedCallback(): void;
|
|
399
466
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -402,6 +469,12 @@ declare class ICPayCoffeeShop extends LitElement {
|
|
|
402
469
|
private selectSymbol;
|
|
403
470
|
private get selectedItem();
|
|
404
471
|
private order;
|
|
472
|
+
private attachTransakMessageListener;
|
|
473
|
+
private detachTransakMessageListener;
|
|
474
|
+
private onTransakMessage;
|
|
475
|
+
private startOnramp;
|
|
476
|
+
private createOnrampIntent;
|
|
477
|
+
private startOnrampPolling;
|
|
405
478
|
private getWalletId;
|
|
406
479
|
private getWalletLabel;
|
|
407
480
|
private getWalletIcon;
|
|
@@ -430,6 +503,14 @@ declare class ICPayDonationThermometer extends LitElement {
|
|
|
430
503
|
private pendingAction;
|
|
431
504
|
private showWalletModal;
|
|
432
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;
|
|
433
514
|
private tryAutoConnectPNP;
|
|
434
515
|
private get amounts();
|
|
435
516
|
private get cryptoOptions();
|
|
@@ -440,6 +521,12 @@ declare class ICPayDonationThermometer extends LitElement {
|
|
|
440
521
|
private selectSymbol;
|
|
441
522
|
private get fillPercentage();
|
|
442
523
|
private donate;
|
|
524
|
+
private attachTransakMessageListener;
|
|
525
|
+
private detachTransakMessageListener;
|
|
526
|
+
private onTransakMessage;
|
|
527
|
+
private startOnramp;
|
|
528
|
+
private createOnrampIntent;
|
|
529
|
+
private startOnrampPolling;
|
|
443
530
|
private getWalletId;
|
|
444
531
|
private getWalletLabel;
|
|
445
532
|
private getWalletIcon;
|
|
@@ -465,7 +552,17 @@ declare class ICPayPayButton extends LitElement {
|
|
|
465
552
|
private walletConnected;
|
|
466
553
|
private pendingAction;
|
|
467
554
|
private showWalletModal;
|
|
555
|
+
private showOnrampModal;
|
|
556
|
+
private onrampSessionId;
|
|
557
|
+
private onrampPaymentIntentId;
|
|
558
|
+
private onrampErrorMessage;
|
|
559
|
+
private onrampPollTimer;
|
|
560
|
+
private transakMessageHandlerBound;
|
|
468
561
|
private pnp;
|
|
562
|
+
private sdk;
|
|
563
|
+
private onrampPollingActive;
|
|
564
|
+
private onrampNotifyController;
|
|
565
|
+
private getSdk;
|
|
469
566
|
private get cryptoOptions();
|
|
470
567
|
connectedCallback(): void;
|
|
471
568
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -477,6 +574,12 @@ declare class ICPayPayButton extends LitElement {
|
|
|
477
574
|
private getWalletIcon;
|
|
478
575
|
private connectWithWallet;
|
|
479
576
|
private renderWalletModal;
|
|
577
|
+
private startOnramp;
|
|
578
|
+
private createOnrampIntent;
|
|
579
|
+
private attachTransakMessageListener;
|
|
580
|
+
private detachTransakMessageListener;
|
|
581
|
+
private onTransakMessage;
|
|
582
|
+
private startOnrampPolling;
|
|
480
583
|
private pay;
|
|
481
584
|
render(): lit.TemplateResult<1>;
|
|
482
585
|
}
|
|
@@ -501,7 +604,15 @@ declare class ICPayAmountInput extends LitElement {
|
|
|
501
604
|
private walletConnected;
|
|
502
605
|
private pendingAction;
|
|
503
606
|
private showWalletModal;
|
|
607
|
+
private showOnrampModal;
|
|
608
|
+
private onrampSessionId;
|
|
609
|
+
private onrampPaymentIntentId;
|
|
610
|
+
private onrampErrorMessage;
|
|
504
611
|
private pnp;
|
|
612
|
+
private transakMessageHandlerBound;
|
|
613
|
+
private onrampPollTimer;
|
|
614
|
+
private onrampPollingActive;
|
|
615
|
+
private onrampNotifyController;
|
|
505
616
|
private get cryptoOptions();
|
|
506
617
|
connectedCallback(): void;
|
|
507
618
|
protected updated(changed: Map<string, unknown>): void;
|
|
@@ -514,6 +625,12 @@ declare class ICPayAmountInput extends LitElement {
|
|
|
514
625
|
private getWalletLabel;
|
|
515
626
|
private getWalletIcon;
|
|
516
627
|
private connectWithWallet;
|
|
628
|
+
private attachTransakMessageListener;
|
|
629
|
+
private detachTransakMessageListener;
|
|
630
|
+
private onTransakMessage;
|
|
631
|
+
private startOnramp;
|
|
632
|
+
private createOnrampIntent;
|
|
633
|
+
private startOnrampPolling;
|
|
517
634
|
private pay;
|
|
518
635
|
render(): lit.TemplateResult<1>;
|
|
519
636
|
}
|
|
@@ -523,4 +640,33 @@ declare global {
|
|
|
523
640
|
}
|
|
524
641
|
}
|
|
525
642
|
|
|
526
|
-
|
|
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 };
|