@infosoftas/s4-orders-js-sdk 0.2.0 → 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.
Files changed (68) hide show
  1. package/.editorconfig +8 -8
  2. package/.release-it.json +10 -10
  3. package/README.md +13 -6
  4. package/build/postcss-scope-tailwind.cjs +0 -0
  5. package/components.json +0 -0
  6. package/package.json +1 -1
  7. package/src/App.completion.test.tsx +46 -107
  8. package/src/App.css +0 -14
  9. package/src/App.paymentReturn.test.tsx +341 -0
  10. package/src/App.tsx +20 -51
  11. package/src/ErrorBoundary.tsx +41 -41
  12. package/src/api/InvoiceApi.ts +23 -23
  13. package/src/api/SubscribeApi.ts +18 -18
  14. package/src/bundle.ts +4 -4
  15. package/src/components/Alert/Alert.tsx +23 -23
  16. package/src/components/Button/Button.tsx +39 -39
  17. package/src/components/EHFForm/EHFForm.tsx +0 -3
  18. package/src/components/FormFields/AddressField.tsx +55 -55
  19. package/src/components/FormFields/EmailField.tsx +53 -53
  20. package/src/components/FormFields/FormFields.helper.ts +34 -34
  21. package/src/components/FormFields/FormFieldsMapper.ts +34 -34
  22. package/src/components/FormFields/InputField.tsx +52 -52
  23. package/src/components/FormFields/NameField.tsx +52 -52
  24. package/src/components/FormFields/PhoneField.tsx +53 -53
  25. package/src/components/FormFields/TermsCheckbox.tsx +70 -70
  26. package/src/components/FormFields/ToggleFiled.tsx +52 -52
  27. package/src/components/FormFields/fieldValidators.ts +71 -71
  28. package/src/components/OIOForm/OIOForm.tsx +0 -3
  29. package/src/components/OrderDenialModal/OrderDenialModal.tsx +102 -102
  30. package/src/components/OrderForm/ContactDetailsSection.tsx +71 -71
  31. package/src/components/OrderForm/OrderForm.tsx +0 -3
  32. package/src/components/OrderForm/PaymentMethodContent.tsx +62 -62
  33. package/src/components/OrderForm/PaymentMethodSection.tsx +79 -79
  34. package/src/components/OrderForm/SubmitConfirmationDialog.tsx +55 -55
  35. package/src/components/OrderForm/orderFormState.ts +171 -171
  36. package/src/components/OrderForm/useSlotElement.tsx +89 -89
  37. package/src/components/ui/alert-dialog.tsx +0 -0
  38. package/src/components/ui/alert.tsx +0 -0
  39. package/src/components/ui/button.tsx +0 -0
  40. package/src/components/ui/card.tsx +0 -0
  41. package/src/components/ui/checkbox.tsx +0 -0
  42. package/src/components/ui/field.tsx +0 -0
  43. package/src/components/ui/input.tsx +0 -0
  44. package/src/components/ui/label.tsx +0 -0
  45. package/src/components/ui/radio-group.tsx +0 -0
  46. package/src/components/ui/separator.tsx +0 -0
  47. package/src/components/ui/skeleton.tsx +0 -0
  48. package/src/components/ui/spinner.tsx +0 -0
  49. package/src/components/ui/switch.tsx +0 -0
  50. package/src/components/ui/textarea.tsx +0 -0
  51. package/src/constants/index.ts +13 -13
  52. package/src/custom.d.ts +0 -0
  53. package/src/enums/api.ts +5 -5
  54. package/src/enums/general.ts +4 -2
  55. package/src/hooks/useOrderForm.tsx +0 -3
  56. package/src/hooks/usePaymentReturn.tsx +139 -0
  57. package/src/hooks/useQueryParams.ts +5 -5
  58. package/src/index.tsx +30 -30
  59. package/src/lib/utils.ts +1 -1
  60. package/src/types/api.ts +28 -28
  61. package/src/types/general.ts +0 -1
  62. package/src/utils/helper.ts +78 -78
  63. package/src/utils/order.helper.test.ts +81 -0
  64. package/src/utils/order.helper.ts +38 -25
  65. package/tsconfig.json +1 -0
  66. package/src/components/MainIframe/MainIframe.tsx +0 -42
  67. package/src/hooks/useIframe.tsx +0 -59
  68. package/src/hooks/useMessageEvent.tsx +0 -194
