@blocklet/payment-react 1.24.4 → 1.25.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.
- package/es/components/auto-topup/modal.d.ts +2 -0
- package/es/components/auto-topup/modal.js +48 -6
- package/es/components/auto-topup/product-card.d.ts +16 -1
- package/es/components/auto-topup/product-card.js +97 -15
- package/es/components/dynamic-pricing-unavailable.d.ts +9 -0
- package/es/components/dynamic-pricing-unavailable.js +58 -0
- package/es/components/loading-amount.d.ts +17 -0
- package/es/components/loading-amount.js +46 -0
- package/es/components/price-change-confirm.d.ts +18 -0
- package/es/components/price-change-confirm.js +107 -0
- package/es/components/quote-details-panel.d.ts +21 -0
- package/es/components/quote-details-panel.js +170 -0
- package/es/components/quote-lock-banner.d.ts +7 -0
- package/es/components/quote-lock-banner.js +79 -0
- package/es/components/slippage-config.d.ts +20 -0
- package/es/components/slippage-config.js +261 -0
- package/es/history/invoice/list.js +125 -15
- package/es/hooks/dynamic-pricing.d.ts +102 -0
- package/es/hooks/dynamic-pricing.js +393 -0
- package/es/index.d.ts +6 -1
- package/es/index.js +9 -1
- package/es/libs/util.d.ts +42 -5
- package/es/libs/util.js +345 -57
- package/es/locales/en.js +114 -3
- package/es/locales/zh.js +114 -3
- package/es/payment/form/index.d.ts +4 -1
- package/es/payment/form/index.js +454 -22
- package/es/payment/index.d.ts +1 -1
- package/es/payment/index.js +279 -16
- package/es/payment/product-item.d.ts +26 -1
- package/es/payment/product-item.js +330 -51
- package/es/payment/summary-section/promotion-section.d.ts +32 -0
- package/es/payment/summary-section/promotion-section.js +143 -0
- package/es/payment/summary-section/total-section.d.ts +39 -0
- package/es/payment/summary-section/total-section.js +83 -0
- package/es/payment/summary.d.ts +17 -2
- package/es/payment/summary.js +300 -253
- package/es/types/index.d.ts +11 -0
- package/lib/components/auto-topup/modal.d.ts +2 -0
- package/lib/components/auto-topup/modal.js +54 -6
- package/lib/components/auto-topup/product-card.d.ts +16 -1
- package/lib/components/auto-topup/product-card.js +75 -7
- package/lib/components/dynamic-pricing-unavailable.d.ts +9 -0
- package/lib/components/dynamic-pricing-unavailable.js +81 -0
- package/lib/components/loading-amount.d.ts +17 -0
- package/lib/components/loading-amount.js +53 -0
- package/lib/components/price-change-confirm.d.ts +18 -0
- package/lib/components/price-change-confirm.js +157 -0
- package/lib/components/quote-details-panel.d.ts +21 -0
- package/lib/components/quote-details-panel.js +226 -0
- package/lib/components/quote-lock-banner.d.ts +7 -0
- package/lib/components/quote-lock-banner.js +93 -0
- package/lib/components/slippage-config.d.ts +20 -0
- package/lib/components/slippage-config.js +316 -0
- package/lib/history/invoice/list.js +167 -27
- package/lib/hooks/dynamic-pricing.d.ts +102 -0
- package/lib/hooks/dynamic-pricing.js +390 -0
- package/lib/index.d.ts +6 -1
- package/lib/index.js +32 -0
- package/lib/libs/util.d.ts +42 -5
- package/lib/libs/util.js +367 -49
- package/lib/locales/en.js +114 -3
- package/lib/locales/zh.js +114 -3
- package/lib/payment/form/index.d.ts +4 -1
- package/lib/payment/form/index.js +476 -20
- package/lib/payment/index.d.ts +1 -1
- package/lib/payment/index.js +308 -14
- package/lib/payment/product-item.d.ts +26 -1
- package/lib/payment/product-item.js +270 -35
- package/lib/payment/summary-section/promotion-section.d.ts +32 -0
- package/lib/payment/summary-section/promotion-section.js +133 -0
- package/lib/payment/summary-section/total-section.d.ts +39 -0
- package/lib/payment/summary-section/total-section.js +117 -0
- package/lib/payment/summary.d.ts +17 -2
- package/lib/payment/summary.js +205 -127
- package/lib/types/index.d.ts +11 -0
- package/package.json +3 -3
- package/src/components/auto-topup/modal.tsx +59 -6
- package/src/components/auto-topup/product-card.tsx +118 -11
- package/src/components/dynamic-pricing-unavailable.tsx +69 -0
- package/src/components/loading-amount.tsx +66 -0
- package/src/components/price-change-confirm.tsx +136 -0
- package/src/components/quote-details-panel.tsx +218 -0
- package/src/components/quote-lock-banner.tsx +99 -0
- package/src/components/slippage-config.tsx +336 -0
- package/src/history/invoice/list.tsx +143 -9
- package/src/hooks/dynamic-pricing.ts +617 -0
- package/src/index.ts +9 -0
- package/src/libs/util.ts +473 -58
- package/src/locales/en.tsx +117 -0
- package/src/locales/zh.tsx +111 -0
- package/src/payment/form/index.tsx +561 -19
- package/src/payment/index.tsx +349 -10
- package/src/payment/product-item.tsx +451 -37
- package/src/payment/summary-section/promotion-section.tsx +172 -0
- package/src/payment/summary-section/total-section.tsx +141 -0
- package/src/payment/summary.tsx +334 -192
- package/src/types/index.ts +15 -0
package/es/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ import StripeForm from './payment/form/stripe';
|
|
|
26
26
|
import Payment from './payment/index';
|
|
27
27
|
import ProductSkeleton from './payment/product-skeleton';
|
|
28
28
|
import PaymentSummary from './payment/summary';
|
|
29
|
+
import PromotionSection from './payment/summary-section/promotion-section';
|
|
30
|
+
import TotalSection from './payment/summary-section/total-section';
|
|
29
31
|
import PricingItem from './components/pricing-item';
|
|
30
32
|
import CountrySelect from './components/country-select';
|
|
31
33
|
import TruncatedText from './components/truncated-text';
|
|
@@ -42,6 +44,8 @@ import AutoTopup from './components/auto-topup';
|
|
|
42
44
|
import Collapse from './components/collapse';
|
|
43
45
|
import PromotionCode from './components/promotion-code';
|
|
44
46
|
import SourceDataViewer from './components/source-data-viewer';
|
|
47
|
+
import SlippageConfig from './components/slippage-config';
|
|
48
|
+
import DynamicPricingUnavailable from './components/dynamic-pricing-unavailable';
|
|
45
49
|
export { PaymentThemeProvider } from './theme';
|
|
46
50
|
export * from './libs/util';
|
|
47
51
|
export * from './libs/connect';
|
|
@@ -56,6 +60,7 @@ export * from './hooks/scroll';
|
|
|
56
60
|
export * from './hooks/keyboard';
|
|
57
61
|
export * from './libs/validator';
|
|
58
62
|
export { translations, createTranslator } from './locales';
|
|
59
|
-
export { createLazyComponent, api, dayjs, FormInput, FormLabel, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, StripePaymentAction, PaymentBeneficiaries, LoadingButton, DonateDetails, ResumeSubscription, CreditGrantsList, CreditTransactionsList, DateRangePicker, CreditStatusChip, AutoTopupModal, AutoTopup, Collapse, PromotionCode, SourceDataViewer, };
|
|
63
|
+
export { createLazyComponent, api, dayjs, FormInput, FormLabel, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, StripePaymentAction, PaymentBeneficiaries, LoadingButton, DonateDetails, ResumeSubscription, CreditGrantsList, CreditTransactionsList, DateRangePicker, CreditStatusChip, AutoTopupModal, AutoTopup, Collapse, PromotionCode, SourceDataViewer, SlippageConfig, DynamicPricingUnavailable, PromotionSection, TotalSection, };
|
|
60
64
|
export type { CountrySelectProps } from './components/country-select';
|
|
61
65
|
export type { StripePaymentActionProps } from './components/stripe-payment-action';
|
|
66
|
+
export type { SlippageConfigValue, SlippageConfigProps } from './components/slippage-config';
|
package/es/index.js
CHANGED
|
@@ -26,6 +26,8 @@ import StripeForm from "./payment/form/stripe/index.js";
|
|
|
26
26
|
import Payment from "./payment/index.js";
|
|
27
27
|
import ProductSkeleton from "./payment/product-skeleton.js";
|
|
28
28
|
import PaymentSummary from "./payment/summary.js";
|
|
29
|
+
import PromotionSection from "./payment/summary-section/promotion-section.js";
|
|
30
|
+
import TotalSection from "./payment/summary-section/total-section.js";
|
|
29
31
|
import PricingItem from "./components/pricing-item.js";
|
|
30
32
|
import CountrySelect from "./components/country-select.js";
|
|
31
33
|
import TruncatedText from "./components/truncated-text.js";
|
|
@@ -42,6 +44,8 @@ import AutoTopup from "./components/auto-topup/index.js";
|
|
|
42
44
|
import Collapse from "./components/collapse.js";
|
|
43
45
|
import PromotionCode from "./components/promotion-code.js";
|
|
44
46
|
import SourceDataViewer from "./components/source-data-viewer.js";
|
|
47
|
+
import SlippageConfig from "./components/slippage-config.js";
|
|
48
|
+
import DynamicPricingUnavailable from "./components/dynamic-pricing-unavailable.js";
|
|
45
49
|
export { PaymentThemeProvider } from "./theme/index.js";
|
|
46
50
|
export * from "./libs/util.js";
|
|
47
51
|
export * from "./libs/connect.js";
|
|
@@ -102,5 +106,9 @@ export {
|
|
|
102
106
|
AutoTopup,
|
|
103
107
|
Collapse,
|
|
104
108
|
PromotionCode,
|
|
105
|
-
SourceDataViewer
|
|
109
|
+
SourceDataViewer,
|
|
110
|
+
SlippageConfig,
|
|
111
|
+
DynamicPricingUnavailable,
|
|
112
|
+
PromotionSection,
|
|
113
|
+
TotalSection
|
|
106
114
|
};
|
package/es/libs/util.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PaymentDetails, PriceCurrency, PriceRecurring, TCoupon, TInvoiceExpanded, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TProductExpanded, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
2
|
+
import { BN } from '@ocap/util';
|
|
2
3
|
import type { ActionProps, PricingRenderProps } from '../types';
|
|
3
4
|
export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
4
5
|
/**
|
|
@@ -38,15 +39,45 @@ export declare function formatCreditAmount(formattedAmount: string, currencySymb
|
|
|
38
39
|
*/
|
|
39
40
|
export declare function formatCreditForCheckout(formattedAmount: string, currencySymbol: string, locale?: string, showUnit?: boolean): string;
|
|
40
41
|
export declare function formatNumber(n: number | string, precision?: number, trim?: boolean, thousandSeparated?: boolean): string;
|
|
42
|
+
export declare function formatDynamicPrice(n: number | string, isDynamic: boolean, precision?: number, trim?: boolean, thousandSeparated?: boolean): string;
|
|
43
|
+
export declare function getUsdAmountFromBaseAmount(amount: string | number | undefined, quantity: number, scale?: number): string | null;
|
|
44
|
+
export declare function getUsdAmountFromTokenUnits(tokenAmount: BN | string, tokenDecimals: number, exchangeRate?: string | null): string | null;
|
|
45
|
+
export declare function formatUsdAmount(amount: string | null, locale?: string): string | null;
|
|
46
|
+
export declare function formatExchangeRate(amount: string | null): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Format exchange rate with currency symbol for display
|
|
49
|
+
* @param rate - The exchange rate value
|
|
50
|
+
* @param currency - The currency code (default: 'USD')
|
|
51
|
+
* @param decimals - Number of decimal places (default: 2, use 4 for live exchange rates)
|
|
52
|
+
* @returns Formatted string like "$0.12" for USD, or "0.12 EUR" for other currencies
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatExchangeRateDisplay(rate: string | number | null | undefined, currency?: string, decimals?: number): string | null;
|
|
41
55
|
export declare const formatPrice: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean, locale?: string) => string;
|
|
42
|
-
export declare const formatPriceAmount: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean) => string;
|
|
56
|
+
export declare const formatPriceAmount: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean, locale?: string) => string;
|
|
43
57
|
export declare function getStatementDescriptor(items: any[]): any;
|
|
44
58
|
export declare function formatRecurring(recurring: PriceRecurring, translate?: boolean, separator?: string, locale?: string): string;
|
|
45
59
|
export declare function getPriceUintAmountByCurrency(price: TPrice, currency: TPaymentCurrency): string;
|
|
46
60
|
export declare function getPriceCurrencyOptions(price: TPrice): PriceCurrency[];
|
|
47
|
-
export declare function
|
|
61
|
+
export declare function getLineItemAmounts(item: TLineItemExpanded, currency: TPaymentCurrency, { useUpsell, exchangeRate }?: {
|
|
62
|
+
useUpsell?: boolean;
|
|
63
|
+
exchangeRate?: string | null;
|
|
64
|
+
}): {
|
|
65
|
+
unitAmount: BN;
|
|
66
|
+
totalAmount: BN;
|
|
67
|
+
isDynamicQuote: boolean;
|
|
68
|
+
};
|
|
69
|
+
export type QuoteLockInfo = {
|
|
70
|
+
baseAmount: string;
|
|
71
|
+
baseCurrency: string;
|
|
72
|
+
tokenAmount: string;
|
|
73
|
+
tokenSymbol: string;
|
|
74
|
+
expiresAt: number | null;
|
|
75
|
+
};
|
|
76
|
+
export declare function getQuoteLockInfo(items: TLineItemExpanded[], currency?: TPaymentCurrency | null): QuoteLockInfo | null;
|
|
77
|
+
export declare function formatLineItemPricing(item: TLineItemExpanded, currency: TPaymentCurrency, { trialEnd, trialInDays, exchangeRate, }: {
|
|
48
78
|
trialEnd: number;
|
|
49
79
|
trialInDays: number;
|
|
80
|
+
exchangeRate?: string | null;
|
|
50
81
|
}, locale?: string): {
|
|
51
82
|
primary: string;
|
|
52
83
|
secondary?: string;
|
|
@@ -58,7 +89,9 @@ export declare function getRefundStatusColor(status: string): "default" | "succe
|
|
|
58
89
|
export declare function getPayoutStatusColor(status: string): "default" | "success" | "warning";
|
|
59
90
|
export declare function getInvoiceStatusColor(status: string): "default" | "success" | "warning" | "secondary";
|
|
60
91
|
export declare function getWebhookStatusColor(status: string): "default" | "success";
|
|
61
|
-
export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean
|
|
92
|
+
export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean, { exchangeRate }?: {
|
|
93
|
+
exchangeRate?: string | null;
|
|
94
|
+
}): {
|
|
62
95
|
subtotal: any;
|
|
63
96
|
total: any;
|
|
64
97
|
renew: string;
|
|
@@ -69,6 +102,7 @@ export declare function getCheckoutAmount(items: TLineItemExpanded[], currency:
|
|
|
69
102
|
export declare function getRecurringPeriod(recurring: PriceRecurring): number;
|
|
70
103
|
export declare function formatUpsellSaving(items: TLineItemExpanded[], currency: TPaymentCurrency): string;
|
|
71
104
|
export declare function formatMeteredThen(subscription: string, recurring: string, hasMetered: boolean, locale?: string): string;
|
|
105
|
+
export declare function formatThenValue(subscription: string, recurring: string, hasMetered: boolean, locale?: string): string;
|
|
72
106
|
export declare function formatPriceDisplay({ amount, then, actualAmount, showThen }: {
|
|
73
107
|
amount: string;
|
|
74
108
|
then?: string;
|
|
@@ -86,16 +120,19 @@ export declare function getFreeTrialTime({ trialInDays, trialEnd }: {
|
|
|
86
120
|
export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], currency: TPaymentCurrency, { trialInDays, trialEnd }: {
|
|
87
121
|
trialInDays: number;
|
|
88
122
|
trialEnd: number;
|
|
89
|
-
}, locale?: string
|
|
123
|
+
}, locale?: string, { exchangeRate }?: {
|
|
124
|
+
exchangeRate?: string | null;
|
|
125
|
+
}): {
|
|
90
126
|
action: string;
|
|
91
127
|
amount: string;
|
|
92
128
|
then?: string;
|
|
129
|
+
thenValue?: string;
|
|
93
130
|
secondary?: string;
|
|
94
131
|
showThen?: boolean;
|
|
95
132
|
actualAmount: string;
|
|
96
133
|
priceDisplay: string;
|
|
97
134
|
};
|
|
98
|
-
export declare function formatAmount(amount: string, decimals: number): string;
|
|
135
|
+
export declare function formatAmount(amount: string, decimals: number, precision?: number): string;
|
|
99
136
|
export declare function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string): TPaymentCurrencyExpanded | null;
|
|
100
137
|
export declare function isValidCountry(code: string): boolean;
|
|
101
138
|
export declare function stopEvent(e: React.SyntheticEvent<any>): void;
|