@infosoftas/s4-orders-js-sdk 0.1.21-0 → 0.1.21-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/README.md +471 -471
- package/package.json +58 -59
- package/src/App.tsx +639 -639
- package/src/ErrorBoundary.tsx +1 -1
- package/src/api/OrdersApi.ts +2 -2
- package/src/api/SubscribeApi.ts +1 -1
- package/src/bundle.ts +4 -0
- package/src/components/Alert/Alert.tsx +23 -23
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/EHFForm/EHFForm.tsx +253 -253
- package/src/components/FormFields/AddressField.tsx +55 -55
- package/src/components/FormFields/EmailField.tsx +53 -53
- package/src/components/FormFields/FormFields.helper.ts +1 -1
- package/src/components/FormFields/InputField.tsx +52 -52
- package/src/components/FormFields/NameField.tsx +52 -52
- package/src/components/FormFields/PhoneField.tsx +53 -53
- package/src/components/FormFields/TermsCheckbox.tsx +70 -70
- package/src/components/FormFields/ToggleFiled.tsx +52 -52
- package/src/components/FormFields/fieldValidators.ts +1 -1
- package/src/components/MainIframe/MainIframe.tsx +1 -1
- package/src/components/OIOForm/OIOForm.tsx +4 -4
- package/src/components/OrderDenialModal/OrderDenialModal.tsx +102 -102
- package/src/components/OrderForm/ContactDetailsSection.tsx +71 -71
- package/src/components/OrderForm/OrderForm.tsx +8 -8
- package/src/components/OrderForm/PaymentMethodContent.tsx +62 -62
- package/src/components/OrderForm/PaymentMethodSection.tsx +79 -79
- package/src/components/OrderForm/SubmitConfirmationDialog.tsx +55 -55
- package/src/components/OrderForm/orderFormState.ts +171 -171
- package/src/components/OrderForm/useSlotElement.tsx +2 -2
- package/src/hooks/useMessageEvent.tsx +1 -1
- package/src/hooks/useOrderForm.tsx +4 -4
- package/src/index.tsx +2 -4
- package/src/types/general.ts +136 -136
- package/src/utils/fetcher.ts +1 -1
- package/src/utils/helper.ts +1 -1
- package/src/utils/order.helper.ts +2 -2
- package/tsconfig.json +38 -37
package/README.md
CHANGED
|
@@ -1,471 +1,471 @@
|
|
|
1
|
-
# INFO-Subscription JS/TS Order SDK
|
|
2
|
-
|
|
3
|
-
This repository contains code for the Orders SDK usable to add orders for Tenants within INFO-Subscription.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Install the package with:
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
npm install @infosoftas/s4-orders-js-sdk
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Available Scripts
|
|
14
|
-
|
|
15
|
-
In the project directory, you can run:
|
|
16
|
-
|
|
17
|
-
### `npm run build`
|
|
18
|
-
|
|
19
|
-
Builds the app for production to the `dist` folder.\
|
|
20
|
-
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
21
|
-
|
|
22
|
-
The build is minified and the filenames include the hashes.\
|
|
23
|
-
Your app is ready to be deployed!
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
The package needs to be configured with configuration object:
|
|
28
|
-
|
|
29
|
-
<!-- prettier-ignore -->
|
|
30
|
-
```ts
|
|
31
|
-
|
|
32
|
-
enum PaymentMethodEnum {
|
|
33
|
-
Vipps = 'Vipps',
|
|
34
|
-
MobilePay = 'MobilePay',
|
|
35
|
-
SwedbankPay = 'SwedbankPay',
|
|
36
|
-
Mollie = 'Mollie',
|
|
37
|
-
Invoice = 'Invoice',
|
|
38
|
-
Email = 'Email',
|
|
39
|
-
EHF = 'EHF',
|
|
40
|
-
OIO = 'OIO',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type OrderFormFieldType = {
|
|
44
|
-
name: string;
|
|
45
|
-
required?: boolean;
|
|
46
|
-
readOnly?: boolean;
|
|
47
|
-
label?: string;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type PaymentMethodSettingsType = {
|
|
51
|
-
[key in PaymentMethodEnum]?: {
|
|
52
|
-
generateSubscriberContact?: boolean;
|
|
53
|
-
accountId?: string;
|
|
54
|
-
orderFormFields?: OrderFormFieldType[];
|
|
55
|
-
paymentInvoiceFields?: OrderFormFieldType[] | never[] | null;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type OrderFormInputsType = {
|
|
60
|
-
name?: string;
|
|
61
|
-
email?: string;
|
|
62
|
-
phoneNumber?: string;
|
|
63
|
-
paymentMethod?: PaymentMethodEnum;
|
|
64
|
-
country?: string;
|
|
65
|
-
city?: string;
|
|
66
|
-
address?: string;
|
|
67
|
-
zip?: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
enum UserActionEnum {
|
|
71
|
-
SELECT_FORM = 'selectForm',
|
|
72
|
-
SELECT_PAYMENT_METHOD = 'selectPaymentMethod',
|
|
73
|
-
RETURN_TO_MAIN = 'returnToMain',
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
type ConfigType = {
|
|
77
|
-
domElementId: string;
|
|
78
|
-
moduleTitle?: string;
|
|
79
|
-
submitStartCallback?: (subscriberId: string) => void;
|
|
80
|
-
userActionCallback?: (action: UserActionEnum, args: object | null | undefined) => void;
|
|
81
|
-
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
82
|
-
cancelVippsCallback?: () => void;
|
|
83
|
-
apiKey?: string;
|
|
84
|
-
apiUrl?: string;
|
|
85
|
-
templatePackageId: string;
|
|
86
|
-
subscriberId: string;
|
|
87
|
-
userId: string;
|
|
88
|
-
identityProviderId: string;
|
|
89
|
-
organizationId: string;
|
|
90
|
-
redirectUrl?: string;
|
|
91
|
-
showIframe?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* The full list of payment methods displayed in the UI, each with a display label and value.
|
|
94
|
-
* Controls what the user sees in the payment method selector.
|
|
95
|
-
* @example [{ label: 'Credit Card', value: 'SwedbankPay' }, { label: 'Invoice', value: 'Invoice' }]
|
|
96
|
-
*/
|
|
97
|
-
availablePaymentMethods?: {
|
|
98
|
-
label: string;
|
|
99
|
-
value: PaymentMethodEnum;
|
|
100
|
-
description?: string;
|
|
101
|
-
icons?: { src: string; alt?: string; className?: string }[];
|
|
102
|
-
}[];
|
|
103
|
-
/**
|
|
104
|
-
* Whitelist of payment methods the subscriber is permitted to use.
|
|
105
|
-
* If a method is in availablePaymentMethods but not here, it will be shown but blocked.
|
|
106
|
-
* @example ['SwedbankPay', 'Invoice']
|
|
107
|
-
*/
|
|
108
|
-
allowedPaymentMethods?: PaymentMethodEnum[];
|
|
109
|
-
/**
|
|
110
|
-
* Per-payment-method form field configuration.
|
|
111
|
-
* Controls which input fields are shown in the order form for each payment method.
|
|
112
|
-
* Use accountId on SwedbankPay to set your Swedbank Pay account ID.
|
|
113
|
-
*/
|
|
114
|
-
paymentMethodsOptions?: PaymentMethodSettingsType;
|
|
115
|
-
requireTermsAcceptance?: boolean;
|
|
116
|
-
language?: string;
|
|
117
|
-
merchantAgreementUrl?: string;
|
|
118
|
-
invoiceAddressSelection?: {
|
|
119
|
-
enabled?: boolean;
|
|
120
|
-
label?: string;
|
|
121
|
-
fields?: OrderFormFieldType[];
|
|
122
|
-
};
|
|
123
|
-
settings?: {
|
|
124
|
-
successText?: string;
|
|
125
|
-
failureText?: string;
|
|
126
|
-
submitButtonText?: string;
|
|
127
|
-
backButtonText?: string;
|
|
128
|
-
verifyButtonText?: string;
|
|
129
|
-
organizationNumberLabel?: string;
|
|
130
|
-
cvrLabel?: string;
|
|
131
|
-
glnLabel?: string;
|
|
132
|
-
orderDefaultValues?: OrderFormInputsType;
|
|
133
|
-
paymentMethodLabel?: string;
|
|
134
|
-
contactDetailsLabel?: string;
|
|
135
|
-
/**
|
|
136
|
-
* Ids of existing elements on the host page. When set, the matching
|
|
137
|
-
* order form section is rendered into that element instead of inline.
|
|
138
|
-
*/
|
|
139
|
-
paymentMethodElementId?: string;
|
|
140
|
-
contactDetailsElementId?: string;
|
|
141
|
-
errorReqMsg?: string;
|
|
142
|
-
errorInvalidEmailMsg?: string;
|
|
143
|
-
errorInvalidPhoneMsg?: string;
|
|
144
|
-
errorTermsMsg?: string;
|
|
145
|
-
errorValidationTitleMsg?: string;
|
|
146
|
-
errorValidationDenialOrderBlockingMsg?: string;
|
|
147
|
-
errorValidationBlockingOffersMsg?: string;
|
|
148
|
-
paymentMethodNotAllowedMsg?: string;
|
|
149
|
-
invoiceLookupNotFoundText?: string;
|
|
150
|
-
orderDenialOfferBaseText?: string;
|
|
151
|
-
orderDenialOfferWithFallbackText?: string;
|
|
152
|
-
orderDenialAmountText?: string;
|
|
153
|
-
fetchDenialFallbackOffer?: (organizationId: string) => Promise<OrderDenialFallbackOfferType | undefined>;
|
|
154
|
-
termsAndConditionsText?: string | ReactNode;
|
|
155
|
-
/**
|
|
156
|
-
* When set, submitting the order opens a confirmation dialog first.
|
|
157
|
-
* The order is only sent once the user confirms.
|
|
158
|
-
*/
|
|
159
|
-
submitConfirmation?: {
|
|
160
|
-
title: string;
|
|
161
|
-
description?: string;
|
|
162
|
-
confirmText: string;
|
|
163
|
-
cancelText: string;
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Usage example OrderPlace react component:
|
|
170
|
-
|
|
171
|
-
<!-- prettier-ignore -->
|
|
172
|
-
```tsx
|
|
173
|
-
|
|
174
|
-
enum OrderModuleFiledNameEnum {
|
|
175
|
-
name = 'name',
|
|
176
|
-
email = 'email',
|
|
177
|
-
phoneNumber = 'phoneNumber',
|
|
178
|
-
address = 'address',
|
|
179
|
-
country = 'country',
|
|
180
|
-
city = 'city',
|
|
181
|
-
zip = 'zip',
|
|
182
|
-
careOf = 'careOf',
|
|
183
|
-
organizationNumber = 'organizationNumber',
|
|
184
|
-
buyerReference = 'buyerReference',
|
|
185
|
-
orderReference = 'orderReference',
|
|
186
|
-
invoiceName = 'invoiceName',
|
|
187
|
-
invoiceAddress = 'invoiceAddress',
|
|
188
|
-
invoiceCity = 'invoiceCity',
|
|
189
|
-
invoiceZip = 'invoiceZip',
|
|
190
|
-
invoiceCountry = 'invoiceCountry',
|
|
191
|
-
invoicePhone = 'invoicePhoneNumber',
|
|
192
|
-
invoiceEmail = 'invoiceEmail',
|
|
193
|
-
invoiceCareOf = 'invoiceCareOf',
|
|
194
|
-
invoiceBuyerReference ='invoiceBuyerReference',
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export const prepareConfig = ({
|
|
198
|
-
submitStartCallback,
|
|
199
|
-
apiKey,
|
|
200
|
-
apiUrl,
|
|
201
|
-
userId,
|
|
202
|
-
subscriberId,
|
|
203
|
-
templatePackageId,
|
|
204
|
-
identityProviderId,
|
|
205
|
-
organizationId,
|
|
206
|
-
selfServiceUrl,
|
|
207
|
-
userEmail,
|
|
208
|
-
name,
|
|
209
|
-
city,
|
|
210
|
-
country,
|
|
211
|
-
postalCode,
|
|
212
|
-
streetAddress,
|
|
213
|
-
}: Props) => {
|
|
214
|
-
|
|
215
|
-
const config = {
|
|
216
|
-
submitStartCallback,
|
|
217
|
-
userActionCallback: (action, args) => {
|
|
218
|
-
console.log(action);
|
|
219
|
-
console.table(args);
|
|
220
|
-
},
|
|
221
|
-
moduleTitle: '',
|
|
222
|
-
domElementId: ORDER_PLACE_ID,
|
|
223
|
-
redirectUrl: window.location.href,
|
|
224
|
-
merchantAgreementUrl: selfServiceUrl,
|
|
225
|
-
showIframe: true,
|
|
226
|
-
apiKey,
|
|
227
|
-
apiUrl,
|
|
228
|
-
userId,
|
|
229
|
-
subscriberId,
|
|
230
|
-
templatePackageId,
|
|
231
|
-
identityProviderId,
|
|
232
|
-
organizationId,
|
|
233
|
-
language: 'en-US',
|
|
234
|
-
availablePaymentMethods: [
|
|
235
|
-
{ label: "Vipps", value: "Vipps" },
|
|
236
|
-
{ label: "MobilePay", value: "MobilePay" },
|
|
237
|
-
{ label: "Credit Card/Debit Card", value: "SwedbankPay" },
|
|
238
|
-
{ label: "Mollie", value: "Mollie" },
|
|
239
|
-
{ label: 'Invoice', translateKey: 'Invoice', value: 'Invoice' },
|
|
240
|
-
{ label: 'Email', translateKey: 'Email', value: 'Email' },
|
|
241
|
-
{ label: 'EHF', translateKey: 'EHF', value: 'EHF' },
|
|
242
|
-
{ label: 'OIO', translateKey: 'OIO', value: 'OIO' },
|
|
243
|
-
],
|
|
244
|
-
paymentMethodsOptions: {
|
|
245
|
-
Vipps: {
|
|
246
|
-
generateSubscriberContact: true,
|
|
247
|
-
orderFormFields: [],
|
|
248
|
-
},
|
|
249
|
-
SwedbankPay: {
|
|
250
|
-
orderFormFields: [
|
|
251
|
-
{
|
|
252
|
-
name: OrderModuleFiledNameEnum.name,
|
|
253
|
-
label: 'Name',
|
|
254
|
-
required: false,
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: OrderModuleFiledNameEnum.phoneNumber,
|
|
258
|
-
label: 'Phone',
|
|
259
|
-
readOnly: false,
|
|
260
|
-
required: false,
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
name: OrderModuleFiledNameEnum.email,
|
|
264
|
-
label: 'Email',
|
|
265
|
-
required: true,
|
|
266
|
-
readOnly: !!userEmail,
|
|
267
|
-
},
|
|
268
|
-
],
|
|
269
|
-
},
|
|
270
|
-
Mollie: {
|
|
271
|
-
accountId: 'your-mollie-account-id',
|
|
272
|
-
orderFormFields: [
|
|
273
|
-
{
|
|
274
|
-
name: OrderModuleFiledNameEnum.name,
|
|
275
|
-
label: 'Name',
|
|
276
|
-
required: false,
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
name: OrderModuleFiledNameEnum.email,
|
|
280
|
-
label: 'Email',
|
|
281
|
-
required: true,
|
|
282
|
-
readOnly: !!userEmail,
|
|
283
|
-
},
|
|
284
|
-
],
|
|
285
|
-
},
|
|
286
|
-
Invoice: {
|
|
287
|
-
orderFormFields: [
|
|
288
|
-
{
|
|
289
|
-
name: OrderModuleFiledNameEnum.address,
|
|
290
|
-
label: 'Address',
|
|
291
|
-
required: false,
|
|
292
|
-
readOnly: false,
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
},
|
|
296
|
-
Email: {
|
|
297
|
-
orderFormFields: [
|
|
298
|
-
{
|
|
299
|
-
name: OrderModuleFiledNameEnum.address,
|
|
300
|
-
label: 'Address',
|
|
301
|
-
required: false,
|
|
302
|
-
readOnly: false,
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
paymentInvoiceFields: [
|
|
306
|
-
{
|
|
307
|
-
name: OrderModuleFiledNameEnum.invoiceEmail,
|
|
308
|
-
label: 'Email',
|
|
309
|
-
required: true,
|
|
310
|
-
readOnly: false,
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
},
|
|
314
|
-
EHF: {
|
|
315
|
-
orderFormFields: [
|
|
316
|
-
{
|
|
317
|
-
name: OrderModuleFiledNameEnum.address,
|
|
318
|
-
label: 'Address',
|
|
319
|
-
required: false,
|
|
320
|
-
readOnly: false,
|
|
321
|
-
},
|
|
322
|
-
],
|
|
323
|
-
},
|
|
324
|
-
OIO: {
|
|
325
|
-
orderFormFields: [
|
|
326
|
-
{
|
|
327
|
-
name: OrderModuleFiledNameEnum.address,
|
|
328
|
-
label: 'Address',
|
|
329
|
-
required: false,
|
|
330
|
-
readOnly: false,
|
|
331
|
-
},
|
|
332
|
-
],
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
invoiceAddressSelection: {
|
|
336
|
-
enabled: true,
|
|
337
|
-
label: 'Invoice Address',
|
|
338
|
-
fields: [
|
|
339
|
-
{
|
|
340
|
-
name: OrderModuleFiledNameEnum.invoiceAddress,
|
|
341
|
-
label: 'Address',
|
|
342
|
-
required: false,
|
|
343
|
-
readOnly: false,
|
|
344
|
-
},
|
|
345
|
-
],
|
|
346
|
-
},
|
|
347
|
-
settings: {
|
|
348
|
-
submitButtonText: 'Continue',
|
|
349
|
-
backButtonText: 'Back',
|
|
350
|
-
verifyButtonText: 'Verify',
|
|
351
|
-
organizationNumberLabel: 'Organization Number',
|
|
352
|
-
glnLabel: 'GLN/EAN',
|
|
353
|
-
cvrLabel: 'CVR',
|
|
354
|
-
paymentMethodLabel: 'Select Payment Method',
|
|
355
|
-
errorReqMsg: 'This field is required!',
|
|
356
|
-
errorInvalidEmailMsg: 'Invalid email address!',
|
|
357
|
-
errorInvalidPhoneMsg: 'Invalid phone number!',
|
|
358
|
-
errorValidationTitleMsg: 'One or more validation errors occurred.',
|
|
359
|
-
errorValidationDenialOrderBlockingMsg: 'The order/subscription will not be created because the subscriber has a denial order blocking all.',
|
|
360
|
-
errorValidationBlockingOffersMsg: 'The order/subscription will not be created because the subscriber has a denial order blocking offers.',
|
|
361
|
-
paymentMethodNotAllowedMsg: 'This payment method not allowed!',
|
|
362
|
-
invoiceLookupNotFoundText: 'There was no recipient found for the given information',
|
|
363
|
-
successText: 'Success message',
|
|
364
|
-
failureText: 'Failed message',
|
|
365
|
-
orderDefaultValues: {
|
|
366
|
-
name,
|
|
367
|
-
email: userEmail || '',
|
|
368
|
-
phoneNumber: '',
|
|
369
|
-
city,
|
|
370
|
-
country,
|
|
371
|
-
zip: postalCode,
|
|
372
|
-
address: streetAddress,
|
|
373
|
-
paymentMethod: undefined,
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
return config as ConfigType;
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
import { FC, useEffect, useRef, useCallback } from 'react';
|
|
383
|
-
import { useSearchParams } from 'react-router-dom';
|
|
384
|
-
import { orderComponent } from '@infosoftas/s4-orders-js-sdk/src/index';
|
|
385
|
-
|
|
386
|
-
import { prepareConfig } from 'Utils/moduleConfig';
|
|
387
|
-
import { encodeJwt } from 'Utils/helper';
|
|
388
|
-
|
|
389
|
-
const ORDER_PLACE_ID = 'sdk-order';
|
|
390
|
-
|
|
391
|
-
const OrderPlace: FC = ({journey, userEmail, sub, emails, userId, name, city, country, postalCode, streetAddress}) => {
|
|
392
|
-
const moduleMount = useRef(false);
|
|
393
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
394
|
-
|
|
395
|
-
const submitStartCallback = useCallback(
|
|
396
|
-
(subscriberId: string) => {
|
|
397
|
-
const hashTokenValue = {
|
|
398
|
-
extension_SubscriberId: subscriberId,
|
|
399
|
-
emails: emails,
|
|
400
|
-
sub: sub,
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
searchParams?.set('hashToken', encodeJwt(hashTokenValue) as string);
|
|
404
|
-
setSearchParams(searchParams);
|
|
405
|
-
},
|
|
406
|
-
[emails, sub, searchParams, setSearchParams]
|
|
407
|
-
);
|
|
408
|
-
|
|
409
|
-
useEffect(() => {
|
|
410
|
-
if (!moduleMount.current && idTokenClaims) {
|
|
411
|
-
moduleMount.current = true;
|
|
412
|
-
const config = prepareConfig({
|
|
413
|
-
apiKey: API_KEY,
|
|
414
|
-
apiUrl: API_URL,
|
|
415
|
-
userId: userId || '',
|
|
416
|
-
subscriberId: userEmail || '',
|
|
417
|
-
identityProviderId: IDENTITY_PROVIDER_ID,
|
|
418
|
-
templatePackageId: TEMPLATE_PACKAGE_ID,
|
|
419
|
-
selfServiceUrl: SELF_SERVICE_URL,
|
|
420
|
-
organizationId: ORGANIZATION_ID,
|
|
421
|
-
userEmail: userEmail || '',
|
|
422
|
-
name: name,
|
|
423
|
-
city: city,
|
|
424
|
-
country: country,
|
|
425
|
-
postalCode: postalCode,
|
|
426
|
-
streetAddress: streetAddress,
|
|
427
|
-
journey: journey,
|
|
428
|
-
submitStartCallback: submitStartCallback,
|
|
429
|
-
});
|
|
430
|
-
orderComponent?.remove();
|
|
431
|
-
orderComponent?.init(config);
|
|
432
|
-
}
|
|
433
|
-
}, [userEmail, userId, name, city, country, postalCode, streetAddress, journey, submitStartCallback]);
|
|
434
|
-
|
|
435
|
-
return (
|
|
436
|
-
<div
|
|
437
|
-
id={ORDER_PLACE_ID}
|
|
438
|
-
className="w-100 order-wrapper"
|
|
439
|
-
data-testid="order-place-id"
|
|
440
|
-
/>
|
|
441
|
-
);
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
export default OrderPlace;
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
<!-- prettier-ignore -->
|
|
448
|
-
| Option | Default | Description |
|
|
449
|
-
| --------------------- | :----------------------------------------------------------------------------: | -------------------------: |
|
|
450
|
-
| moduleTitle | '' | module title |
|
|
451
|
-
| apiKey | '' | order api key |
|
|
452
|
-
| apiUrl | '' | order api url |
|
|
453
|
-
| templatePackageId | '' | template package id |
|
|
454
|
-
| subscriberId | '' | subscriber id |
|
|
455
|
-
| identityProviderId | '' | identity provider id |
|
|
456
|
-
| organizationId | '' | organization id |
|
|
457
|
-
| redirectUrl | window.location.href | redirect url |
|
|
458
|
-
| showIframe | false | show credit card in iframe |
|
|
459
|
-
| userActionCallback | undefined | function for tracking user actions |
|
|
460
|
-
| cancelVippsCallback | undefined | callback invoked when a Vipps/MobilePay payment is cancelled |
|
|
461
|
-
| paymentMethodsOptions | orderFormFields: [{name: 'phoneNumber', required: false, readOnly: false, label: ''}] | default form fields |
|
|
462
|
-
| availablePaymentMethods | [] | available payment methods to display |
|
|
463
|
-
| allowedPaymentMethods | [] | list of payment methods the subscriber is allowed to use |
|
|
464
|
-
| requireTermsAcceptance | false | when true, the user must accept terms and conditions before submitting |
|
|
465
|
-
| language | 'en-US' | language |
|
|
466
|
-
| merchantAgreementUrl | '' | vipps and MobilePay property |
|
|
467
|
-
| settings.paymentMethodElementId / settings.contactDetailsElementId | undefined | ids of host page elements to render the payment method / contact detail sections into, instead of inline |
|
|
468
|
-
| settings.submitConfirmation | undefined | `{ title, description?, confirmText, cancelText }` — shows a confirmation dialog before the order is submitted |
|
|
469
|
-
| settings.contactDetailsLabel | undefined | heading for the contact details section |
|
|
470
|
-
| settings.errorTermsMsg | undefined | validation message shown when terms are not accepted |
|
|
471
|
-
| settings | {successText: 'Order completed successfully!', failureText: 'Something went wrong!', submitButtonText: 'Start', backButtonText: 'Back', verifyButtonText: 'Verify', organizationNumberLabel: 'Organization Number', cvrLabel: 'CVR', glnLabel: 'GLN', paymentMethodLabel: 'Select Payment Method', orderDefaultValues: 'Default order form values', errorReqMsg: '', errorInvalidEmailMsg: '', errorInvalidPhoneMsg: '', errorValidationTitleMsg: 'One or more validation errors occurred.', errorValidationDenialOrderBlockingMsg: '...', errorValidationBlockingOffersMsg: '...', paymentMethodNotAllowedMsg: 'This payment method not allowed!', invoiceLookupNotFoundText: 'There was no recipient found for the given information', termsAndConditionsText: '' } | label and text properties |
|
|
1
|
+
# INFO-Subscription JS/TS Order SDK
|
|
2
|
+
|
|
3
|
+
This repository contains code for the Orders SDK usable to add orders for Tenants within INFO-Subscription.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the package with:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @infosoftas/s4-orders-js-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Available Scripts
|
|
14
|
+
|
|
15
|
+
In the project directory, you can run:
|
|
16
|
+
|
|
17
|
+
### `npm run build`
|
|
18
|
+
|
|
19
|
+
Builds the app for production to the `dist` folder.\
|
|
20
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
21
|
+
|
|
22
|
+
The build is minified and the filenames include the hashes.\
|
|
23
|
+
Your app is ready to be deployed!
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
The package needs to be configured with configuration object:
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
```ts
|
|
31
|
+
|
|
32
|
+
enum PaymentMethodEnum {
|
|
33
|
+
Vipps = 'Vipps',
|
|
34
|
+
MobilePay = 'MobilePay',
|
|
35
|
+
SwedbankPay = 'SwedbankPay',
|
|
36
|
+
Mollie = 'Mollie',
|
|
37
|
+
Invoice = 'Invoice',
|
|
38
|
+
Email = 'Email',
|
|
39
|
+
EHF = 'EHF',
|
|
40
|
+
OIO = 'OIO',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type OrderFormFieldType = {
|
|
44
|
+
name: string;
|
|
45
|
+
required?: boolean;
|
|
46
|
+
readOnly?: boolean;
|
|
47
|
+
label?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type PaymentMethodSettingsType = {
|
|
51
|
+
[key in PaymentMethodEnum]?: {
|
|
52
|
+
generateSubscriberContact?: boolean;
|
|
53
|
+
accountId?: string;
|
|
54
|
+
orderFormFields?: OrderFormFieldType[];
|
|
55
|
+
paymentInvoiceFields?: OrderFormFieldType[] | never[] | null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type OrderFormInputsType = {
|
|
60
|
+
name?: string;
|
|
61
|
+
email?: string;
|
|
62
|
+
phoneNumber?: string;
|
|
63
|
+
paymentMethod?: PaymentMethodEnum;
|
|
64
|
+
country?: string;
|
|
65
|
+
city?: string;
|
|
66
|
+
address?: string;
|
|
67
|
+
zip?: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
enum UserActionEnum {
|
|
71
|
+
SELECT_FORM = 'selectForm',
|
|
72
|
+
SELECT_PAYMENT_METHOD = 'selectPaymentMethod',
|
|
73
|
+
RETURN_TO_MAIN = 'returnToMain',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type ConfigType = {
|
|
77
|
+
domElementId: string;
|
|
78
|
+
moduleTitle?: string;
|
|
79
|
+
submitStartCallback?: (subscriberId: string) => void;
|
|
80
|
+
userActionCallback?: (action: UserActionEnum, args: object | null | undefined) => void;
|
|
81
|
+
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
82
|
+
cancelVippsCallback?: () => void;
|
|
83
|
+
apiKey?: string;
|
|
84
|
+
apiUrl?: string;
|
|
85
|
+
templatePackageId: string;
|
|
86
|
+
subscriberId: string;
|
|
87
|
+
userId: string;
|
|
88
|
+
identityProviderId: string;
|
|
89
|
+
organizationId: string;
|
|
90
|
+
redirectUrl?: string;
|
|
91
|
+
showIframe?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* The full list of payment methods displayed in the UI, each with a display label and value.
|
|
94
|
+
* Controls what the user sees in the payment method selector.
|
|
95
|
+
* @example [{ label: 'Credit Card', value: 'SwedbankPay' }, { label: 'Invoice', value: 'Invoice' }]
|
|
96
|
+
*/
|
|
97
|
+
availablePaymentMethods?: {
|
|
98
|
+
label: string;
|
|
99
|
+
value: PaymentMethodEnum;
|
|
100
|
+
description?: string;
|
|
101
|
+
icons?: { src: string; alt?: string; className?: string }[];
|
|
102
|
+
}[];
|
|
103
|
+
/**
|
|
104
|
+
* Whitelist of payment methods the subscriber is permitted to use.
|
|
105
|
+
* If a method is in availablePaymentMethods but not here, it will be shown but blocked.
|
|
106
|
+
* @example ['SwedbankPay', 'Invoice']
|
|
107
|
+
*/
|
|
108
|
+
allowedPaymentMethods?: PaymentMethodEnum[];
|
|
109
|
+
/**
|
|
110
|
+
* Per-payment-method form field configuration.
|
|
111
|
+
* Controls which input fields are shown in the order form for each payment method.
|
|
112
|
+
* Use accountId on SwedbankPay to set your Swedbank Pay account ID.
|
|
113
|
+
*/
|
|
114
|
+
paymentMethodsOptions?: PaymentMethodSettingsType;
|
|
115
|
+
requireTermsAcceptance?: boolean;
|
|
116
|
+
language?: string;
|
|
117
|
+
merchantAgreementUrl?: string;
|
|
118
|
+
invoiceAddressSelection?: {
|
|
119
|
+
enabled?: boolean;
|
|
120
|
+
label?: string;
|
|
121
|
+
fields?: OrderFormFieldType[];
|
|
122
|
+
};
|
|
123
|
+
settings?: {
|
|
124
|
+
successText?: string;
|
|
125
|
+
failureText?: string;
|
|
126
|
+
submitButtonText?: string;
|
|
127
|
+
backButtonText?: string;
|
|
128
|
+
verifyButtonText?: string;
|
|
129
|
+
organizationNumberLabel?: string;
|
|
130
|
+
cvrLabel?: string;
|
|
131
|
+
glnLabel?: string;
|
|
132
|
+
orderDefaultValues?: OrderFormInputsType;
|
|
133
|
+
paymentMethodLabel?: string;
|
|
134
|
+
contactDetailsLabel?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Ids of existing elements on the host page. When set, the matching
|
|
137
|
+
* order form section is rendered into that element instead of inline.
|
|
138
|
+
*/
|
|
139
|
+
paymentMethodElementId?: string;
|
|
140
|
+
contactDetailsElementId?: string;
|
|
141
|
+
errorReqMsg?: string;
|
|
142
|
+
errorInvalidEmailMsg?: string;
|
|
143
|
+
errorInvalidPhoneMsg?: string;
|
|
144
|
+
errorTermsMsg?: string;
|
|
145
|
+
errorValidationTitleMsg?: string;
|
|
146
|
+
errorValidationDenialOrderBlockingMsg?: string;
|
|
147
|
+
errorValidationBlockingOffersMsg?: string;
|
|
148
|
+
paymentMethodNotAllowedMsg?: string;
|
|
149
|
+
invoiceLookupNotFoundText?: string;
|
|
150
|
+
orderDenialOfferBaseText?: string;
|
|
151
|
+
orderDenialOfferWithFallbackText?: string;
|
|
152
|
+
orderDenialAmountText?: string;
|
|
153
|
+
fetchDenialFallbackOffer?: (organizationId: string) => Promise<OrderDenialFallbackOfferType | undefined>;
|
|
154
|
+
termsAndConditionsText?: string | ReactNode;
|
|
155
|
+
/**
|
|
156
|
+
* When set, submitting the order opens a confirmation dialog first.
|
|
157
|
+
* The order is only sent once the user confirms.
|
|
158
|
+
*/
|
|
159
|
+
submitConfirmation?: {
|
|
160
|
+
title: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
confirmText: string;
|
|
163
|
+
cancelText: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Usage example OrderPlace react component:
|
|
170
|
+
|
|
171
|
+
<!-- prettier-ignore -->
|
|
172
|
+
```tsx
|
|
173
|
+
|
|
174
|
+
enum OrderModuleFiledNameEnum {
|
|
175
|
+
name = 'name',
|
|
176
|
+
email = 'email',
|
|
177
|
+
phoneNumber = 'phoneNumber',
|
|
178
|
+
address = 'address',
|
|
179
|
+
country = 'country',
|
|
180
|
+
city = 'city',
|
|
181
|
+
zip = 'zip',
|
|
182
|
+
careOf = 'careOf',
|
|
183
|
+
organizationNumber = 'organizationNumber',
|
|
184
|
+
buyerReference = 'buyerReference',
|
|
185
|
+
orderReference = 'orderReference',
|
|
186
|
+
invoiceName = 'invoiceName',
|
|
187
|
+
invoiceAddress = 'invoiceAddress',
|
|
188
|
+
invoiceCity = 'invoiceCity',
|
|
189
|
+
invoiceZip = 'invoiceZip',
|
|
190
|
+
invoiceCountry = 'invoiceCountry',
|
|
191
|
+
invoicePhone = 'invoicePhoneNumber',
|
|
192
|
+
invoiceEmail = 'invoiceEmail',
|
|
193
|
+
invoiceCareOf = 'invoiceCareOf',
|
|
194
|
+
invoiceBuyerReference ='invoiceBuyerReference',
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export const prepareConfig = ({
|
|
198
|
+
submitStartCallback,
|
|
199
|
+
apiKey,
|
|
200
|
+
apiUrl,
|
|
201
|
+
userId,
|
|
202
|
+
subscriberId,
|
|
203
|
+
templatePackageId,
|
|
204
|
+
identityProviderId,
|
|
205
|
+
organizationId,
|
|
206
|
+
selfServiceUrl,
|
|
207
|
+
userEmail,
|
|
208
|
+
name,
|
|
209
|
+
city,
|
|
210
|
+
country,
|
|
211
|
+
postalCode,
|
|
212
|
+
streetAddress,
|
|
213
|
+
}: Props) => {
|
|
214
|
+
|
|
215
|
+
const config = {
|
|
216
|
+
submitStartCallback,
|
|
217
|
+
userActionCallback: (action, args) => {
|
|
218
|
+
console.log(action);
|
|
219
|
+
console.table(args);
|
|
220
|
+
},
|
|
221
|
+
moduleTitle: '',
|
|
222
|
+
domElementId: ORDER_PLACE_ID,
|
|
223
|
+
redirectUrl: window.location.href,
|
|
224
|
+
merchantAgreementUrl: selfServiceUrl,
|
|
225
|
+
showIframe: true,
|
|
226
|
+
apiKey,
|
|
227
|
+
apiUrl,
|
|
228
|
+
userId,
|
|
229
|
+
subscriberId,
|
|
230
|
+
templatePackageId,
|
|
231
|
+
identityProviderId,
|
|
232
|
+
organizationId,
|
|
233
|
+
language: 'en-US',
|
|
234
|
+
availablePaymentMethods: [
|
|
235
|
+
{ label: "Vipps", value: "Vipps" },
|
|
236
|
+
{ label: "MobilePay", value: "MobilePay" },
|
|
237
|
+
{ label: "Credit Card/Debit Card", value: "SwedbankPay" },
|
|
238
|
+
{ label: "Mollie", value: "Mollie" },
|
|
239
|
+
{ label: 'Invoice', translateKey: 'Invoice', value: 'Invoice' },
|
|
240
|
+
{ label: 'Email', translateKey: 'Email', value: 'Email' },
|
|
241
|
+
{ label: 'EHF', translateKey: 'EHF', value: 'EHF' },
|
|
242
|
+
{ label: 'OIO', translateKey: 'OIO', value: 'OIO' },
|
|
243
|
+
],
|
|
244
|
+
paymentMethodsOptions: {
|
|
245
|
+
Vipps: {
|
|
246
|
+
generateSubscriberContact: true,
|
|
247
|
+
orderFormFields: [],
|
|
248
|
+
},
|
|
249
|
+
SwedbankPay: {
|
|
250
|
+
orderFormFields: [
|
|
251
|
+
{
|
|
252
|
+
name: OrderModuleFiledNameEnum.name,
|
|
253
|
+
label: 'Name',
|
|
254
|
+
required: false,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: OrderModuleFiledNameEnum.phoneNumber,
|
|
258
|
+
label: 'Phone',
|
|
259
|
+
readOnly: false,
|
|
260
|
+
required: false,
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: OrderModuleFiledNameEnum.email,
|
|
264
|
+
label: 'Email',
|
|
265
|
+
required: true,
|
|
266
|
+
readOnly: !!userEmail,
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
Mollie: {
|
|
271
|
+
accountId: 'your-mollie-account-id',
|
|
272
|
+
orderFormFields: [
|
|
273
|
+
{
|
|
274
|
+
name: OrderModuleFiledNameEnum.name,
|
|
275
|
+
label: 'Name',
|
|
276
|
+
required: false,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: OrderModuleFiledNameEnum.email,
|
|
280
|
+
label: 'Email',
|
|
281
|
+
required: true,
|
|
282
|
+
readOnly: !!userEmail,
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
},
|
|
286
|
+
Invoice: {
|
|
287
|
+
orderFormFields: [
|
|
288
|
+
{
|
|
289
|
+
name: OrderModuleFiledNameEnum.address,
|
|
290
|
+
label: 'Address',
|
|
291
|
+
required: false,
|
|
292
|
+
readOnly: false,
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
Email: {
|
|
297
|
+
orderFormFields: [
|
|
298
|
+
{
|
|
299
|
+
name: OrderModuleFiledNameEnum.address,
|
|
300
|
+
label: 'Address',
|
|
301
|
+
required: false,
|
|
302
|
+
readOnly: false,
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
paymentInvoiceFields: [
|
|
306
|
+
{
|
|
307
|
+
name: OrderModuleFiledNameEnum.invoiceEmail,
|
|
308
|
+
label: 'Email',
|
|
309
|
+
required: true,
|
|
310
|
+
readOnly: false,
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
EHF: {
|
|
315
|
+
orderFormFields: [
|
|
316
|
+
{
|
|
317
|
+
name: OrderModuleFiledNameEnum.address,
|
|
318
|
+
label: 'Address',
|
|
319
|
+
required: false,
|
|
320
|
+
readOnly: false,
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
OIO: {
|
|
325
|
+
orderFormFields: [
|
|
326
|
+
{
|
|
327
|
+
name: OrderModuleFiledNameEnum.address,
|
|
328
|
+
label: 'Address',
|
|
329
|
+
required: false,
|
|
330
|
+
readOnly: false,
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
invoiceAddressSelection: {
|
|
336
|
+
enabled: true,
|
|
337
|
+
label: 'Invoice Address',
|
|
338
|
+
fields: [
|
|
339
|
+
{
|
|
340
|
+
name: OrderModuleFiledNameEnum.invoiceAddress,
|
|
341
|
+
label: 'Address',
|
|
342
|
+
required: false,
|
|
343
|
+
readOnly: false,
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
settings: {
|
|
348
|
+
submitButtonText: 'Continue',
|
|
349
|
+
backButtonText: 'Back',
|
|
350
|
+
verifyButtonText: 'Verify',
|
|
351
|
+
organizationNumberLabel: 'Organization Number',
|
|
352
|
+
glnLabel: 'GLN/EAN',
|
|
353
|
+
cvrLabel: 'CVR',
|
|
354
|
+
paymentMethodLabel: 'Select Payment Method',
|
|
355
|
+
errorReqMsg: 'This field is required!',
|
|
356
|
+
errorInvalidEmailMsg: 'Invalid email address!',
|
|
357
|
+
errorInvalidPhoneMsg: 'Invalid phone number!',
|
|
358
|
+
errorValidationTitleMsg: 'One or more validation errors occurred.',
|
|
359
|
+
errorValidationDenialOrderBlockingMsg: 'The order/subscription will not be created because the subscriber has a denial order blocking all.',
|
|
360
|
+
errorValidationBlockingOffersMsg: 'The order/subscription will not be created because the subscriber has a denial order blocking offers.',
|
|
361
|
+
paymentMethodNotAllowedMsg: 'This payment method not allowed!',
|
|
362
|
+
invoiceLookupNotFoundText: 'There was no recipient found for the given information',
|
|
363
|
+
successText: 'Success message',
|
|
364
|
+
failureText: 'Failed message',
|
|
365
|
+
orderDefaultValues: {
|
|
366
|
+
name,
|
|
367
|
+
email: userEmail || '',
|
|
368
|
+
phoneNumber: '',
|
|
369
|
+
city,
|
|
370
|
+
country,
|
|
371
|
+
zip: postalCode,
|
|
372
|
+
address: streetAddress,
|
|
373
|
+
paymentMethod: undefined,
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
return config as ConfigType;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
import { FC, useEffect, useRef, useCallback } from 'react';
|
|
383
|
+
import { useSearchParams } from 'react-router-dom';
|
|
384
|
+
import { orderComponent } from '@infosoftas/s4-orders-js-sdk/src/index';
|
|
385
|
+
|
|
386
|
+
import { prepareConfig } from 'Utils/moduleConfig';
|
|
387
|
+
import { encodeJwt } from 'Utils/helper';
|
|
388
|
+
|
|
389
|
+
const ORDER_PLACE_ID = 'sdk-order';
|
|
390
|
+
|
|
391
|
+
const OrderPlace: FC = ({journey, userEmail, sub, emails, userId, name, city, country, postalCode, streetAddress}) => {
|
|
392
|
+
const moduleMount = useRef(false);
|
|
393
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
394
|
+
|
|
395
|
+
const submitStartCallback = useCallback(
|
|
396
|
+
(subscriberId: string) => {
|
|
397
|
+
const hashTokenValue = {
|
|
398
|
+
extension_SubscriberId: subscriberId,
|
|
399
|
+
emails: emails,
|
|
400
|
+
sub: sub,
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
searchParams?.set('hashToken', encodeJwt(hashTokenValue) as string);
|
|
404
|
+
setSearchParams(searchParams);
|
|
405
|
+
},
|
|
406
|
+
[emails, sub, searchParams, setSearchParams]
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
useEffect(() => {
|
|
410
|
+
if (!moduleMount.current && idTokenClaims) {
|
|
411
|
+
moduleMount.current = true;
|
|
412
|
+
const config = prepareConfig({
|
|
413
|
+
apiKey: API_KEY,
|
|
414
|
+
apiUrl: API_URL,
|
|
415
|
+
userId: userId || '',
|
|
416
|
+
subscriberId: userEmail || '',
|
|
417
|
+
identityProviderId: IDENTITY_PROVIDER_ID,
|
|
418
|
+
templatePackageId: TEMPLATE_PACKAGE_ID,
|
|
419
|
+
selfServiceUrl: SELF_SERVICE_URL,
|
|
420
|
+
organizationId: ORGANIZATION_ID,
|
|
421
|
+
userEmail: userEmail || '',
|
|
422
|
+
name: name,
|
|
423
|
+
city: city,
|
|
424
|
+
country: country,
|
|
425
|
+
postalCode: postalCode,
|
|
426
|
+
streetAddress: streetAddress,
|
|
427
|
+
journey: journey,
|
|
428
|
+
submitStartCallback: submitStartCallback,
|
|
429
|
+
});
|
|
430
|
+
orderComponent?.remove();
|
|
431
|
+
orderComponent?.init(config);
|
|
432
|
+
}
|
|
433
|
+
}, [userEmail, userId, name, city, country, postalCode, streetAddress, journey, submitStartCallback]);
|
|
434
|
+
|
|
435
|
+
return (
|
|
436
|
+
<div
|
|
437
|
+
id={ORDER_PLACE_ID}
|
|
438
|
+
className="w-100 order-wrapper"
|
|
439
|
+
data-testid="order-place-id"
|
|
440
|
+
/>
|
|
441
|
+
);
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
export default OrderPlace;
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
<!-- prettier-ignore -->
|
|
448
|
+
| Option | Default | Description |
|
|
449
|
+
| --------------------- | :----------------------------------------------------------------------------: | -------------------------: |
|
|
450
|
+
| moduleTitle | '' | module title |
|
|
451
|
+
| apiKey | '' | order api key |
|
|
452
|
+
| apiUrl | '' | order api url |
|
|
453
|
+
| templatePackageId | '' | template package id |
|
|
454
|
+
| subscriberId | '' | subscriber id |
|
|
455
|
+
| identityProviderId | '' | identity provider id |
|
|
456
|
+
| organizationId | '' | organization id |
|
|
457
|
+
| redirectUrl | window.location.href | redirect url |
|
|
458
|
+
| showIframe | false | show credit card in iframe |
|
|
459
|
+
| userActionCallback | undefined | function for tracking user actions |
|
|
460
|
+
| cancelVippsCallback | undefined | callback invoked when a Vipps/MobilePay payment is cancelled |
|
|
461
|
+
| paymentMethodsOptions | orderFormFields: [{name: 'phoneNumber', required: false, readOnly: false, label: ''}] | default form fields |
|
|
462
|
+
| availablePaymentMethods | [] | available payment methods to display |
|
|
463
|
+
| allowedPaymentMethods | [] | list of payment methods the subscriber is allowed to use |
|
|
464
|
+
| requireTermsAcceptance | false | when true, the user must accept terms and conditions before submitting |
|
|
465
|
+
| language | 'en-US' | language |
|
|
466
|
+
| merchantAgreementUrl | '' | vipps and MobilePay property |
|
|
467
|
+
| settings.paymentMethodElementId / settings.contactDetailsElementId | undefined | ids of host page elements to render the payment method / contact detail sections into, instead of inline |
|
|
468
|
+
| settings.submitConfirmation | undefined | `{ title, description?, confirmText, cancelText }` — shows a confirmation dialog before the order is submitted |
|
|
469
|
+
| settings.contactDetailsLabel | undefined | heading for the contact details section |
|
|
470
|
+
| settings.errorTermsMsg | undefined | validation message shown when terms are not accepted |
|
|
471
|
+
| settings | {successText: 'Order completed successfully!', failureText: 'Something went wrong!', submitButtonText: 'Start', backButtonText: 'Back', verifyButtonText: 'Verify', organizationNumberLabel: 'Organization Number', cvrLabel: 'CVR', glnLabel: 'GLN', paymentMethodLabel: 'Select Payment Method', orderDefaultValues: 'Default order form values', errorReqMsg: '', errorInvalidEmailMsg: '', errorInvalidPhoneMsg: '', errorValidationTitleMsg: 'One or more validation errors occurred.', errorValidationDenialOrderBlockingMsg: '...', errorValidationBlockingOffersMsg: '...', paymentMethodNotAllowedMsg: 'This payment method not allowed!', invoiceLookupNotFoundText: 'There was no recipient found for the given information', termsAndConditionsText: '' } | label and text properties |
|