@infosoftas/s4-orders-js-sdk 0.1.21 → 0.2.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/.editorconfig +0 -0
- package/.release-it.json +0 -0
- package/README.md +572 -471
- package/build/postcss-scope-tailwind.cjs +0 -0
- package/components.json +0 -0
- package/package.json +62 -58
- package/src/App.completion.test.tsx +677 -0
- package/src/App.css +0 -14
- package/src/App.paymentReturn.test.tsx +341 -0
- package/src/App.tsx +722 -639
- package/src/ErrorBoundary.tsx +0 -0
- package/src/api/InvoiceApi.ts +0 -0
- package/src/api/OrdersApi.ts +74 -59
- package/src/api/SubscribeApi.ts +0 -0
- package/src/bundle.ts +0 -0
- package/src/components/Alert/Alert.tsx +0 -0
- package/src/components/Button/Button.tsx +0 -0
- package/src/components/EHFForm/EHFForm.tsx +250 -253
- package/src/components/FormFields/AddressField.tsx +0 -0
- package/src/components/FormFields/EmailField.tsx +0 -0
- package/src/components/FormFields/FormFields.helper.ts +0 -0
- package/src/components/FormFields/FormFieldsMapper.ts +0 -0
- package/src/components/FormFields/InputField.tsx +0 -0
- package/src/components/FormFields/NameField.tsx +0 -0
- package/src/components/FormFields/PhoneField.tsx +0 -0
- package/src/components/FormFields/TermsCheckbox.tsx +0 -0
- package/src/components/FormFields/ToggleFiled.tsx +0 -0
- package/src/components/FormFields/fieldValidators.ts +0 -0
- package/src/components/OIOForm/OIOForm.tsx +304 -307
- package/src/components/OrderDenialModal/OrderDenialModal.tsx +0 -0
- package/src/components/OrderForm/ContactDetailsSection.tsx +0 -0
- package/src/components/OrderForm/OrderForm.tsx +417 -420
- package/src/components/OrderForm/PaymentMethodContent.tsx +0 -0
- package/src/components/OrderForm/PaymentMethodSection.tsx +0 -0
- package/src/components/OrderForm/SubmitConfirmationDialog.tsx +0 -0
- package/src/components/OrderForm/orderFormState.ts +0 -0
- package/src/components/OrderForm/useSlotElement.tsx +0 -0
- package/src/components/ui/alert-dialog.tsx +0 -0
- package/src/components/ui/alert.tsx +0 -0
- package/src/components/ui/button.tsx +0 -0
- package/src/components/ui/card.tsx +0 -0
- package/src/components/ui/checkbox.tsx +0 -0
- package/src/components/ui/field.tsx +0 -0
- package/src/components/ui/input.tsx +0 -0
- package/src/components/ui/label.tsx +0 -0
- package/src/components/ui/radio-group.tsx +0 -0
- package/src/components/ui/separator.tsx +0 -0
- package/src/components/ui/skeleton.tsx +0 -0
- package/src/components/ui/spinner.tsx +0 -0
- package/src/components/ui/switch.tsx +0 -0
- package/src/components/ui/textarea.tsx +0 -0
- package/src/constants/index.ts +0 -0
- package/src/custom.d.ts +0 -0
- package/src/enums/api.ts +0 -0
- package/src/enums/general.ts +42 -40
- package/src/hooks/useOrderForm.tsx +400 -403
- package/src/hooks/usePaymentReturn.tsx +139 -0
- package/src/hooks/useQueryParams.ts +0 -0
- package/src/index.tsx +0 -0
- package/src/lib/utils.ts +0 -0
- package/src/types/api.ts +0 -0
- package/src/types/general.ts +153 -136
- package/src/types/order.ts +91 -70
- package/src/utils/fetcher.ts +131 -113
- package/src/utils/helper.ts +0 -0
- package/src/utils/order.helper.test.ts +81 -0
- package/src/utils/order.helper.ts +285 -272
- package/src/utils/waitForOrderCompletion.ts +125 -0
- package/tsconfig.json +39 -38
- package/src/components/MainIframe/MainIframe.tsx +0 -42
- package/src/hooks/useIframe.tsx +0 -59
- package/src/hooks/useMessageEvent.tsx +0 -194
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { PaymentMethodEnum, PaymentReturnActionEnum } from '../enums/general';
|
|
4
|
+
import type { CompleteOrderParamsType, OrderInfoType } from '../types/order';
|
|
5
|
+
import useQueryParams from './useQueryParams';
|
|
6
|
+
|
|
7
|
+
const MOLLIE_ORDER_TTL_MS = 20 * 60 * 1000;
|
|
8
|
+
|
|
9
|
+
// Reads and consumes the persisted Mollie order id. The key is always removed:
|
|
10
|
+
// the return leg gets one chance to use it, whether or not it is still valid.
|
|
11
|
+
const takeStoredMollieOrderId = (): string | null => {
|
|
12
|
+
const raw = sessionStorage.getItem('mollieOrderId');
|
|
13
|
+
if (!raw) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
sessionStorage.removeItem('mollieOrderId');
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const { id, ts } = JSON.parse(raw) as { id: string; ts: number };
|
|
21
|
+
|
|
22
|
+
return Date.now() - ts <= MOLLIE_ORDER_TTL_MS ? id : null;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Temporary, remove in the next release: checkouts started on the previous
|
|
29
|
+
// version open SwedbankPay in an iframe, so the provider returns inside that
|
|
30
|
+
// frame. A framed SDK renders nothing and no longer notifies the parent, so
|
|
31
|
+
// hand the return to the top-level page, which then handles it once.
|
|
32
|
+
const breakOutOfLegacyPaymentFrame = (): boolean => {
|
|
33
|
+
if (!window.top || window.top === window) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
if (window.top.location.origin !== window.location.origin) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
window.top.location.replace(window.location.href);
|
|
41
|
+
return true;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const usePaymentReturn = (
|
|
48
|
+
onPaymentComplete: (data: CompleteOrderParamsType) => Promise<void>,
|
|
49
|
+
onPaymentCancel: (orderId?: string) => void,
|
|
50
|
+
orderInfo: OrderInfoType | null
|
|
51
|
+
) => {
|
|
52
|
+
const queryParams = useQueryParams();
|
|
53
|
+
const isBreakingOut = useRef(false);
|
|
54
|
+
const hasPaymentReturn =
|
|
55
|
+
queryParams.get('action') === PaymentReturnActionEnum.COMPLETE ||
|
|
56
|
+
queryParams.get('action') === PaymentReturnActionEnum.CANCEL ||
|
|
57
|
+
(!!queryParams.get('orderId') && !!queryParams.get('agreementId'));
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (hasPaymentReturn) {
|
|
61
|
+
isBreakingOut.current = breakOutOfLegacyPaymentFrame();
|
|
62
|
+
}
|
|
63
|
+
}, [hasPaymentReturn]);
|
|
64
|
+
|
|
65
|
+
// Vipps / MobilePay
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (isBreakingOut.current) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (queryParams.get('orderId') && queryParams.get('agreementId')) {
|
|
71
|
+
onPaymentComplete({
|
|
72
|
+
orderId: queryParams.get('orderId') || '',
|
|
73
|
+
agreementId: queryParams.get('agreementId') || '',
|
|
74
|
+
orderInfo: orderInfo || null,
|
|
75
|
+
paymentMethod: PaymentMethodEnum.Vipps,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, [queryParams.get('orderId'), queryParams.get('agreementId')]);
|
|
79
|
+
|
|
80
|
+
// SwedbankPay completion, and cancellation for every redirect provider
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (isBreakingOut.current) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (
|
|
86
|
+
queryParams.get('S4OrderId') &&
|
|
87
|
+
queryParams.get('TransactionId') &&
|
|
88
|
+
queryParams.get('action') === PaymentReturnActionEnum.COMPLETE
|
|
89
|
+
) {
|
|
90
|
+
onPaymentComplete({
|
|
91
|
+
orderId: queryParams.get('S4OrderId') || '',
|
|
92
|
+
agreementId: queryParams.get('TransactionId') || '',
|
|
93
|
+
orderInfo: orderInfo || null,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (queryParams.get('action') === PaymentReturnActionEnum.CANCEL) {
|
|
98
|
+
const cancelOrderId =
|
|
99
|
+
queryParams.get('S4OrderId') || takeStoredMollieOrderId();
|
|
100
|
+
onPaymentCancel(cancelOrderId || undefined);
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
queryParams.get('action'),
|
|
104
|
+
queryParams.get('S4OrderId'),
|
|
105
|
+
queryParams.get('TransactionId'),
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
// Mollie: a completion return with no TransactionId (that one is SwedbankPay's).
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (isBreakingOut.current) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (
|
|
114
|
+
queryParams.get('action') !== PaymentReturnActionEnum.COMPLETE ||
|
|
115
|
+
queryParams.get('TransactionId')
|
|
116
|
+
) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const s4OrderId = queryParams.get('S4OrderId');
|
|
121
|
+
const storedOrderId = takeStoredMollieOrderId();
|
|
122
|
+
const mollieOrderId = s4OrderId || storedOrderId;
|
|
123
|
+
if (!mollieOrderId) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
onPaymentComplete({
|
|
128
|
+
orderId: mollieOrderId,
|
|
129
|
+
agreementId: '',
|
|
130
|
+
orderInfo: orderInfo || null,
|
|
131
|
+
});
|
|
132
|
+
}, [
|
|
133
|
+
queryParams.get('action'),
|
|
134
|
+
queryParams.get('S4OrderId'),
|
|
135
|
+
queryParams.get('TransactionId'),
|
|
136
|
+
]);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default usePaymentReturn;
|
|
File without changes
|
package/src/index.tsx
CHANGED
|
File without changes
|
package/src/lib/utils.ts
CHANGED
|
File without changes
|
package/src/types/api.ts
CHANGED
|
File without changes
|
package/src/types/general.ts
CHANGED
|
@@ -1,136 +1,153 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PaymentMethodEnum, UserActionEnum } from '../enums/general';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { PaymentMethodEnum, UserActionEnum } from '../enums/general';
|
|
4
|
+
import type {
|
|
5
|
+
OrderCompletionEventType,
|
|
6
|
+
OrderCompletionDelayedEventType,
|
|
7
|
+
OrderCompletionFailedEventType,
|
|
8
|
+
OrderFormInputsType,
|
|
9
|
+
} from './order';
|
|
10
|
+
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
sdkOrderCallback: () => void;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type OrderFormFieldType = {
|
|
18
|
+
name: string;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
label?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type PaymentMethodSettingsType = {
|
|
25
|
+
[key in PaymentMethodEnum]?: {
|
|
26
|
+
generateSubscriberContact?: boolean;
|
|
27
|
+
accountId?: string;
|
|
28
|
+
orderFormFields?: OrderFormFieldType[];
|
|
29
|
+
paymentInvoiceFields?: OrderFormFieldType[] | never[] | null;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ContactRequestType = {
|
|
34
|
+
addressLines?: Array<string> | undefined;
|
|
35
|
+
name?: string;
|
|
36
|
+
email?: string;
|
|
37
|
+
phone?: string;
|
|
38
|
+
country?: string;
|
|
39
|
+
city?: string;
|
|
40
|
+
zip?: string;
|
|
41
|
+
careOf?: string;
|
|
42
|
+
organizationNumber?: string;
|
|
43
|
+
gln?: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type OrderDenialFallbackOfferType = {
|
|
47
|
+
title?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
price?: string;
|
|
50
|
+
templatePackageId?: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type PaymentIconType = {
|
|
54
|
+
src: string;
|
|
55
|
+
alt?: string;
|
|
56
|
+
className?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type PaymentMethodOptionType = {
|
|
60
|
+
label: string;
|
|
61
|
+
value: PaymentMethodEnum;
|
|
62
|
+
description?: string;
|
|
63
|
+
icons?: PaymentIconType[];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type SubmitConfirmationType = {
|
|
67
|
+
title: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
confirmText: string;
|
|
70
|
+
cancelText: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type ConfigType = {
|
|
74
|
+
/** SDK polling is the default. External mode delegates confirmation to the host. */
|
|
75
|
+
completionMode?: 'sdk' | 'external';
|
|
76
|
+
orderAcceptedCallback?: (event: OrderCompletionEventType) => void;
|
|
77
|
+
orderCompletedCallback?: (event: OrderCompletionEventType) => void;
|
|
78
|
+
orderCompletionDelayedCallback?: (
|
|
79
|
+
event: OrderCompletionDelayedEventType
|
|
80
|
+
) => void;
|
|
81
|
+
orderCompletionFailedCallback?: (
|
|
82
|
+
event: OrderCompletionFailedEventType
|
|
83
|
+
) => void;
|
|
84
|
+
submitStartCallback?: (subscriberId: string) => void;
|
|
85
|
+
userActionCallback?: (
|
|
86
|
+
action: UserActionEnum,
|
|
87
|
+
args: object | null | undefined
|
|
88
|
+
) => void;
|
|
89
|
+
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
90
|
+
cancelVippsCallback?: () => void;
|
|
91
|
+
domElementId: string;
|
|
92
|
+
moduleTitle?: string;
|
|
93
|
+
templatePackageId: string;
|
|
94
|
+
subscriberId: string;
|
|
95
|
+
userId: string;
|
|
96
|
+
identityProviderId: string;
|
|
97
|
+
organizationId: string;
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
apiUrl?: string;
|
|
100
|
+
redirectUrl?: string;
|
|
101
|
+
availablePaymentMethods?: PaymentMethodOptionType[];
|
|
102
|
+
allowedPaymentMethods?: PaymentMethodEnum[];
|
|
103
|
+
paymentMethodsOptions?: PaymentMethodSettingsType;
|
|
104
|
+
requireTermsAcceptance?: boolean;
|
|
105
|
+
language?: string;
|
|
106
|
+
merchantAgreementUrl?: string;
|
|
107
|
+
invoiceAddressSelection?: {
|
|
108
|
+
enabled?: boolean;
|
|
109
|
+
label?: string;
|
|
110
|
+
fields?: OrderFormFieldType[];
|
|
111
|
+
};
|
|
112
|
+
settings?: {
|
|
113
|
+
successText?: string;
|
|
114
|
+
orderProcessingText?: string;
|
|
115
|
+
orderReceivedText?: string;
|
|
116
|
+
orderDelayedText?: string;
|
|
117
|
+
failureText?: string;
|
|
118
|
+
submitButtonText?: string;
|
|
119
|
+
backButtonText?: string;
|
|
120
|
+
verifyButtonText?: string;
|
|
121
|
+
orderDenialCloseButtonText?: string;
|
|
122
|
+
orderDenialContinueButtonText?: string;
|
|
123
|
+
organizationNumberLabel?: string;
|
|
124
|
+
cvrLabel?: string;
|
|
125
|
+
glnLabel?: string;
|
|
126
|
+
orderDefaultValues?: OrderFormInputsType;
|
|
127
|
+
paymentMethodLabel?: string;
|
|
128
|
+
contactDetailsLabel?: string;
|
|
129
|
+
paymentMethodElementId?: string;
|
|
130
|
+
contactDetailsElementId?: string;
|
|
131
|
+
errorReqMsg?: string;
|
|
132
|
+
errorInvalidEmailMsg?: string;
|
|
133
|
+
errorInvalidPhoneMsg?: string;
|
|
134
|
+
errorTermsMsg?: string;
|
|
135
|
+
paymentMethodNotAllowedMsg?: string;
|
|
136
|
+
invoiceLookupNotFoundText?: string;
|
|
137
|
+
errorValidationTitleMsg?: string;
|
|
138
|
+
errorValidationDenialOrderBlockingMsg?: string;
|
|
139
|
+
errorValidationBlockingOffersMsg?: string;
|
|
140
|
+
orderDenialOfferBaseText?: string;
|
|
141
|
+
orderDenialOfferWithFallbackText?: string;
|
|
142
|
+
orderDenialAmountText?: string;
|
|
143
|
+
fetchDenialFallbackOffer?: (
|
|
144
|
+
organizationId: string
|
|
145
|
+
) => Promise<OrderDenialFallbackOfferType | undefined>;
|
|
146
|
+
termsAndConditionsText?: string | ReactNode;
|
|
147
|
+
submitConfirmation?: SubmitConfirmationType;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export type ErrorsMsg = {
|
|
152
|
+
[key: string]: string[];
|
|
153
|
+
};
|
package/src/types/order.ts
CHANGED
|
@@ -1,70 +1,91 @@
|
|
|
1
|
-
import { PaymentMethodEnum } from '../enums/general';
|
|
2
|
-
|
|
3
|
-
export type OrderFormInputsType = {
|
|
4
|
-
name?: string;
|
|
5
|
-
email?: string;
|
|
6
|
-
phoneNumber?: string;
|
|
7
|
-
paymentMethod?: PaymentMethodEnum;
|
|
8
|
-
country?: string;
|
|
9
|
-
city?: string;
|
|
10
|
-
address?: string;
|
|
11
|
-
zip?: string;
|
|
12
|
-
careOf?: string;
|
|
13
|
-
organizationNumber?: string;
|
|
14
|
-
invoiceAddressSelection?: boolean;
|
|
15
|
-
orderReference?: string;
|
|
16
|
-
invoiceName?: string;
|
|
17
|
-
invoiceEmail?: string;
|
|
18
|
-
invoicePhoneNumber?: string;
|
|
19
|
-
invoiceCountry?: string;
|
|
20
|
-
invoiceCity?: string;
|
|
21
|
-
invoiceAddress?: string;
|
|
22
|
-
invoiceZip?: string;
|
|
23
|
-
invoiceCareOf?: string;
|
|
24
|
-
invoiceBuyerReference?: string;
|
|
25
|
-
gln?: string;
|
|
26
|
-
cvr?: string;
|
|
27
|
-
termsAccept?: boolean;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type VippsMobilePay = {
|
|
31
|
-
phoneNumber?: string;
|
|
32
|
-
merchantRedirectUrl: string;
|
|
33
|
-
merchantAgreementUrl: string;
|
|
34
|
-
generateSubscriberContact?: boolean;
|
|
35
|
-
accountId?: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type SwedbankPay = {
|
|
39
|
-
accountId?: string;
|
|
40
|
-
completeUrl: string;
|
|
41
|
-
cancelUrl: string;
|
|
42
|
-
language?: string;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type Mollie = {
|
|
46
|
-
accountId?: string;
|
|
47
|
-
returnUrl: string;
|
|
48
|
-
cancelUrl?: string;
|
|
49
|
-
language?: string;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type AgreementsType = {
|
|
53
|
-
paymentProvider: PaymentMethodEnum;
|
|
54
|
-
vippsMobilePay?: VippsMobilePay;
|
|
55
|
-
swedbankPay?: SwedbankPay;
|
|
56
|
-
mollie?: Mollie;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export type OrderInfoType = {
|
|
60
|
-
subscriberId: string;
|
|
61
|
-
paymentMethod: string;
|
|
62
|
-
orderId: string;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
import { PaymentMethodEnum } from '../enums/general';
|
|
2
|
+
|
|
3
|
+
export type OrderFormInputsType = {
|
|
4
|
+
name?: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
phoneNumber?: string;
|
|
7
|
+
paymentMethod?: PaymentMethodEnum;
|
|
8
|
+
country?: string;
|
|
9
|
+
city?: string;
|
|
10
|
+
address?: string;
|
|
11
|
+
zip?: string;
|
|
12
|
+
careOf?: string;
|
|
13
|
+
organizationNumber?: string;
|
|
14
|
+
invoiceAddressSelection?: boolean;
|
|
15
|
+
orderReference?: string;
|
|
16
|
+
invoiceName?: string;
|
|
17
|
+
invoiceEmail?: string;
|
|
18
|
+
invoicePhoneNumber?: string;
|
|
19
|
+
invoiceCountry?: string;
|
|
20
|
+
invoiceCity?: string;
|
|
21
|
+
invoiceAddress?: string;
|
|
22
|
+
invoiceZip?: string;
|
|
23
|
+
invoiceCareOf?: string;
|
|
24
|
+
invoiceBuyerReference?: string;
|
|
25
|
+
gln?: string;
|
|
26
|
+
cvr?: string;
|
|
27
|
+
termsAccept?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type VippsMobilePay = {
|
|
31
|
+
phoneNumber?: string;
|
|
32
|
+
merchantRedirectUrl: string;
|
|
33
|
+
merchantAgreementUrl: string;
|
|
34
|
+
generateSubscriberContact?: boolean;
|
|
35
|
+
accountId?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type SwedbankPay = {
|
|
39
|
+
accountId?: string;
|
|
40
|
+
completeUrl: string;
|
|
41
|
+
cancelUrl: string;
|
|
42
|
+
language?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type Mollie = {
|
|
46
|
+
accountId?: string;
|
|
47
|
+
returnUrl: string;
|
|
48
|
+
cancelUrl?: string;
|
|
49
|
+
language?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type AgreementsType = {
|
|
53
|
+
paymentProvider: PaymentMethodEnum;
|
|
54
|
+
vippsMobilePay?: VippsMobilePay;
|
|
55
|
+
swedbankPay?: SwedbankPay;
|
|
56
|
+
mollie?: Mollie;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type OrderInfoType = {
|
|
60
|
+
subscriberId: string;
|
|
61
|
+
paymentMethod: string;
|
|
62
|
+
orderId: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type OrderStatusResponseType = {
|
|
66
|
+
id: string;
|
|
67
|
+
status: string;
|
|
68
|
+
orderCreated?: string | null;
|
|
69
|
+
orderCompleted?: string | null;
|
|
70
|
+
orderCancelled?: string | null;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type OrderCompletionEventType = {
|
|
74
|
+
orderId: string;
|
|
75
|
+
orderInfo: OrderInfoType | null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type OrderCompletionDelayedEventType = OrderCompletionEventType & {
|
|
79
|
+
reason: 'timeout' | 'statusUnavailable';
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type OrderCompletionFailedEventType = OrderCompletionEventType & {
|
|
83
|
+
status: 'Cancelled' | 'Rejected';
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type CompleteOrderParamsType = {
|
|
87
|
+
orderId: string;
|
|
88
|
+
agreementId: string;
|
|
89
|
+
orderInfo: OrderInfoType | null;
|
|
90
|
+
paymentMethod?: PaymentMethodEnum | null;
|
|
91
|
+
};
|