@imtbl/checkout-widgets 2.13.1-alpha.0 → 2.13.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{AddTokensWidget-BqYVKXwq.js → AddTokensWidget-DtxxgqCF.js} +3 -3
- package/dist/browser/{BridgeWidget-msFHkKih.js → BridgeWidget-BZuzfW2J.js} +7 -7
- package/dist/browser/{CommerceWidget-CILJs_vD.js → CommerceWidget-C77uJBo2.js} +13 -13
- package/dist/browser/{FeesBreakdown-CfqEJ3aK.js → FeesBreakdown-CRh1DLhl.js} +1 -1
- package/dist/browser/{OnRampWidget-D0wM_7ZM.js → OnRampWidget-BhN5m26y.js} +3 -3
- package/dist/browser/{SaleWidget-xwh_4tRb.js → SaleWidget-D6Ace1BZ.js} +47 -17
- package/dist/browser/{SpendingCapHero-BNKv-C0j.js → SpendingCapHero-yVpOdczj.js} +1 -1
- package/dist/browser/{SwapWidget-DPHgUweH.js → SwapWidget-ClIRsyTo.js} +6 -6
- package/dist/browser/{TokenImage-R4f2g0X1.js → TokenImage-BP8hEsU_.js} +1 -1
- package/dist/browser/{TopUpView-DwLVMHcA.js → TopUpView-jh7TXNI-.js} +1 -1
- package/dist/browser/{WalletApproveHero-BC3-HSDe.js → WalletApproveHero-Eg7vp2Us.js} +2 -2
- package/dist/browser/{WalletWidget-B8y8lJS0.js → WalletWidget-C51tZZB0.js} +3 -3
- package/dist/browser/{auto-track-C5k_pAab.js → auto-track-DsvmUw_O.js} +1 -1
- package/dist/browser/{index-DheR-vpe.js → index-B3VZS6ym.js} +1 -1
- package/dist/browser/{index-BUK5KgI7.js → index-B_FiZcJq.js} +1 -1
- package/dist/browser/{index-CHSzGpNA.js → index-BjKL0jz3.js} +1 -1
- package/dist/browser/{index-DYz65wGh.js → index-Cl_Sj41T.js} +1 -1
- package/dist/browser/{index-BJ2jwG_p.js → index-Ct3oyZEC.js} +40 -24
- package/dist/browser/{index-DQgsBfzr.js → index-DWE9xBUf.js} +1 -1
- package/dist/browser/{index-jrtMmWeP.js → index-DXv1oK4B.js} +2 -2
- package/dist/browser/{index-DfwJk-cv.js → index-kT3FIcpI.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{index.umd-D3pHV3LA.js → index.umd-DvqLg8Q3.js} +1 -1
- package/dist/browser/{useInterval-C5gF06RQ.js → useInterval-BnmMwpZh.js} +1 -1
- package/dist/types/context/view-context/SaleViewContextTypes.d.ts +4 -0
- package/dist/types/widgets/sale/context/SaleContextProvider.d.ts +1 -1
- package/dist/types/widgets/sale/hooks/useQuoteOrder.d.ts +1 -1
- package/dist/types/widgets/sale/types.d.ts +8 -2
- package/dist/types/widgets/sale/views/SaleErrorView.d.ts +2 -1
- package/package.json +7 -7
- package/src/context/view-context/SaleViewContextTypes.ts +1 -0
- package/src/locales/en.json +4 -0
- package/src/locales/ja.json +4 -0
- package/src/locales/ko.json +4 -0
- package/src/locales/zh.json +4 -0
- package/src/widgets/sale/SaleWidget.tsx +1 -0
- package/src/widgets/sale/context/SaleContextProvider.tsx +10 -3
- package/src/widgets/sale/hooks/useQuoteOrder.ts +11 -1
- package/src/widgets/sale/hooks/useSignOrder.ts +9 -3
- package/src/widgets/sale/types.ts +4 -1
- package/src/widgets/sale/views/SaleErrorView.tsx +14 -3
|
@@ -38,7 +38,7 @@ type SaleContextValues = SaleContextProps & {
|
|
|
38
38
|
paymentMethod: SalePaymentTypes | undefined;
|
|
39
39
|
setPaymentMethod: (paymentMethod: SalePaymentTypes | undefined) => void;
|
|
40
40
|
goBackToPaymentMethods: (paymentMethod?: SalePaymentTypes | undefined, data?: Record<string, unknown>) => void;
|
|
41
|
-
goToErrorView: (type: SaleErrorTypes, data?: Record<string,
|
|
41
|
+
goToErrorView: (type: SaleErrorTypes, data?: Record<string, unknown>) => void;
|
|
42
42
|
goToSuccessView: (data?: Record<string, unknown>) => void;
|
|
43
43
|
fundingRoutes: FundingRoute[];
|
|
44
44
|
disabledPaymentTypes: SalePaymentTypes[];
|
|
@@ -11,7 +11,7 @@ type UseQuoteOrderParams = {
|
|
|
11
11
|
export declare const defaultOrderQuote: OrderQuote;
|
|
12
12
|
export type ConfigError = {
|
|
13
13
|
type: SaleErrorTypes;
|
|
14
|
-
data?: Record<string,
|
|
14
|
+
data?: Record<string, unknown>;
|
|
15
15
|
};
|
|
16
16
|
export declare const useQuoteOrder: ({ items, environment, environmentId, provider, preferredCurrency, }: UseQuoteOrderParams) => {
|
|
17
17
|
orderQuote: OrderQuote;
|
|
@@ -47,7 +47,12 @@ export type SignOrderInput = {
|
|
|
47
47
|
};
|
|
48
48
|
export type SignOrderError = {
|
|
49
49
|
type: SaleErrorTypes;
|
|
50
|
-
data?: Record<string, string
|
|
50
|
+
data?: Record<string, string> | {
|
|
51
|
+
vendorError: {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
51
56
|
};
|
|
52
57
|
export type ExecutedTransaction = {
|
|
53
58
|
method: string;
|
|
@@ -69,7 +74,8 @@ export declare enum SaleErrorTypes {
|
|
|
69
74
|
WALLET_REJECTED = "WALLET_REJECTED",
|
|
70
75
|
WALLET_REJECTED_NO_FUNDS = "WALLET_REJECTED_NO_FUNDS",
|
|
71
76
|
WALLET_POPUP_BLOCKED = "WALLET_POPUP_BLOCKED",
|
|
72
|
-
FUNDING_ROUTE_EXECUTE_ERROR = "FUNDING_ROUTE_EXECUTE_ERROR"
|
|
77
|
+
FUNDING_ROUTE_EXECUTE_ERROR = "FUNDING_ROUTE_EXECUTE_ERROR",
|
|
78
|
+
SALE_AUTHORIZATION_REJECTED = "SALE_AUTHORIZATION_REJECTED"
|
|
73
79
|
}
|
|
74
80
|
export type OrderQuoteCurrency = {
|
|
75
81
|
base: boolean;
|
|
@@ -5,6 +5,7 @@ type SaleErrorViewProps = {
|
|
|
5
5
|
errorType: SaleErrorTypes | undefined;
|
|
6
6
|
transactionHash?: string;
|
|
7
7
|
blockExplorerLink?: string;
|
|
8
|
+
vendorMessage?: string;
|
|
8
9
|
};
|
|
9
|
-
export declare function SaleErrorView({ biomeTheme, transactionHash, blockExplorerLink, errorType, }: SaleErrorViewProps): null;
|
|
10
|
+
export declare function SaleErrorView({ biomeTheme, transactionHash, blockExplorerLink, errorType, vendorMessage, }: SaleErrorViewProps): null;
|
|
10
11
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/checkout-widgets",
|
|
3
|
-
"version": "2.13.1-alpha.
|
|
3
|
+
"version": "2.13.1-alpha.2",
|
|
4
4
|
"browserslist": {
|
|
5
5
|
"production": [
|
|
6
6
|
">0.2%",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"@biom3/design-tokens": "^0.4.5",
|
|
19
19
|
"@biom3/react": "^0.29.4",
|
|
20
20
|
"@emotion/react": "^11.11.3",
|
|
21
|
-
"@imtbl/bridge-sdk": "2.13.1-alpha.
|
|
22
|
-
"@imtbl/checkout-sdk": "2.13.1-alpha.
|
|
23
|
-
"@imtbl/config": "2.13.1-alpha.
|
|
24
|
-
"@imtbl/cryptofiat": "2.13.1-alpha.
|
|
25
|
-
"@imtbl/dex-sdk": "2.13.1-alpha.
|
|
26
|
-
"@imtbl/passport": "2.13.1-alpha.
|
|
21
|
+
"@imtbl/bridge-sdk": "2.13.1-alpha.2",
|
|
22
|
+
"@imtbl/checkout-sdk": "2.13.1-alpha.2",
|
|
23
|
+
"@imtbl/config": "2.13.1-alpha.2",
|
|
24
|
+
"@imtbl/cryptofiat": "2.13.1-alpha.2",
|
|
25
|
+
"@imtbl/dex-sdk": "2.13.1-alpha.2",
|
|
26
|
+
"@imtbl/passport": "2.13.1-alpha.2",
|
|
27
27
|
"@imtbl/react-analytics": "0.3.4-alpha",
|
|
28
28
|
"@rive-app/react-canvas-lite": "^4.9.0",
|
|
29
29
|
"@walletconnect/ethereum-provider": "^2.11.1",
|
package/src/locales/en.json
CHANGED
|
@@ -499,6 +499,10 @@
|
|
|
499
499
|
"primaryAction": "Try again",
|
|
500
500
|
"secondaryAction": "Cancel"
|
|
501
501
|
},
|
|
502
|
+
"SALE_AUTHORIZATION_REJECTED": {
|
|
503
|
+
"description": "Sorry, your purchase could not be completed.",
|
|
504
|
+
"secondaryAction": "Dismiss"
|
|
505
|
+
},
|
|
502
506
|
"DEFAULT_ERROR": {
|
|
503
507
|
"description": "Sorry, something went wrong. Please try again.",
|
|
504
508
|
"primaryAction": "Try again",
|
package/src/locales/ja.json
CHANGED
|
@@ -459,6 +459,10 @@
|
|
|
459
459
|
"primaryAction": "もう一度試す",
|
|
460
460
|
"secondaryAction": "キャンセル"
|
|
461
461
|
},
|
|
462
|
+
"SALE_AUTHORIZATION_REJECTED": {
|
|
463
|
+
"description": "申し訳ございません。購入を完了できませんでした。",
|
|
464
|
+
"secondaryAction": "閉じる"
|
|
465
|
+
},
|
|
462
466
|
"DEFAULT_ERROR": {
|
|
463
467
|
"description": "申し訳ありませんが、何かがうまくいかなかったようです。もう一度お試しください。",
|
|
464
468
|
"primaryAction": "もう一度試す",
|
package/src/locales/ko.json
CHANGED
|
@@ -456,6 +456,10 @@
|
|
|
456
456
|
"primaryAction": "다시 시도",
|
|
457
457
|
"secondaryAction": "취소"
|
|
458
458
|
},
|
|
459
|
+
"SALE_AUTHORIZATION_REJECTED": {
|
|
460
|
+
"description": "죄송합니다, 구매를 완료할 수 없습니다.",
|
|
461
|
+
"secondaryAction": "닫기"
|
|
462
|
+
},
|
|
459
463
|
"DEFAULT_ERROR": {
|
|
460
464
|
"description": "죄송합니다, 문제가 발생했습니다. 다시 시도하세요.",
|
|
461
465
|
"primaryAction": "다시 시도",
|
package/src/locales/zh.json
CHANGED
|
@@ -456,6 +456,10 @@
|
|
|
456
456
|
"primaryAction": "再试一次",
|
|
457
457
|
"secondaryAction": "取消"
|
|
458
458
|
},
|
|
459
|
+
"SALE_AUTHORIZATION_REJECTED": {
|
|
460
|
+
"description": "抱歉,您的购买无法完成。",
|
|
461
|
+
"secondaryAction": "关闭"
|
|
462
|
+
},
|
|
459
463
|
"DEFAULT_ERROR": {
|
|
460
464
|
"description": "抱歉,出了点问题。请再试一次。",
|
|
461
465
|
"primaryAction": "再试一次",
|
|
@@ -159,6 +159,7 @@ export default function SaleWidget(props: SaleWidgetProps) {
|
|
|
159
159
|
biomeTheme={biomeTheme}
|
|
160
160
|
errorType={viewState.view.data?.errorType}
|
|
161
161
|
transactionHash={viewState.view.data?.transactionHash}
|
|
162
|
+
vendorMessage={viewState.view.data?.vendorError?.message}
|
|
162
163
|
blockExplorerLink={BlockExplorerService.getTransactionLink(
|
|
163
164
|
chainId.current as ChainId,
|
|
164
165
|
viewState.view.data?.transactionHash!,
|
|
@@ -87,7 +87,7 @@ type SaleContextValues = SaleContextProps & {
|
|
|
87
87
|
paymentMethod?: SalePaymentTypes | undefined,
|
|
88
88
|
data?: Record<string, unknown>
|
|
89
89
|
) => void;
|
|
90
|
-
goToErrorView: (type: SaleErrorTypes, data?: Record<string,
|
|
90
|
+
goToErrorView: (type: SaleErrorTypes, data?: Record<string, unknown>) => void;
|
|
91
91
|
goToSuccessView: (data?: Record<string, unknown>) => void;
|
|
92
92
|
fundingRoutes: FundingRoute[];
|
|
93
93
|
disabledPaymentTypes: SalePaymentTypes[];
|
|
@@ -284,14 +284,21 @@ export function SaleContextProvider(props: {
|
|
|
284
284
|
);
|
|
285
285
|
|
|
286
286
|
const goToErrorView = useCallback(
|
|
287
|
-
(
|
|
287
|
+
(
|
|
288
|
+
errorType: SaleErrorTypes,
|
|
289
|
+
data: Record<string, unknown> & { vendorError?: { code: string; message?: string } } = {},
|
|
290
|
+
) => {
|
|
288
291
|
errorRetries.current += 1;
|
|
289
292
|
if (errorRetries.current > MAX_ERROR_RETRIES) {
|
|
290
293
|
errorRetries.current = 0;
|
|
291
294
|
setPaymentMethod(undefined);
|
|
292
295
|
}
|
|
293
296
|
|
|
294
|
-
|
|
297
|
+
const { vendorError, ...errorData } = data;
|
|
298
|
+
trackError('commerce', 'saleError', new Error(errorType), {
|
|
299
|
+
...errorData,
|
|
300
|
+
...(vendorError ? { vendorCode: vendorError.code, vendorMessage: vendorError.message || '' } : {}),
|
|
301
|
+
});
|
|
295
302
|
|
|
296
303
|
viewDispatch({
|
|
297
304
|
payload: {
|
|
@@ -26,7 +26,7 @@ export const defaultOrderQuote: OrderQuote = {
|
|
|
26
26
|
|
|
27
27
|
export type ConfigError = {
|
|
28
28
|
type: SaleErrorTypes;
|
|
29
|
-
data?: Record<string,
|
|
29
|
+
data?: Record<string, unknown>;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export const useQuoteOrder = ({
|
|
@@ -93,6 +93,16 @@ export const useQuoteOrder = ({
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
if (!response.ok) {
|
|
96
|
+
if (response.status === 400) {
|
|
97
|
+
const { code, message } = await response.json();
|
|
98
|
+
setOrderQuoteError({
|
|
99
|
+
type: SaleErrorTypes.SALE_AUTHORIZATION_REJECTED,
|
|
100
|
+
data: {
|
|
101
|
+
vendorError: { code: code || '', message: message || undefined },
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
96
106
|
throw new Error(`${response.status} - ${response.statusText}`);
|
|
97
107
|
}
|
|
98
108
|
|
|
@@ -291,11 +291,17 @@ export const useSignOrder = (input: SignOrderInput) => {
|
|
|
291
291
|
|
|
292
292
|
const { ok, status } = response;
|
|
293
293
|
if (!ok) {
|
|
294
|
-
const { code } = (await response.json()) as SignApiError;
|
|
294
|
+
const { code, message } = (await response.json()) as SignApiError;
|
|
295
295
|
let errorType: SaleErrorTypes;
|
|
296
|
+
let errorData: { code: string; message: string } | undefined;
|
|
297
|
+
|
|
296
298
|
switch (status) {
|
|
297
299
|
case 400:
|
|
298
|
-
errorType = SaleErrorTypes.
|
|
300
|
+
errorType = SaleErrorTypes.SALE_AUTHORIZATION_REJECTED;
|
|
301
|
+
errorData = {
|
|
302
|
+
code,
|
|
303
|
+
message,
|
|
304
|
+
};
|
|
299
305
|
break;
|
|
300
306
|
case 404:
|
|
301
307
|
if (code === 'insufficient_stock') {
|
|
@@ -312,7 +318,7 @@ export const useSignOrder = (input: SignOrderInput) => {
|
|
|
312
318
|
throw new Error('Unknown error');
|
|
313
319
|
}
|
|
314
320
|
|
|
315
|
-
setSignError({ type: errorType });
|
|
321
|
+
setSignError({ type: errorType, data: errorData });
|
|
316
322
|
return undefined;
|
|
317
323
|
}
|
|
318
324
|
|
|
@@ -59,7 +59,9 @@ export type SignOrderInput = {
|
|
|
59
59
|
|
|
60
60
|
export type SignOrderError = {
|
|
61
61
|
type: SaleErrorTypes;
|
|
62
|
-
data?:
|
|
62
|
+
data?:
|
|
63
|
+
| Record<string, string>
|
|
64
|
+
| { vendorError: { code: string; message: string } };
|
|
63
65
|
};
|
|
64
66
|
|
|
65
67
|
export type ExecutedTransaction = {
|
|
@@ -85,6 +87,7 @@ export enum SaleErrorTypes {
|
|
|
85
87
|
WALLET_REJECTED_NO_FUNDS = 'WALLET_REJECTED_NO_FUNDS',
|
|
86
88
|
WALLET_POPUP_BLOCKED = 'WALLET_POPUP_BLOCKED',
|
|
87
89
|
FUNDING_ROUTE_EXECUTE_ERROR = 'FUNDING_ROUTE_EXECUTE_ERROR',
|
|
90
|
+
SALE_AUTHORIZATION_REJECTED = 'SALE_AUTHORIZATION_REJECTED',
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
export type OrderQuoteCurrency = {
|
|
@@ -36,6 +36,7 @@ type SaleErrorViewProps = {
|
|
|
36
36
|
errorType: SaleErrorTypes | undefined;
|
|
37
37
|
transactionHash?: string;
|
|
38
38
|
blockExplorerLink?: string;
|
|
39
|
+
vendorMessage?: string;
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
export function SaleErrorView({
|
|
@@ -43,6 +44,7 @@ export function SaleErrorView({
|
|
|
43
44
|
transactionHash,
|
|
44
45
|
blockExplorerLink,
|
|
45
46
|
errorType,
|
|
47
|
+
vendorMessage,
|
|
46
48
|
}: SaleErrorViewProps) {
|
|
47
49
|
const { t } = useTranslation();
|
|
48
50
|
const {
|
|
@@ -198,6 +200,13 @@ export function SaleErrorView({
|
|
|
198
200
|
onSecondaryActionClick: closeWidget,
|
|
199
201
|
statusType: StatusType.INFORMATION,
|
|
200
202
|
},
|
|
203
|
+
[SaleErrorTypes.SALE_AUTHORIZATION_REJECTED]: {
|
|
204
|
+
onSecondaryActionClick: closeWidget,
|
|
205
|
+
statusType: StatusType.INFORMATION,
|
|
206
|
+
statusIconStyles: {
|
|
207
|
+
fill: biomeTheme.color.status.fatal.dim,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
201
210
|
[SaleErrorTypes.INVALID_PARAMETERS]: {
|
|
202
211
|
onSecondaryActionClick: closeWidget,
|
|
203
212
|
statusType: StatusType.ALERT,
|
|
@@ -222,11 +231,13 @@ export function SaleErrorView({
|
|
|
222
231
|
? t(`views.SALE_FAIL.errors.${currentErrorType}.secondaryAction`)
|
|
223
232
|
: t(`views.SALE_FAIL.errors.${SaleErrorTypes.DEFAULT}.secondaryAction`);
|
|
224
233
|
|
|
234
|
+
const useVendorMessage = currentErrorType === SaleErrorTypes.SALE_AUTHORIZATION_REJECTED
|
|
235
|
+
&& vendorMessage;
|
|
236
|
+
|
|
225
237
|
return {
|
|
226
238
|
headingText: t('views.PAYMENT_METHODS.handover.error.heading'),
|
|
227
|
-
subheadingText:
|
|
228
|
-
`views.SALE_FAIL.errors.${currentErrorType}.description
|
|
229
|
-
),
|
|
239
|
+
subheadingText: useVendorMessage
|
|
240
|
+
|| t(`views.SALE_FAIL.errors.${currentErrorType}.description`),
|
|
230
241
|
primaryButtonText: t(
|
|
231
242
|
`views.SALE_FAIL.errors.${currentErrorType}.primaryAction`,
|
|
232
243
|
),
|