@infosoftas/s4-orders-js-sdk 0.0.1-beta1.2 → 0.0.1-beta1.3

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 CHANGED
@@ -272,6 +272,7 @@ export const prepareConfig = ({
272
272
  errorInvalidEmailMsg: 'Invalid email address!',
273
273
  errorInvalidPhoneMsg: 'Invalid phone number!',
274
274
  paymentMethodNotAllowedMsg: 'This payment method not allowed!',
275
+ invoiceLookupNotFoundText: 'There was no recipient found for the given information',
275
276
  successText: 'Success message',
276
277
  failureText: 'Failed message',
277
278
  orderDefaultValues: {
@@ -372,4 +373,4 @@ export default OrderPlace;
372
373
  | availablePaymentMethods | [] | available payment methods |
373
374
  | language | 'en-US' | language |
374
375
  | merchantAgreementUrl | '' | vipps and MobilePay property |
375
- | settings | {successText: 'Order successful completed!',failureText: 'Something went wrong!',submitButtonText: 'Start',backButtonText: 'Back',verifyButtonText: 'Verify',organizationNumberLabel: 'CVR',glnLabel: 'GLN',paymentMethodLabel:'Select Payment Method', orderDefaultValues: 'Default order form values' } | label and text properties |
376
+ | settings | {successText: 'Order successful completed!',failureText: 'Something went wrong!',submitButtonText: 'Start',backButtonText: 'Back',verifyButtonText: 'Verify',organizationNumberLabel: 'CVR',glnLabel: 'GLN',paymentMethodLabel:'Select Payment Method', orderDefaultValues: 'Default order form values', paymentMethodNotAllowedMsg: 'This payment method not allowed!', invoiceLookupNotFoundText: 'There was no recipient found for the given information' } | label and text properties |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosoftas/s4-orders-js-sdk",
3
- "version": "0.0.1-beta1.2",
3
+ "version": "0.0.1-beta1.3",
4
4
  "scripts": {
5
5
  "build": "rimraf lib && webpack --env mode=production",
6
6
  "release": "release-it"
package/src/App.tsx CHANGED
@@ -59,6 +59,8 @@ const App: FC<ConfigType> = ({
59
59
  errorInvalidEmailMsg: '',
60
60
  errorInvalidPhoneMsg: '',
61
61
  paymentMethodNotAllowedMsg: '',
62
+ invoiceLookupNotFoundText:
63
+ 'There was no recipient found for the given information',
62
64
  },
63
65
  }) => {
64
66
  const [loading, setLoading] = useState<boolean>(false);
@@ -324,6 +326,9 @@ const App: FC<ConfigType> = ({
324
326
  invoiceAddressSelection={
325
327
  invoiceAddressSelection
326
328
  }
329
+ invoiceLookupNotFoundText={
330
+ settings?.invoiceLookupNotFoundText
331
+ }
327
332
  />
328
333
  )}
329
334
  {formType === FormTypeEnum.EHF && (
@@ -352,6 +357,9 @@ const App: FC<ConfigType> = ({
352
357
  invoiceAddressSelection={
353
358
  invoiceAddressSelection
354
359
  }
360
+ invoiceLookupNotFoundText={
361
+ settings?.invoiceLookupNotFoundText
362
+ }
355
363
  />
356
364
  )}
357
365
  {formType !== FormTypeEnum.OIO &&
@@ -41,6 +41,7 @@ type Props = {
41
41
  fields?: OrderFormFiledType[];
42
42
  paymentMethods?: PaymentMethodEnum[];
43
43
  };
44
+ invoiceLookupNotFoundText?: string;
44
45
  };
45
46
 
46
47
  type EHFFormInputsType = {
@@ -72,6 +73,7 @@ const EHFForm: FC<Props> = ({
72
73
  orderValues,
73
74
  paymentMethodsOptions,
74
75
  invoiceAddressSelection,
76
+ invoiceLookupNotFoundText,
75
77
  }) => {
76
78
  const methods = useForm<EHFFormInputsType>({
77
79
  defaultValues: {
@@ -108,6 +110,7 @@ const EHFForm: FC<Props> = ({
108
110
  templatePackageId,
109
111
  invoiceAddressToggle: orderValues?.invoiceAddressSelection,
110
112
  invoiceOrderFields,
113
+ invoiceLookupNotFoundText,
111
114
  });
112
115
 
113
116
  const onSubmit: SubmitHandler<EHFFormInputsType> = async (
@@ -42,6 +42,7 @@ type Props = {
42
42
  fields?: OrderFormFiledType[];
43
43
  paymentMethods?: PaymentMethodEnum[];
44
44
  };
45
+ invoiceLookupNotFoundText?: string;
45
46
  };
46
47
 
47
48
  type OIOFormInputsType = {
@@ -76,6 +77,7 @@ const EHFForm: FC<Props> = ({
76
77
  orderValues,
77
78
  paymentMethodsOptions,
78
79
  invoiceAddressSelection,
80
+ invoiceLookupNotFoundText,
79
81
  }) => {
80
82
  const methods = useForm<OIOFormInputsType>({
81
83
  defaultValues: {
@@ -116,6 +118,7 @@ const EHFForm: FC<Props> = ({
116
118
  templatePackageId,
117
119
  invoiceAddressToggle: orderValues?.invoiceAddressSelection,
118
120
  invoiceOrderFields,
121
+ invoiceLookupNotFoundText,
119
122
  });
120
123
 
121
124
  const onSubmit: SubmitHandler<OIOFormInputsType> = async (
@@ -38,6 +38,7 @@ type Props = {
38
38
  orderFields: OrderFormFiledType[];
39
39
  invoiceAddressToggle?: boolean;
40
40
  invoiceOrderFields: OrderFormFiledType[];
41
+ invoiceLookupNotFoundText?: string;
41
42
  };
42
43
 
43
44
  const useOrderForm = ({
@@ -56,6 +57,7 @@ const useOrderForm = ({
56
57
  templatePackageId,
57
58
  invoiceAddressToggle,
58
59
  invoiceOrderFields,
60
+ invoiceLookupNotFoundText,
59
61
  }: Props) => {
60
62
  const [loading, setLoading] = useState<boolean>(false);
61
63
  const [apiErrorMsg, setApiErrorMsg] = useState<string>('');
@@ -69,8 +71,9 @@ const useOrderForm = ({
69
71
  setLoading(true);
70
72
  try {
71
73
  let id: string | undefined = subscriberId;
74
+ let invoiceResponse = null;
72
75
  if (data.paymentMethod === PaymentMethodEnum.OIO) {
73
- await invoiceLookup({
76
+ invoiceResponse = await invoiceLookup({
74
77
  network: data.gln
75
78
  ? InvoiceLookupNetworkEnum.OIO_GLN
76
79
  : InvoiceLookupNetworkEnum.OIO_Danish_CVR,
@@ -78,12 +81,22 @@ const useOrderForm = ({
78
81
  });
79
82
  }
80
83
  if (data.paymentMethod === PaymentMethodEnum.EHF) {
81
- await invoiceLookup({
84
+ invoiceResponse = await invoiceLookup({
82
85
  network: InvoiceLookupNetworkEnum.EHF,
83
86
  value: data.organizationNumber || '',
84
87
  });
85
88
  }
86
89
 
90
+ if (invoiceResponse && !invoiceResponse?.recievesInvoice) {
91
+ setLoading(false);
92
+ const value =
93
+ data.paymentMethod === PaymentMethodEnum.OIO
94
+ ? data.gln || data.cvr || ''
95
+ : data.organizationNumber || '';
96
+ setApiErrorMsg(`${invoiceLookupNotFoundText || ''} (${value})`);
97
+ return;
98
+ }
99
+
87
100
  const contactModel = prepareContactModel({ data, orderFields });
88
101
  if (!subscriberId) {
89
102
  const response = await createSubscriber({
@@ -61,6 +61,7 @@ export type ConfigType = {
61
61
  errorInvalidEmailMsg?: string;
62
62
  errorInvalidPhoneMsg?: string;
63
63
  paymentMethodNotAllowedMsg?: string;
64
+ invoiceLookupNotFoundText?: string;
64
65
  };
65
66
  };
66
67