@deuna/react-native-sdk 1.0.0
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/LICENSE +20 -0
- package/README.md +15 -0
- package/lib/module/DeunaLogs.js +18 -0
- package/lib/module/DeunaLogs.js.map +1 -0
- package/lib/module/DeunaSDK.js +207 -0
- package/lib/module/DeunaSDK.js.map +1 -0
- package/lib/module/components/DeunaWebView.js +37 -0
- package/lib/module/components/DeunaWebView.js.map +1 -0
- package/lib/module/components/DeunaWidget.js +82 -0
- package/lib/module/components/DeunaWidget.js.map +1 -0
- package/lib/module/components/NewTabWebView.js +55 -0
- package/lib/module/components/NewTabWebView.js.map +1 -0
- package/lib/module/components/WebViewLoader.js +25 -0
- package/lib/module/components/WebViewLoader.js.map +1 -0
- package/lib/module/controllers/BaseWebViewController.js +252 -0
- package/lib/module/controllers/BaseWebViewController.js.map +1 -0
- package/lib/module/controllers/ElementsWidgetController.js +64 -0
- package/lib/module/controllers/ElementsWidgetController.js.map +1 -0
- package/lib/module/controllers/OpenInNewTabController.js +34 -0
- package/lib/module/controllers/OpenInNewTabController.js.map +1 -0
- package/lib/module/controllers/PaymentWidgetController.js +98 -0
- package/lib/module/controllers/PaymentWidgetController.js.map +1 -0
- package/lib/module/helpers/Completer.js +30 -0
- package/lib/module/helpers/Completer.js.map +1 -0
- package/lib/module/helpers/getController.js +48 -0
- package/lib/module/helpers/getController.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/interfaces/constants.js +8 -0
- package/lib/module/interfaces/constants.js.map +1 -0
- package/lib/module/interfaces/errors.js +36 -0
- package/lib/module/interfaces/errors.js.map +1 -0
- package/lib/module/interfaces/events/checkout.js +45 -0
- package/lib/module/interfaces/events/checkout.js.map +1 -0
- package/lib/module/interfaces/events/elements.js +28 -0
- package/lib/module/interfaces/events/elements.js.map +1 -0
- package/lib/module/interfaces/index.js +6 -0
- package/lib/module/interfaces/index.js.map +1 -0
- package/lib/module/interfaces/types.js +13 -0
- package/lib/module/interfaces/types.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/base.js +24 -0
- package/lib/module/types/base.js.map +1 -0
- package/lib/module/types/env.js +48 -0
- package/lib/module/types/env.js.map +1 -0
- package/lib/module/types/helpers/buildElementsLink.js +75 -0
- package/lib/module/types/helpers/buildElementsLink.js.map +1 -0
- package/lib/module/types/helpers/buildNextActionLink.js +33 -0
- package/lib/module/types/helpers/buildNextActionLink.js.map +1 -0
- package/lib/module/types/helpers/buildPaymentLink.js +54 -0
- package/lib/module/types/helpers/buildPaymentLink.js.map +1 -0
- package/lib/module/types/helpers/buildVoucherLink.js +48 -0
- package/lib/module/types/helpers/buildVoucherLink.js.map +1 -0
- package/lib/module/types/helpers/index.js +13 -0
- package/lib/module/types/helpers/index.js.map +1 -0
- package/lib/module/types/helpers/urlConfig.js +19 -0
- package/lib/module/types/helpers/urlConfig.js.map +1 -0
- package/lib/module/types/index.js +7 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/interfaces/callbacks.js +2 -0
- package/lib/module/types/interfaces/callbacks.js.map +1 -0
- package/lib/module/types/interfaces/customStyle.js +2 -0
- package/lib/module/types/interfaces/customStyle.js.map +1 -0
- package/lib/module/types/interfaces/index.js +9 -0
- package/lib/module/types/interfaces/index.js.map +1 -0
- package/lib/module/types/interfaces/initWidgetBase.js +4 -0
- package/lib/module/types/interfaces/initWidgetBase.js.map +1 -0
- package/lib/module/types/interfaces/merchant.js +2 -0
- package/lib/module/types/interfaces/merchant.js.map +1 -0
- package/lib/module/types/interfaces/order.js +2 -0
- package/lib/module/types/interfaces/order.js.map +1 -0
- package/lib/module/types/interfaces/user.js +2 -0
- package/lib/module/types/interfaces/user.js.map +1 -0
- package/lib/module/types/utils/hasKey.js +8 -0
- package/lib/module/types/utils/hasKey.js.map +1 -0
- package/lib/module/types/utils/index.js +4 -0
- package/lib/module/types/utils/index.js.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/DeunaLogs.d.ts +6 -0
- package/lib/typescript/deuna-sdk-react-native/src/DeunaLogs.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/DeunaSDK.d.ts +88 -0
- package/lib/typescript/deuna-sdk-react-native/src/DeunaSDK.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/DeunaWebView.d.ts +11 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/DeunaWebView.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/DeunaWidget.d.ts +7 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/DeunaWidget.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/NewTabWebView.d.ts +7 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/NewTabWebView.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/WebViewLoader.d.ts +2 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/WebViewLoader.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/BaseWebViewController.d.ts +83 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/BaseWebViewController.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/ElementsWidgetController.d.ts +9 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/ElementsWidgetController.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/OpenInNewTabController.d.ts +12 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/OpenInNewTabController.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/PaymentWidgetController.d.ts +12 -0
- package/lib/typescript/deuna-sdk-react-native/src/controllers/PaymentWidgetController.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/helpers/Completer.d.ts +12 -0
- package/lib/typescript/deuna-sdk-react-native/src/helpers/Completer.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/helpers/getController.d.ts +22 -0
- package/lib/typescript/deuna-sdk-react-native/src/helpers/getController.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/index.d.ts +5 -0
- package/lib/typescript/deuna-sdk-react-native/src/index.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/constants.d.ts +6 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/constants.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/errors.d.ts +32 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/errors.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/events/checkout.d.ts +46 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/events/checkout.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/events/elements.d.ts +29 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/events/elements.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/index.d.ts +4 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/index.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/types.d.ts +15 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/types.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/base.d.ts +91 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/base.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/env.d.ts +45 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/env.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildElementsLink.d.ts +3 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildElementsLink.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildNextActionLink.d.ts +3 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildNextActionLink.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildPaymentLink.d.ts +8 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildPaymentLink.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildVoucherLink.d.ts +8 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildVoucherLink.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/index.d.ts +7 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/index.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/urlConfig.d.ts +34 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/urlConfig.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/index.d.ts +5 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/index.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/callbacks.d.ts +38 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/callbacks.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/customStyle.d.ts +156 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/customStyle.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/index.d.ts +7 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/index.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/initWidgetBase.d.ts +78 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/initWidgetBase.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/merchant.d.ts +76 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/merchant.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/order.d.ts +3 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/order.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/user.d.ts +23 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/user.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/utils/hasKey.d.ts +2 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/utils/hasKey.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/utils/index.d.ts +2 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/utils/index.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/package.json +159 -0
- package/src/DeunaLogs.ts +17 -0
- package/src/DeunaSDK.ts +269 -0
- package/src/components/DeunaWebView.tsx +38 -0
- package/src/components/DeunaWidget.tsx +92 -0
- package/src/components/NewTabWebView.tsx +61 -0
- package/src/components/WebViewLoader.tsx +22 -0
- package/src/controllers/BaseWebViewController.ts +289 -0
- package/src/controllers/ElementsWidgetController.ts +78 -0
- package/src/controllers/OpenInNewTabController.ts +39 -0
- package/src/controllers/PaymentWidgetController.ts +118 -0
- package/src/helpers/Completer.ts +33 -0
- package/src/helpers/getController.ts +83 -0
- package/src/index.tsx +4 -0
- package/src/interfaces/constants.ts +5 -0
- package/src/interfaces/errors.ts +34 -0
- package/src/interfaces/events/checkout.ts +46 -0
- package/src/interfaces/events/elements.ts +29 -0
- package/src/interfaces/index.ts +3 -0
- package/src/interfaces/types.ts +13 -0
- package/src/types/base.ts +126 -0
- package/src/types/env.ts +51 -0
- package/src/types/helpers/buildElementsLink.ts +87 -0
- package/src/types/helpers/buildNextActionLink.ts +42 -0
- package/src/types/helpers/buildPaymentLink.ts +63 -0
- package/src/types/helpers/buildVoucherLink.ts +53 -0
- package/src/types/helpers/index.ts +11 -0
- package/src/types/helpers/urlConfig.ts +80 -0
- package/src/types/index.ts +4 -0
- package/src/types/interfaces/callbacks.ts +43 -0
- package/src/types/interfaces/customStyle.ts +189 -0
- package/src/types/interfaces/index.ts +6 -0
- package/src/types/interfaces/initWidgetBase.ts +97 -0
- package/src/types/interfaces/merchant.ts +79 -0
- package/src/types/interfaces/order.ts +1 -0
- package/src/types/interfaces/user.ts +22 -0
- package/src/types/utils/hasKey.ts +5 -0
- package/src/types/utils/index.ts +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export enum CheckoutEventType {
|
|
2
|
+
custom = 'custom',
|
|
3
|
+
purchase = 'purchase',
|
|
4
|
+
purchaseError = 'purchaseError',
|
|
5
|
+
linkClose = 'linkClose',
|
|
6
|
+
linkFailed = 'linkFailed',
|
|
7
|
+
purchaseRejected = 'purchaseRejected',
|
|
8
|
+
paymentProcessing = 'paymentProcessing',
|
|
9
|
+
paymentMethodsAddCard = 'paymentMethodsAddCard',
|
|
10
|
+
paymentMethodsCardExpirationDateInitiated = 'paymentMethodsCardExpirationDateInitiated',
|
|
11
|
+
paymentMethodsCardNameEntered = 'paymentMethodsCardNameEntered',
|
|
12
|
+
apmSuccess = 'apmSuccess',
|
|
13
|
+
apmSuccessful = 'apmSuccessful',
|
|
14
|
+
changeAddress = 'changeAddress',
|
|
15
|
+
changeCart = 'changeCart',
|
|
16
|
+
paymentClick = 'paymentClick',
|
|
17
|
+
apmClickRedirect = 'apmClickRedirect',
|
|
18
|
+
paymentMethodsCardNumberInitiated = 'paymentMethodsCardNumberInitiated',
|
|
19
|
+
paymentMethodsCardNumberEntered = 'paymentMethodsCardNumberEntered',
|
|
20
|
+
paymentMethodsEntered = 'paymentMethodsEntered',
|
|
21
|
+
checkoutStarted = 'checkoutStarted',
|
|
22
|
+
linkStarted = 'linkStarted',
|
|
23
|
+
paymentMethodsStarted = 'paymentMethodsStarted',
|
|
24
|
+
paymentMethodsSelected = 'paymentMethodsSelected',
|
|
25
|
+
adBlock = 'adBlock',
|
|
26
|
+
paymentMethods3dsInitiated = 'paymentMethods3dsInitiated',
|
|
27
|
+
pointsToWinStarted = 'pointsToWinStarted',
|
|
28
|
+
paymentMethodsCardSecurityCodeInitiated = 'paymentMethodsCardSecurityCodeInitiated',
|
|
29
|
+
paymentMethodsCardSecurityCodeEntered = 'paymentMethodsCardSecurityCodeEntered',
|
|
30
|
+
paymentMethodsCardExpirationDateEntered = 'paymentMethodsCardExpirationDateEntered',
|
|
31
|
+
paymentMethodsCardNameInitiated = 'paymentMethodsCardNameInitiated',
|
|
32
|
+
paymentMethodsNotAvailable = 'paymentMethodsNotAvailable',
|
|
33
|
+
paymentMethodsShowMore = 'paymentMethodsShowMore',
|
|
34
|
+
paymentMethodsShowMyCards = 'paymentMethodsShowMyCards',
|
|
35
|
+
benefitsStarted = 'benefitsStarted',
|
|
36
|
+
donationsStarted = 'donationsStarted',
|
|
37
|
+
donationsUsed = 'donationsUsed',
|
|
38
|
+
onBinDetected = 'onBinDetected',
|
|
39
|
+
onInstallmentSelected = 'onInstallmentSelected',
|
|
40
|
+
onDownloadVoucher = 'onDownloadVoucher',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface CheckoutEvent {
|
|
44
|
+
type: CheckoutEventType;
|
|
45
|
+
data: Record<string, any>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export enum ElementsEventType {
|
|
2
|
+
vaultClosed = 'vaultClosed',
|
|
3
|
+
vaultProcessing = 'vaultProcessing',
|
|
4
|
+
vaultSaveClick = 'vaultSaveClick',
|
|
5
|
+
vaultStarted = 'vaultStarted',
|
|
6
|
+
vaultFailed = 'vaultFailed',
|
|
7
|
+
cardSuccessfullyCreated = 'cardSuccessfullyCreated',
|
|
8
|
+
changeAddress = 'changeAddress',
|
|
9
|
+
changeCart = 'changeCart',
|
|
10
|
+
vaultSaveError = 'vaultSaveError',
|
|
11
|
+
vaultSaveSuccess = 'vaultSaveSuccess',
|
|
12
|
+
vaultClickRedirect3DS = 'vaultClickRedirect3DS',
|
|
13
|
+
cardCreationError = 'cardCreationError',
|
|
14
|
+
paymentMethodsCardIdentityNumberInitiated = 'paymentMethodsCardIdentityNumberInitiated',
|
|
15
|
+
paymentMethodsCardIdentityNumberEntered = 'paymentMethodsCardIdentityNumberEntered',
|
|
16
|
+
paymentMethodsCardNameInitiated = 'paymentMethodsCardNameInitiated',
|
|
17
|
+
paymentMethodsCardNameEntered = 'paymentMethodsCardNameEntered',
|
|
18
|
+
paymentMethodsCardSecurityCodeInitiated = 'paymentMethodsCardSecurityCodeInitiated',
|
|
19
|
+
paymentMethodsCardSecurityCodeEntered = 'paymentMethodsCardSecurityCodeEntered',
|
|
20
|
+
paymentMethodsCardExpirationDateEntered = 'paymentMethodsCardExpirationDateEntered',
|
|
21
|
+
paymentMethodsCardExpirationDateInitiated = 'paymentMethodsCardExpirationDateInitiated',
|
|
22
|
+
paymentMethodsCardNumberEntered = 'paymentMethodsCardNumberEntered',
|
|
23
|
+
paymentMethodsCardNumberInitiated = 'paymentMethodsCardNumberInitiated',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ElementsEvent {
|
|
27
|
+
type: ElementsEventType;
|
|
28
|
+
data: Record<string, any>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ElementsWidgetCallbacks,
|
|
3
|
+
NextActionWidgetCallbacks,
|
|
4
|
+
PaymentWidgetCallbacks,
|
|
5
|
+
VoucherWidgetCallbacks,
|
|
6
|
+
} from './interfaces/callbacks';
|
|
7
|
+
import { CustomStyles } from './interfaces/customStyle';
|
|
8
|
+
import { ElementWidgetType } from './helpers/urlConfig';
|
|
9
|
+
import {
|
|
10
|
+
InitWidgetBase,
|
|
11
|
+
PaymentMethodConfigurationFlow,
|
|
12
|
+
} from './interfaces/initWidgetBase';
|
|
13
|
+
import {
|
|
14
|
+
Merchant,
|
|
15
|
+
PaymentMethodTypes,
|
|
16
|
+
PaymentProcessorName,
|
|
17
|
+
} from './interfaces/merchant';
|
|
18
|
+
import { Order } from './interfaces/order';
|
|
19
|
+
import { User } from './interfaces/user';
|
|
20
|
+
|
|
21
|
+
export type Environment = 'production' | 'sandbox' | 'develop' | 'staging';
|
|
22
|
+
|
|
23
|
+
export interface InitializeParams {
|
|
24
|
+
environment?: Environment;
|
|
25
|
+
publicApiKey: string;
|
|
26
|
+
}
|
|
27
|
+
export type SubmitStatus = 'success' | 'error';
|
|
28
|
+
|
|
29
|
+
export type SubmitResult = {
|
|
30
|
+
status: SubmitStatus;
|
|
31
|
+
message?: string;
|
|
32
|
+
code?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export interface State {
|
|
36
|
+
order: Order;
|
|
37
|
+
merchant: Merchant;
|
|
38
|
+
user: User;
|
|
39
|
+
paymentMethods: {
|
|
40
|
+
selectedPaymentMethod: {
|
|
41
|
+
method_type: PaymentMethodTypes;
|
|
42
|
+
processor_name?: PaymentProcessorName;
|
|
43
|
+
configuration?: {
|
|
44
|
+
express?: boolean;
|
|
45
|
+
flowType?: PaymentMethodConfigurationFlow;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type Submit = () => Promise<SubmitResult>;
|
|
52
|
+
export type SetCustomStyle = (customStyles: CustomStyles) => void;
|
|
53
|
+
export type GetStateFn = () => Promise<State>;
|
|
54
|
+
export type IsValid = () => Promise<boolean>;
|
|
55
|
+
export type RefetchOrder = () => Promise<Order | null>;
|
|
56
|
+
|
|
57
|
+
export type InitPaymentWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
58
|
+
orderToken: string;
|
|
59
|
+
callbacks: PaymentWidgetCallbacks;
|
|
60
|
+
paymentMethods?: {
|
|
61
|
+
paymentMethod: string;
|
|
62
|
+
processors: string[];
|
|
63
|
+
configuration?: {
|
|
64
|
+
express?: boolean;
|
|
65
|
+
flowType?: PaymentMethodConfigurationFlow;
|
|
66
|
+
};
|
|
67
|
+
}[];
|
|
68
|
+
sessionId?: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type InitElementsWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
72
|
+
callbacks: ElementsWidgetCallbacks;
|
|
73
|
+
types?: ElementWidgetType[];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type InitNextActionWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
77
|
+
orderToken: string;
|
|
78
|
+
callbacks: NextActionWidgetCallbacks;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type InitVoucherWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
82
|
+
orderToken: string;
|
|
83
|
+
callbacks: VoucherWidgetCallbacks;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export abstract class BaseDeuna {
|
|
87
|
+
abstract setCustomStyleFn?: SetCustomStyle;
|
|
88
|
+
abstract refetchOrderFn?: RefetchOrder;
|
|
89
|
+
abstract getStateFn?: GetStateFn;
|
|
90
|
+
abstract onSubmitFn?: Submit;
|
|
91
|
+
abstract isValidFn?: IsValid;
|
|
92
|
+
abstract closeFn?: () => void;
|
|
93
|
+
|
|
94
|
+
abstract getSessionId(): Promise<string>;
|
|
95
|
+
abstract submit(): Promise<SubmitResult>;
|
|
96
|
+
abstract close(): Promise<void>;
|
|
97
|
+
|
|
98
|
+
async setCustomStyles(customStyles: CustomStyles): Promise<void> {
|
|
99
|
+
await this.setCustomStyleFn?.(customStyles);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async refetchOrder(): Promise<Order | null> {
|
|
103
|
+
return this.refetchOrderFn?.() || null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async getWidgetState() {
|
|
107
|
+
return this.getStateFn?.();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async isValid(): Promise<boolean> {
|
|
111
|
+
return this.isValidFn?.() || false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async getSelectedPaymentMethod() {
|
|
115
|
+
const state = await this.getStateFn?.();
|
|
116
|
+
if (!state?.paymentMethods.selectedPaymentMethod) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return state.paymentMethods.selectedPaymentMethod;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
abstract initPaymentWidget(params: InitPaymentWidgetParams): Promise<void>;
|
|
123
|
+
abstract initElements(params: InitElementsWidgetParams): Promise<void>;
|
|
124
|
+
abstract initNextAction(params: InitNextActionWidgetParams): Promise<void>;
|
|
125
|
+
abstract initVoucherWidget(params: InitVoucherWidgetParams): Promise<void>;
|
|
126
|
+
}
|
package/src/types/env.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export enum Env {
|
|
2
|
+
Production = 'production',
|
|
3
|
+
Staging = 'staging',
|
|
4
|
+
Develop = 'develop',
|
|
5
|
+
Sandbox = 'sandbox',
|
|
6
|
+
local = 'local'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const env = {
|
|
10
|
+
[Env.Production]: 'https://apigw.getduna.com/',
|
|
11
|
+
[Env.Staging]: 'https://api.stg.deuna.io/',
|
|
12
|
+
[Env.Develop]: 'https://api.dev.deuna.io/',
|
|
13
|
+
[Env.Sandbox]: 'https://api.sandbox.deuna.io/'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const checkout = {
|
|
17
|
+
[Env.Production]: 'https://checkout-ux.deuna.com/',
|
|
18
|
+
[Env.Staging]: 'https://checkout.stg.deuna.io/',
|
|
19
|
+
[Env.Develop]: 'https://checkout.dev.deuna.io/',
|
|
20
|
+
[Env.Sandbox]: 'https://checkout.sandbox.deuna.io/'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const fingerprintjsEnv = {
|
|
24
|
+
[Env.Production]: 'PczoxhUz1RUyPv5Ih7nM',
|
|
25
|
+
[Env.Staging]: 'sB9jPdnpvLP3FkjjUPi3',
|
|
26
|
+
[Env.Develop]: 'sB9jPdnpvLP3FkjjUPi3',
|
|
27
|
+
[Env.Sandbox]: 'sB9jPdnpvLP3FkjjUPi3'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const storageSite = {
|
|
31
|
+
[Env.Production]: 'https://cdn.getduna.com/cdl/storageSite/index.html',
|
|
32
|
+
[Env.Staging]: 'https://cdn.stg.deuna.io/cdl/storageSite/index.html',
|
|
33
|
+
[Env.Develop]: 'https://cdn.dev.deuna.io/cdl/storageSite/index.html',
|
|
34
|
+
[Env.Sandbox]: 'https://cdn.stg.deuna.io/cdl/storageSite/index.html',
|
|
35
|
+
[Env.local]: 'http://localhost:3005/'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const siftCred = {
|
|
39
|
+
[Env.Production]: 'ab8ca5421b',
|
|
40
|
+
[Env.Staging]: 'b267dfc8a5',
|
|
41
|
+
[Env.Develop]: 'b267dfc8a5',
|
|
42
|
+
[Env.Sandbox]: 'b267dfc8a5'
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const proxyUrls = {
|
|
46
|
+
URL: 'mimos.vendodeuna.com',
|
|
47
|
+
FPJS_BEHAVIOR_PATH: 'thomas',
|
|
48
|
+
FPJS_AGENT_DOWNLOAD_PATH: 'tommy',
|
|
49
|
+
FPJS_GET_RESULT_PATH: 'pabloinvita'
|
|
50
|
+
};
|
|
51
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Environment } from "../base";
|
|
2
|
+
import { hasKey } from "../utils/hasKey";
|
|
3
|
+
import { getIntegrationType, UrlConfig } from "./urlConfig";
|
|
4
|
+
|
|
5
|
+
const urls: Record<Environment, string> = {
|
|
6
|
+
production: "https://elements.deuna.io",
|
|
7
|
+
sandbox: "https://elements.sandbox.deuna.io",
|
|
8
|
+
staging: "https://elements.stg.deuna.io",
|
|
9
|
+
develop: "https://elements.dev.deuna.io",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const pathsMapper = {
|
|
13
|
+
click_to_pay: "/click_to_pay",
|
|
14
|
+
vault: "/vault",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const buildElementsLink = (config: UrlConfig): string => {
|
|
18
|
+
const { env, orderToken, userInfo, userToken, widgetExperience, types } =
|
|
19
|
+
config;
|
|
20
|
+
|
|
21
|
+
let baseUrl = urls.production;
|
|
22
|
+
|
|
23
|
+
if (env) {
|
|
24
|
+
baseUrl = urls[env];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (config.domain) {
|
|
28
|
+
baseUrl = config.domain;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const url = new URL(baseUrl);
|
|
32
|
+
|
|
33
|
+
const publicApiKey = config.publicApiKey;
|
|
34
|
+
const firstName = userInfo?.firstName || "";
|
|
35
|
+
const lastName = userInfo?.lastName || "";
|
|
36
|
+
const email = userInfo?.email || "";
|
|
37
|
+
|
|
38
|
+
const searchParams = new URLSearchParams({
|
|
39
|
+
publicApiKey,
|
|
40
|
+
orderToken,
|
|
41
|
+
email,
|
|
42
|
+
firstName,
|
|
43
|
+
lastName,
|
|
44
|
+
...(config.styleFile ? { cssFile: config.styleFile } : {}),
|
|
45
|
+
int: getIntegrationType(config.mode),
|
|
46
|
+
...(userToken ? { userToken } : {}),
|
|
47
|
+
...(widgetExperience?.userExperience?.showSavedCardsFlow
|
|
48
|
+
? {
|
|
49
|
+
showSavedCardsFlow: String(
|
|
50
|
+
widgetExperience?.userExperience?.showSavedCardsFlow
|
|
51
|
+
),
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
54
|
+
...(widgetExperience?.userExperience?.defaultCardFlow
|
|
55
|
+
? {
|
|
56
|
+
showDefaultCardFlow: String(
|
|
57
|
+
widgetExperience?.userExperience?.defaultCardFlow
|
|
58
|
+
),
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
61
|
+
language: config.language,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const xpropsB64 = {
|
|
65
|
+
id: config.id,
|
|
66
|
+
behavior: config.behavior || {},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getWidgetPath = () => {
|
|
70
|
+
if (types && types.length > 0) {
|
|
71
|
+
const firstPath = types[0]!.name;
|
|
72
|
+
|
|
73
|
+
if (hasKey(pathsMapper, firstPath)) {
|
|
74
|
+
return pathsMapper[firstPath];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return pathsMapper.vault;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
searchParams.append("xpropsB64", btoa(JSON.stringify(xpropsB64)));
|
|
82
|
+
|
|
83
|
+
url.pathname = getWidgetPath();
|
|
84
|
+
url.search = searchParams.toString();
|
|
85
|
+
|
|
86
|
+
return url.toString();
|
|
87
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Environment } from "../base";
|
|
2
|
+
import {
|
|
3
|
+
configToQueryParams,
|
|
4
|
+
getIntegrationType,
|
|
5
|
+
UrlConfig,
|
|
6
|
+
} from "./urlConfig";
|
|
7
|
+
|
|
8
|
+
const urls: Record<Environment, string> = {
|
|
9
|
+
production: "https://pay.deuna.io",
|
|
10
|
+
sandbox: "https://pay.sandbox.deuna.io",
|
|
11
|
+
staging: "https://pay.stg.deuna.com",
|
|
12
|
+
develop: "https://pay.dev.deuna.io",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const buildNextActionLink = (config: UrlConfig): string => {
|
|
16
|
+
const { env, orderToken } = config;
|
|
17
|
+
|
|
18
|
+
let baseUrl = urls.production;
|
|
19
|
+
|
|
20
|
+
if (env) {
|
|
21
|
+
baseUrl = urls[env];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const searchParams = new URLSearchParams({
|
|
25
|
+
mode: "widget",
|
|
26
|
+
int: getIntegrationType(config.mode),
|
|
27
|
+
language: config.language,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
configToQueryParams(config, searchParams);
|
|
31
|
+
|
|
32
|
+
if (config.domain) {
|
|
33
|
+
baseUrl = config.domain;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const url = new URL(baseUrl);
|
|
37
|
+
|
|
38
|
+
url.pathname = `/next-action-purchase/${orderToken}`;
|
|
39
|
+
url.search = searchParams.toString();
|
|
40
|
+
|
|
41
|
+
return url.toString();
|
|
42
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to get base URL based on environment
|
|
3
|
+
* @param config
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Environment } from "../base";
|
|
8
|
+
import {
|
|
9
|
+
configToQueryParams,
|
|
10
|
+
getIntegrationType,
|
|
11
|
+
UrlConfig,
|
|
12
|
+
} from "./urlConfig";
|
|
13
|
+
|
|
14
|
+
const urls: Record<Environment, string> = {
|
|
15
|
+
production: "https://pay.deuna.io",
|
|
16
|
+
sandbox: "https://pay.sandbox.deuna.io",
|
|
17
|
+
staging: "https://pay.stg.deuna.com",
|
|
18
|
+
develop: "https://pay.dev.deuna.io",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const buildPaymentLink = (config: UrlConfig): string => {
|
|
22
|
+
const { env, orderToken } = config;
|
|
23
|
+
|
|
24
|
+
let baseUrl = urls.production;
|
|
25
|
+
|
|
26
|
+
if (env) {
|
|
27
|
+
baseUrl = urls[env];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const searchParams = new URLSearchParams({
|
|
31
|
+
mode: "widget",
|
|
32
|
+
int: getIntegrationType(config.mode),
|
|
33
|
+
language: config.language,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// config.
|
|
37
|
+
|
|
38
|
+
const xpropsB64 = {
|
|
39
|
+
id: config.id,
|
|
40
|
+
paymentMethods: config.paymentMethods,
|
|
41
|
+
publicApiKey: config.publicApiKey,
|
|
42
|
+
behavior: config.behavior,
|
|
43
|
+
cdl: {
|
|
44
|
+
sessionId: config.sessionId,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
configToQueryParams(config, searchParams);
|
|
49
|
+
|
|
50
|
+
if (config.domain) {
|
|
51
|
+
baseUrl = config.domain;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//encode to base64
|
|
55
|
+
searchParams.append("xpropsB64", btoa(JSON.stringify(xpropsB64)));
|
|
56
|
+
|
|
57
|
+
const url = new URL(baseUrl);
|
|
58
|
+
|
|
59
|
+
url.pathname = `/now/${orderToken}`;
|
|
60
|
+
url.search = searchParams.toString();
|
|
61
|
+
|
|
62
|
+
return url.toString();
|
|
63
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to get base URL based on environment
|
|
3
|
+
* @param config
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Environment } from "../base";
|
|
8
|
+
import { getIntegrationType, UrlConfig } from "./urlConfig";
|
|
9
|
+
|
|
10
|
+
const urls: Record<Environment, string> = {
|
|
11
|
+
production: "https://pay.deuna.io",
|
|
12
|
+
sandbox: "https://pay.sandbox.deuna.io",
|
|
13
|
+
staging: "https://pay.stg.deuna.com",
|
|
14
|
+
develop: "https://pay.dev.deuna.io",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const buildVoucherLink = (config: UrlConfig): string => {
|
|
18
|
+
const { env, orderToken } = config;
|
|
19
|
+
|
|
20
|
+
let baseUrl = urls.production;
|
|
21
|
+
|
|
22
|
+
if (env) {
|
|
23
|
+
baseUrl = urls[env];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const searchParams = new URLSearchParams({
|
|
27
|
+
mode: "widget",
|
|
28
|
+
int: getIntegrationType(config.mode),
|
|
29
|
+
language: config.language,
|
|
30
|
+
orderToken,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const xpropsB64 = {
|
|
34
|
+
id: config.id,
|
|
35
|
+
cdl: {
|
|
36
|
+
sessionId: config.sessionId,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (config.domain) {
|
|
41
|
+
baseUrl = config.domain;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//encode to base64
|
|
45
|
+
searchParams.append("xpropsB64", btoa(JSON.stringify(xpropsB64)));
|
|
46
|
+
|
|
47
|
+
const url = new URL(baseUrl);
|
|
48
|
+
|
|
49
|
+
url.pathname = `/voucher`;
|
|
50
|
+
url.search = searchParams.toString();
|
|
51
|
+
|
|
52
|
+
return url.toString();
|
|
53
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { buildElementsLink } from "./buildElementsLink";
|
|
2
|
+
import { buildNextActionLink } from "./buildNextActionLink";
|
|
3
|
+
import { buildPaymentLink } from "./buildPaymentLink";
|
|
4
|
+
import { buildVoucherLink } from "./buildVoucherLink";
|
|
5
|
+
|
|
6
|
+
export const linkBuilders = {
|
|
7
|
+
elements: buildElementsLink,
|
|
8
|
+
payment: buildPaymentLink,
|
|
9
|
+
nextAction: buildNextActionLink,
|
|
10
|
+
voucher: buildVoucherLink,
|
|
11
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Environment } from "../base";
|
|
2
|
+
import { BehaviorWidget, InitWidgetBase } from "../interfaces/initWidgetBase";
|
|
3
|
+
|
|
4
|
+
type ParamsKey = keyof UrlConfig;
|
|
5
|
+
|
|
6
|
+
export const configToQueryParams = (
|
|
7
|
+
config: UrlConfig,
|
|
8
|
+
searchParams: URLSearchParams
|
|
9
|
+
) => {
|
|
10
|
+
const params: ParamsKey[] = ["styleFile", "userToken", "language"];
|
|
11
|
+
|
|
12
|
+
params.forEach((param) => {
|
|
13
|
+
if (param in config && config[param]) {
|
|
14
|
+
searchParams.append(param, config[param] as string);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const getIntegrationType = (mode?: string) => {
|
|
20
|
+
const modeMap: { [key: string]: string } = {
|
|
21
|
+
widget: "modal",
|
|
22
|
+
modal: "modal",
|
|
23
|
+
target: "embedded",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return modeMap[mode || ""] || "redirect";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
interface PaymentMethods {
|
|
30
|
+
paymentMethod: string;
|
|
31
|
+
processors: string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface UrlConfig {
|
|
35
|
+
// Instance identificator (zoid tag)
|
|
36
|
+
id?: string;
|
|
37
|
+
|
|
38
|
+
// Environment where the widget will run (optional)
|
|
39
|
+
env?: Environment;
|
|
40
|
+
|
|
41
|
+
// Order token to identify the transaction (mandatory)
|
|
42
|
+
orderToken: string;
|
|
43
|
+
|
|
44
|
+
// Only when this field is true when setCustomCss is called the upperTag will be showed
|
|
45
|
+
showPromotionsBanner?: boolean;
|
|
46
|
+
|
|
47
|
+
paymentMethods?: PaymentMethods[];
|
|
48
|
+
|
|
49
|
+
publicApiKey: string;
|
|
50
|
+
|
|
51
|
+
styleFile?: string;
|
|
52
|
+
|
|
53
|
+
userToken: string;
|
|
54
|
+
|
|
55
|
+
language: string;
|
|
56
|
+
|
|
57
|
+
devUrl?: string;
|
|
58
|
+
|
|
59
|
+
domain?: string;
|
|
60
|
+
|
|
61
|
+
mode?: string;
|
|
62
|
+
|
|
63
|
+
target?: string;
|
|
64
|
+
|
|
65
|
+
userInfo?: InitWidgetBase["userInfo"];
|
|
66
|
+
|
|
67
|
+
widgetExperience?: InitWidgetBase["widgetExperience"];
|
|
68
|
+
|
|
69
|
+
behavior?: BehaviorWidget;
|
|
70
|
+
|
|
71
|
+
sessionId: string;
|
|
72
|
+
|
|
73
|
+
types?: ElementWidgetType[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ElementWidgetType {
|
|
77
|
+
name: ElementWidgetTypeName;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type ElementWidgetTypeName = "vault" | "click_to_pay";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type ClosedAction = "userAction" | "systemAction";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
+
export type Json = Record<string, any>;
|
|
4
|
+
|
|
5
|
+
export interface OnError {
|
|
6
|
+
type: string;
|
|
7
|
+
metadata: {
|
|
8
|
+
code: string;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface OnCardBinDetected {
|
|
14
|
+
cardBin: string;
|
|
15
|
+
cardBrand: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface OnInstallmentSelectedPayload {
|
|
19
|
+
cardBin: string;
|
|
20
|
+
installmentPlanOptionId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface BaseCallbacks {
|
|
24
|
+
onSuccess?: (data: Json) => void;
|
|
25
|
+
onError?: (data: OnError) => void;
|
|
26
|
+
onClosed?: (action: ClosedAction) => void;
|
|
27
|
+
onEventDispatch?: (event: string, payload: Json) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface PaymentWidgetCallbacks extends BaseCallbacks {
|
|
31
|
+
onCardBinDetected?: (data: OnCardBinDetected) => void;
|
|
32
|
+
onInstallmentSelected?: (data: OnInstallmentSelectedPayload) => void;
|
|
33
|
+
onPaymentProcessing?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ElementsWidgetCallbacks extends BaseCallbacks {
|
|
37
|
+
onCardBinDetected?: (data: OnCardBinDetected) => void;
|
|
38
|
+
onInstallmentSelected?: (data: OnInstallmentSelectedPayload) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface NextActionWidgetCallbacks extends BaseCallbacks {}
|
|
42
|
+
|
|
43
|
+
export interface VoucherWidgetCallbacks extends BaseCallbacks {}
|