package/.editorconfig CHANGED
@@ -1,8 +1,8 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = space
5
- indent_size = 4
6
- charset = utf-8
7
- trim_trailing_whitespace = true
8
- insert_final_newline = true
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 4
6
+ charset = utf-8
7
+ trim_trailing_whitespace = true
8
+ insert_final_newline = true
package/.release-it.json CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "$schema": "https://unpkg.com/release-it/schema/release-it.json",
3
- "git": {
4
- "changelog": "",
5
- "requireBranch": "release/*"
6
- },
7
- "github": {
8
- "release": true
9
- }
10
- }
1
+ {
2
+ "$schema": "https://unpkg.com/release-it/schema/release-it.json",
3
+ "git": {
4
+ "changelog": "",
5
+ "requireBranch": "release/*"
6
+ },
7
+ "github": {
8
+ "release": true
9
+ }
10
+ }
package/README.md CHANGED
@@ -62,7 +62,17 @@ verification and show the same received message with callback reason
62
62
  `Cancelled` and `Rejected` instead show `failureText` and invoke
63
63
  `orderCompletionFailedCallback` with the returned status, without reopening
64
64
  submission. Removing the SDK or switching orders aborts outstanding reads.
65
- Duplicate payment-return messages do not repeat an accepted completion POST.
65
+ An accepted completion POST is not repeated for the same order.
66
+
67
+ ### Payment returns
68
+
69
+ All online payment methods (Vipps, MobilePay, SwedbankPay and Mollie) use
70
+ full-page redirects to the provider. The provider returns to `redirectUrl`
71
+ (default: the current page), and the SDK reads the return from the URL
72
+ parameters (`action=complete`/`action=cancel` with `S4OrderId`, or Vipps'
73
+ `orderId` and `agreementId`). The SDK never completes or cancels an order
74
+ because of a browser `message` event. It only posts its own notifications
75
+ (`orderFlowComplete`, `orderFlowCancel`, `orderUpdateInfo`) to the host page.
66
76
 
67
77
  ### Callbacks and external confirmation
68
78
 
@@ -90,8 +100,8 @@ Use an acceptance callback to hand off confirmation to the host. There is
90
100
  no automatic success fallback when polling is disabled.
91
101
 
92
102
  **Migration:** `orderFlowComplete` now means confirmed order completion, not
93
- POST acceptance. Consumers must not treat raw payment-provider return messages
94
- such as `completeOrder` as success. Trigger success UI, conversion tracking and
103
+ POST acceptance. Consumers must not treat payment-provider returns as success.
104
+ Trigger success UI, conversion tracking and
95
105
  redirects only from confirmed completion. No consumer-side poller is needed
96
106
  when using the default mode.
97
107
 
@@ -179,7 +189,6 @@ type ConfigType = {
179
189
  identityProviderId: string;
180
190
  organizationId: string;
181
191
  redirectUrl?: string;
182
- showIframe?: boolean;
183
192
  /**
184
193
  * The full list of payment methods displayed in the UI, each with a display label and value.
185
194
  * Controls what the user sees in the payment method selector.
@@ -316,7 +325,6 @@ export const prepareConfig = ({
316
325
  domElementId: ORDER_PLACE_ID,
317
326
  redirectUrl: window.location.href,
318
327
  merchantAgreementUrl: selfServiceUrl,
319
- showIframe: true,
320
328
  apiKey,
321
329
  apiUrl,
322
330
  userId,
@@ -549,7 +557,6 @@ export default OrderPlace;
549
557
  | identityProviderId | '' | identity provider id |
550
558
  | organizationId | '' | organization id |
551
559
  | redirectUrl | window.location.href | redirect url |
552
- | showIframe | false | show credit card in iframe |
553
560
  | userActionCallback | undefined | function for tracking user actions |
554
561
  | cancelVippsCallback | undefined | callback invoked when a Vipps/MobilePay payment is cancelled |
555
562
  | paymentMethodsOptions | orderFormFields: [{name: 'phoneNumber', required: false, readOnly: false, label: ''}] | default form fields |
File without changes
package/components.json CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosoftas/s4-orders-js-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "scripts": {
5
5
  "build": "tsc --noEmit && webpack --mode production",
6
6
  "test": "vitest run",
@@ -14,21 +14,24 @@ import { MessageEventTypeEnum } from './enums/general';
14
14
  import type { ConfigType } from './types/general';
15
15
  import type { OrderInfoType } from './types/order';
16
16
 
17
+ const submission = vi.hoisted(() => ({
18
+ url: null as string | null,
19
+ data: {
20
+ orderId: 'invoice-order',
21
+ paymentMethod: 'Invoice',
22
+ subscriberId: 'subscriber-7',
23
+ } as OrderInfoType,
24
+ }));
25
+
26
+ const invoiceSubmission = submission.data;
27
+
17
28
  vi.mock('./components/OrderForm/OrderForm', () => ({
18
29
  default: ({
19
30
  callback,
20
31
  }: {
21
32
  callback: (url: string | null, data: OrderInfoType) => void;
22
33
  }) => (
23
- <button
24
- onClick={() =>
25
- callback(null, {
26
- orderId: 'invoice-order',
27
- paymentMethod: 'Invoice',
28
- subscriberId: 'subscriber-7',
29
- })
30
- }
31
- >
34
+ <button onClick={() => callback(submission.url, submission.data)}>
32
35
  Submit invoice
33
36
  </button>
34
37
  ),
@@ -62,17 +65,17 @@ const renderApp = (props: Partial<ConfigType> = {}) =>
62
65
  />
63
66
  );
64
67
 
68
+ // A SwedbankPay full-page return. Must be set before the SDK mounts, because
69
+ // returns are read from the URL on load.
65
70
  const paymentReturn = () =>
66
- window.dispatchEvent(
67
- new MessageEvent('message', {
68
- data: {
69
- type: MessageEventTypeEnum.COMPLETE,
70
- orderId: 'returned-order',
71
- agreementId: 'agreement-3',
72
- },
73
- })
71
+ window.history.replaceState(
72
+ {},
73
+ '',
74
+ '/?action=complete&S4OrderId=returned-order&TransactionId=agreement-3'
74
75
  );
75
76
 
77
+ const methods = () => fetchMock.mock.calls.map(([, init]) => init?.method);
78
+
76
79
  const advance = async (ms = 0) => {
77
80
  await act(async () => {
78
81
  await vi.advanceTimersByTimeAsync(ms);
@@ -96,6 +99,8 @@ describe('SDK-managed order completion', () => {
96
99
  window.history.replaceState({}, '', '/');
97
100
  sessionStorage.clear();
98
101
  localStorage.clear();
102
+ submission.url = null;
103
+ submission.data = invoiceSubmission;
99
104
  vi.spyOn(window, 'postMessage').mockImplementation(() => undefined);
100
105
  vi.spyOn(console, 'log').mockImplementation(() => undefined);
101
106
  });
@@ -119,12 +124,12 @@ describe('SDK-managed order completion', () => {
119
124
  response({ id: 'returned-order', status: 'Completed' })
120
125
  );
121
126
  const orderAcceptedCallback = vi.fn();
127
+ paymentReturn();
122
128
  renderApp({
123
129
  orderAcceptedCallback,
124
130
  userId: 'user-9',
125
131
  identityProviderId: 'identity-2',
126
132
  });
127
- act(paymentReturn);
128
133
  await advance();
129
134
 
130
135
  expect(screen.queryByText('Order completed')).toBeNull();
@@ -170,8 +175,8 @@ describe('SDK-managed order completion', () => {
170
175
  })
171
176
  );
172
177
  const orderCompletionDelayedCallback = vi.fn();
178
+ paymentReturn();
173
179
  renderApp({ orderCompletionDelayedCallback });
174
- act(paymentReturn);
175
180
  await advance(9999);
176
181
  expect(
177
182
  screen.queryByText('Order received, taking longer than expected')
@@ -191,8 +196,6 @@ describe('SDK-managed order completion', () => {
191
196
  expect(completionMessages()).toHaveLength(0);
192
197
  const calls = fetchMock.mock.calls.length;
193
198
  await advance(20000);
194
- act(paymentReturn);
195
- await advance();
196
199
  expect(fetchMock).toHaveBeenCalledTimes(calls);
197
200
  });
198
201
 
@@ -205,8 +208,8 @@ describe('SDK-managed order completion', () => {
205
208
  })
206
209
  );
207
210
  const orderCompletionDelayedCallback = vi.fn();
211
+ paymentReturn();
208
212
  renderApp({ orderCompletionDelayedCallback });
209
- act(paymentReturn);
210
213
  await advance();
211
214
  await advance(10000);
212
215
  expect(
@@ -225,8 +228,8 @@ describe('SDK-managed order completion', () => {
225
228
  it('lets external mode receive acceptance without polling or announcing success', async () => {
226
229
  fetchMock.mockResolvedValueOnce(response(null));
227
230
  const orderAcceptedCallback = vi.fn();
231
+ paymentReturn();
228
232
  renderApp({ completionMode: 'external', orderAcceptedCallback });
229
- act(paymentReturn);
230
233
  await advance(20000);
231
234
  expect(orderAcceptedCallback).toHaveBeenCalledExactlyOnceWith({
232
235
  orderId: 'returned-order',
@@ -247,8 +250,8 @@ describe('SDK-managed order completion', () => {
247
250
  response({ id: 'returned-order', status })
248
251
  );
249
252
  const orderCompletionFailedCallback = vi.fn();
253
+ paymentReturn();
250
254
  renderApp({ orderCompletionFailedCallback });
251
- act(paymentReturn);
252
255
  await advance(10000);
253
256
  expect(screen.getByText('Order failed')).toBeTruthy();
254
257
  expect(
@@ -266,7 +269,7 @@ describe('SDK-managed order completion', () => {
266
269
  }
267
270
  );
268
271
 
269
- it('does not overlap reads or repeat POST for duplicate payment returns', async () => {
272
+ it('does not overlap status reads while one is pending', async () => {
270
273
  let finish!: (value: Response) => void;
271
274
  fetchMock
272
275
  .mockResolvedValueOnce(response(null))
@@ -279,11 +282,8 @@ describe('SDK-managed order completion', () => {
279
282
  .mockResolvedValueOnce(
280
283
  response({ id: 'returned-order', status: 'Completed' })
281
284
  );
285
+ paymentReturn();
282
286
  renderApp();
283
- act(() => {
284
- paymentReturn();
285
- paymentReturn();
286
- });
287
287
  await advance(1500);
288
288
  expect(fetchMock).toHaveBeenCalledTimes(2);
289
289
  await act(async () => {
@@ -293,9 +293,8 @@ describe('SDK-managed order completion', () => {
293
293
  expect(fetchMock).toHaveBeenCalledTimes(2);
294
294
  await advance(1);
295
295
  expect(screen.getByText('Order completed')).toBeTruthy();
296
- act(paymentReturn);
297
- await advance();
298
296
  expect(fetchMock).toHaveBeenCalledTimes(3);
297
+ expect(methods()).toEqual(['POST', 'GET', 'GET']);
299
298
  expect(completionMessages()).toHaveLength(1);
300
299
  });
301
300
 
@@ -308,8 +307,8 @@ describe('SDK-managed order completion', () => {
308
307
  })
309
308
  );
310
309
  const orderCompletionDelayedCallback = vi.fn();
310
+ paymentReturn();
311
311
  const view = renderApp({ orderCompletionDelayedCallback });
312
- act(paymentReturn);
313
312
  await advance();
314
313
  view.unmount();
315
314
  expect(fetchMock.mock.calls[1][1]?.signal?.aborted).toBe(true);
@@ -321,7 +320,7 @@ describe('SDK-managed order completion', () => {
321
320
  expect(completionMessages()).toHaveLength(0);
322
321
  });
323
322
 
324
- it('uses invoice submission ID and order information without requiring payment messages', async () => {
323
+ it('uses invoice submission ID and order information without a payment return', async () => {
325
324
  fetchMock
326
325
  .mockResolvedValueOnce(response(null))
327
326
  .mockResolvedValueOnce(
@@ -355,8 +354,8 @@ describe('SDK-managed order completion', () => {
355
354
  )
356
355
  );
357
356
  const orderAcceptedCallback = vi.fn();
357
+ paymentReturn();
358
358
  renderApp({ orderAcceptedCallback });
359
- act(paymentReturn);
360
359
  await advance();
361
360
  expect(screen.getByText('Invalid order')).toBeTruthy();
362
361
  expect(screen.getByText('Email is invalid')).toBeTruthy();
@@ -398,8 +397,8 @@ describe('SDK-managed order completion', () => {
398
397
  .mockResolvedValueOnce(
399
398
  response({ id: 'returned-order', status: 'Completed' })
400
399
  );
400
+ paymentReturn();
401
401
  renderApp();
402
- act(paymentReturn);
403
402
  await advance(1499);
404
403
  expect(completionMessages()).toHaveLength(0);
405
404
  await advance(1);
@@ -420,8 +419,8 @@ describe('SDK-managed order completion', () => {
420
419
  .mockResolvedValueOnce(
421
420
  response({ id: 'returned-order', status: 'Completed' })
422
421
  );
422
+ paymentReturn();
423
423
  renderApp();
424
- act(paymentReturn);
425
424
  await advance(1999);
426
425
  expect(fetchMock).toHaveBeenCalledTimes(2);
427
426
  expect(completionMessages()).toHaveLength(0);
@@ -436,8 +435,8 @@ describe('SDK-managed order completion', () => {
436
435
  response(null, 429, { 'Retry-After': '60' })
437
436
  );
438
437
  const orderCompletionDelayedCallback = vi.fn();
438
+ paymentReturn();
439
439
  renderApp({ orderCompletionDelayedCallback });
440
- act(paymentReturn);
441
440
  await advance(10000);
442
441
  expect(
443
442
  screen.getByText('Order received, taking longer than expected')
@@ -451,8 +450,8 @@ describe('SDK-managed order completion', () => {
451
450
  fetchMock
452
451
  .mockResolvedValueOnce(response(null))
453
452
  .mockResolvedValueOnce(response(null, 429));
453
+ paymentReturn();
454
454
  renderApp();
455
- act(paymentReturn);
456
455
  await advance(9999);
457
456
  expect(fetchMock).toHaveBeenCalledTimes(2);
458
457
  await advance(1);
@@ -474,8 +473,8 @@ describe('SDK-managed order completion', () => {
474
473
  response({ id: 'returned-order', status: 'Completed' })
475
474
  );
476
475
  const orderCompletionDelayedCallback = vi.fn();
476
+ paymentReturn();
477
477
  renderApp({ orderCompletionDelayedCallback });
478
- act(paymentReturn);
479
478
  await advance(9999);
480
479
  expect(fetchMock).toHaveBeenCalledTimes(2);
481
480
  expect(orderCompletionDelayedCallback).not.toHaveBeenCalled();
@@ -508,11 +507,11 @@ describe('SDK-managed order completion', () => {
508
507
  .mockResolvedValueOnce(new Response(body, { status }));
509
508
  const orderCompletionDelayedCallback = vi.fn();
510
509
  const orderCompletionFailedCallback = vi.fn();
510
+ paymentReturn();
511
511
  renderApp({
512
512
  orderCompletionDelayedCallback,
513
513
  orderCompletionFailedCallback,
514
514
  });
515
- act(paymentReturn);
516
515
  await advance(10000);
517
516
  expect(
518
517
  orderCompletionDelayedCallback
@@ -542,8 +541,8 @@ describe('SDK-managed order completion', () => {
542
541
  .mockResolvedValueOnce(response(null))
543
542
  .mockResolvedValueOnce(response(body));
544
543
  const orderCompletionDelayedCallback = vi.fn();
544
+ paymentReturn();
545
545
  renderApp({ orderCompletionDelayedCallback });
546
- act(paymentReturn);
547
546
  await advance(10000);
548
547
  expect(
549
548
  screen.getByText('Order received, taking longer than expected')
@@ -569,8 +568,8 @@ describe('SDK-managed order completion', () => {
569
568
  .mockResolvedValueOnce(
570
569
  response({ id: 'returned-order', status: 'Completed' })
571
570
  );
571
+ paymentReturn();
572
572
  renderApp();
573
- act(paymentReturn);
574
573
  await advance();
575
574
  expect(fetchMock).toHaveBeenCalledTimes(2);
576
575
  await advance(500);
@@ -592,8 +591,8 @@ describe('SDK-managed order completion', () => {
592
591
  response({ id: 'returned-order', status: 'Completed' })
593
592
  );
594
593
  const orderCompletionDelayedCallback = vi.fn();
594
+ paymentReturn();
595
595
  renderApp({ orderCompletionDelayedCallback });
596
- act(paymentReturn);
597
596
  await advance(10000);
598
597
  expect(
599
598
  orderCompletionDelayedCallback
@@ -607,24 +606,6 @@ describe('SDK-managed order completion', () => {
607
606
  }
608
607
  );
609
608
 
610
- it('clears the loading skeleton when a pending POST is aborted by cancel', async () => {
611
- fetchMock.mockImplementationOnce(() => new Promise(() => undefined));
612
- fetchMock.mockResolvedValue(response(null));
613
- renderApp();
614
- act(paymentReturn);
615
- await advance();
616
- expect(screen.getByTestId('sdk-order-loading-skeleton')).toBeTruthy();
617
- act(() =>
618
- window.dispatchEvent(
619
- new MessageEvent('message', {
620
- data: { type: MessageEventTypeEnum.CANCEL },
621
- })
622
- )
623
- );
624
- await advance();
625
- expect(screen.queryByTestId('sdk-order-loading-skeleton')).toBeNull();
626
- });
627
-
628
609
  it('isolates host callback failures from accepted order state and polling', async () => {
629
610
  vi.spyOn(console, 'error').mockImplementation(() => undefined);
630
611
  fetchMock
@@ -632,6 +613,7 @@ describe('SDK-managed order completion', () => {
632
613
  .mockResolvedValueOnce(
633
614
  response({ id: 'returned-order', status: 'Completed' })
634
615
  );
616
+ paymentReturn();
635
617
  renderApp({
636
618
  orderAcceptedCallback: () => {
637
619
  throw new Error('Host callback error');
@@ -640,7 +622,6 @@ describe('SDK-managed order completion', () => {
640
622
  throw new Error('Async callback error');
641
623
  },
642
624
  });
643
- act(paymentReturn);
644
625
  await advance();
645
626
  expect(screen.getByText('Order completed')).toBeTruthy();
646
627
  expect(
@@ -652,9 +633,9 @@ describe('SDK-managed order completion', () => {
652
633
  it('does not start status reads after acceptance callback unmounts SDK', async () => {
653
634
  fetchMock.mockResolvedValueOnce(response(null));
654
635
  let unmount!: () => void;
636
+ paymentReturn();
655
637
  const view = renderApp({ orderAcceptedCallback: () => unmount() });
656
638
  unmount = view.unmount;
657
- act(paymentReturn);
658
639
  await advance(10000);
659
640
  expect(fetchMock).toHaveBeenCalledTimes(1);
660
641
  expect(completionMessages()).toHaveLength(0);
@@ -669,8 +650,8 @@ describe('SDK-managed order completion', () => {
669
650
  })
670
651
  );
671
652
  const orderAcceptedCallback = vi.fn();
653
+ paymentReturn();
672
654
  const view = renderApp({ orderAcceptedCallback });
673
- act(paymentReturn);
674
655
  view.unmount();
675
656
  await act(async () => {
676
657
  finish(response(null));
@@ -681,54 +662,12 @@ describe('SDK-managed order completion', () => {
681
662
  expect(completionMessages()).toHaveLength(0);
682
663
  });
683
664
 
684
- it('ignores an old status response after cancelling and starting another order', async () => {
685
- let finish!: (value: Response) => void;
686
- fetchMock
687
- .mockResolvedValueOnce(response(null))
688
- .mockImplementationOnce(
689
- () =>
690
- new Promise((resolve) => {
691
- finish = resolve;
692
- })
693
- )
694
- .mockResolvedValueOnce(response(null))
695
- .mockResolvedValueOnce(response(null))
696
- .mockResolvedValueOnce(
697
- response({ id: 'invoice-order', status: 'Completed' })
698
- );
699
- renderApp();
700
- act(paymentReturn);
701
- await advance();
702
- act(() =>
703
- window.dispatchEvent(
704
- new MessageEvent('message', {
705
- data: { type: MessageEventTypeEnum.CANCEL },
706
- })
707
- )
708
- );
709
- await advance();
710
- expect(fetchMock.mock.calls[1][1]?.signal?.aborted).toBe(true);
711
- expect(fetchMock.mock.calls[2][0]).toBe(
712
- 'https://orders.example.test/order/returned-order'
713
- );
714
- expect(fetchMock.mock.calls[2][1]?.method).toBe('DELETE');
715
- fireEvent.click(screen.getByRole('button', { name: 'Submit invoice' }));
716
- await advance();
717
- await act(async () => {
718
- finish(response({ id: 'returned-order', status: 'Completed' }));
719
- });
720
- expect(completionMessages()).toEqual([
721
- expect.objectContaining({ orderId: 'invoice-order' }),
722
- ]);
723
- expect(screen.getByText('Order completed')).toBeTruthy();
724
- });
725
-
726
665
  it('shows a useful delayed message even when settings contain no custom polling text', async () => {
727
666
  fetchMock.mockImplementation(async () =>
728
667
  response({ id: 'returned-order', status: 'InProgress' })
729
668
  );
669
+ paymentReturn();
730
670
  renderApp({ settings: {} });
731
- act(paymentReturn);
732
671
  await advance(10000);
733
672
  expect(screen.getByRole('status').textContent).toContain(
734
673
  'Your order was received, but things are taking longer than expected.'
package/src/App.css CHANGED
@@ -263,7 +263,6 @@
263
263
  .sdk-scope video,
264
264
  .sdk-scope canvas,
265
265
  .sdk-scope audio,
266
- .sdk-scope iframe,
267
266
  .sdk-scope embed,
268
267
  .sdk-scope object {
269
268
  display: block;
@@ -393,17 +392,4 @@
393
392
  *::after {
394
393
  box-sizing: border-box;
395
394
  }
396
-
397
- .sdk-iframe-wrapper {
398
- display: flex;
399
- flex-direction: column;
400
- align-items: center;
401
- }
402
-
403
- iframe {
404
- max-width: 640px;
405
- border: none;
406
- background: transparent;
407
- border-radius: calc(var(--radius) * 2);
408
- }
409
395
  }