@rebilly/instruments 4.8.1 → 4.8.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.
Files changed (139) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.min.js +1 -1
  4. package/package.json +5 -1
  5. package/.babelrc +0 -26
  6. package/project.json +0 -31
  7. package/rollup.config.mjs +0 -79
  8. package/src/data/options-schema/index.js +0 -112
  9. package/src/data/options-schema/schemas/options-schema.js +0 -448
  10. package/src/events/base-event.js +0 -47
  11. package/src/events/events.spec.js +0 -11
  12. package/src/events/index.js +0 -15
  13. package/src/functions/destroy.js +0 -29
  14. package/src/functions/destroy.spec.js +0 -63
  15. package/src/functions/mount/fetch-data.js +0 -236
  16. package/src/functions/mount/fetch-data.spec.js +0 -317
  17. package/src/functions/mount/get-lead-source-data.js +0 -46
  18. package/src/functions/mount/get-lead-source-data.spec.js +0 -38
  19. package/src/functions/mount/index.js +0 -105
  20. package/src/functions/mount/mount.spec.js +0 -96
  21. package/src/functions/mount/setup-element.js +0 -29
  22. package/src/functions/mount/setup-framepay-theme.js +0 -104
  23. package/src/functions/mount/setup-framepay.js +0 -26
  24. package/src/functions/mount/setup-i18n.js +0 -21
  25. package/src/functions/mount/setup-options.js +0 -100
  26. package/src/functions/mount/setup-options.spec.js +0 -353
  27. package/src/functions/mount/setup-storefront.js +0 -23
  28. package/src/functions/mount/setup-styles-vars.js +0 -30
  29. package/src/functions/mount/setup-user-flow.js +0 -60
  30. package/src/functions/on.js +0 -22
  31. package/src/functions/on.spec.js +0 -75
  32. package/src/functions/purchase.js +0 -173
  33. package/src/functions/purchase.spec.js +0 -80
  34. package/src/functions/setup.js +0 -66
  35. package/src/functions/setup.spec.js +0 -111
  36. package/src/functions/show.js +0 -30
  37. package/src/functions/show.spec.js +0 -62
  38. package/src/functions/update.js +0 -40
  39. package/src/functions/update.spec.js +0 -104
  40. package/src/i18n/en.json +0 -35
  41. package/src/i18n/es.json +0 -32
  42. package/src/i18n/i18n.spec.js +0 -27
  43. package/src/i18n/index.js +0 -59
  44. package/src/index.js +0 -3
  45. package/src/instance.js +0 -48
  46. package/src/instance.spec.js +0 -44
  47. package/src/loader/index.js +0 -145
  48. package/src/loader/loader.spec.js +0 -74
  49. package/src/state/iframes.js +0 -23
  50. package/src/state/index.js +0 -64
  51. package/src/storefront/account-and-website.js +0 -18
  52. package/src/storefront/account-and-website.spec.js +0 -73
  53. package/src/storefront/deposit-requests.js +0 -12
  54. package/src/storefront/fetch-plans-from-addons-bumpOffer.js +0 -30
  55. package/src/storefront/fetch-products-from-plans.js +0 -59
  56. package/src/storefront/fetch-products-from-plans.spec.js +0 -113
  57. package/src/storefront/index.js +0 -78
  58. package/src/storefront/invoices.js +0 -23
  59. package/src/storefront/invoices.spec.js +0 -92
  60. package/src/storefront/models/account-model.js +0 -36
  61. package/src/storefront/models/base-model.js +0 -7
  62. package/src/storefront/models/deposit-request-model.js +0 -24
  63. package/src/storefront/models/invoice-model.js +0 -20
  64. package/src/storefront/models/payment-metadata.js +0 -7
  65. package/src/storefront/models/plan-model.js +0 -94
  66. package/src/storefront/models/product-model.js +0 -3
  67. package/src/storefront/models/ready-to-pay-model.js +0 -76
  68. package/src/storefront/models/summary-model.js +0 -56
  69. package/src/storefront/models/transaction-model.js +0 -16
  70. package/src/storefront/models/website-model.js +0 -3
  71. package/src/storefront/payment-instruments.js +0 -47
  72. package/src/storefront/payment-instruments.spec.js +0 -88
  73. package/src/storefront/purchase.js +0 -60
  74. package/src/storefront/purchase.spec.js +0 -53
  75. package/src/storefront/ready-to-pay.js +0 -96
  76. package/src/storefront/ready-to-pay.spec.js +0 -76
  77. package/src/storefront/storefront.spec.js +0 -14
  78. package/src/storefront/summary.js +0 -114
  79. package/src/storefront/summary.spec.js +0 -136
  80. package/src/storefront/transactions.js +0 -12
  81. package/src/style/base/__snapshots__/theme.spec.js.snap +0 -143
  82. package/src/style/base/default-theme.js +0 -955
  83. package/src/style/base/index.js +0 -688
  84. package/src/style/base/theme.js +0 -30
  85. package/src/style/base/theme.spec.js +0 -19
  86. package/src/style/index.js +0 -11
  87. package/src/style/utils/border.js +0 -47
  88. package/src/style/utils/color-values.js +0 -35
  89. package/src/style/utils/minifyCss.js +0 -14
  90. package/src/utils/add-dom-element.js +0 -17
  91. package/src/utils/format-currency.js +0 -8
  92. package/src/utils/has-valid-css-selector.js +0 -4
  93. package/src/utils/index.js +0 -15
  94. package/src/utils/is-dom-element.js +0 -3
  95. package/src/utils/process-property-as-dom-element.js +0 -31
  96. package/src/utils/quantity.js +0 -47
  97. package/src/utils/sleep.js +0 -5
  98. package/src/views/amount-selector.js +0 -46
  99. package/src/views/common/iframe/base-iframe.js +0 -66
  100. package/src/views/common/iframe/events/change-iframe-src-handler.js +0 -6
  101. package/src/views/common/iframe/events/dispatch-event-handler.js +0 -8
  102. package/src/views/common/iframe/events/resize-component-handler.js +0 -9
  103. package/src/views/common/iframe/events/show-error-handler.js +0 -5
  104. package/src/views/common/iframe/events/stop-loader-handler.js +0 -9
  105. package/src/views/common/iframe/events/update-addons-handler.js +0 -23
  106. package/src/views/common/iframe/events/update-coupons-handler.js +0 -12
  107. package/src/views/common/iframe/events/update-items-handler.js +0 -34
  108. package/src/views/common/iframe/index.js +0 -5
  109. package/src/views/common/iframe/modal-iframe.js +0 -82
  110. package/src/views/common/iframe/view-iframe.js +0 -23
  111. package/src/views/common/render-utilities.js +0 -4
  112. package/src/views/confirmation.js +0 -45
  113. package/src/views/errors.js +0 -115
  114. package/src/views/form.js +0 -61
  115. package/src/views/method-selector/__snapshots__/method-selector.spec.js.snap +0 -135
  116. package/src/views/method-selector/express-methods.js +0 -52
  117. package/src/views/method-selector/generate-digital-wallet.js +0 -53
  118. package/src/views/method-selector/generate-digital-wallet.spec.js +0 -121
  119. package/src/views/method-selector/generate-framepay-config.js +0 -56
  120. package/src/views/method-selector/generate-framepay-config.spec.js +0 -216
  121. package/src/views/method-selector/get-method-data.js +0 -11
  122. package/src/views/method-selector/get-payment-methods.js +0 -25
  123. package/src/views/method-selector/get-payment-methods.spec.js +0 -41
  124. package/src/views/method-selector/index.js +0 -223
  125. package/src/views/method-selector/method-selector.spec.js +0 -20
  126. package/src/views/method-selector/mount-bump-offer.js +0 -120
  127. package/src/views/method-selector/mount-express-methods.js +0 -107
  128. package/src/views/modal.js +0 -103
  129. package/src/views/result.js +0 -24
  130. package/src/views/summary.js +0 -38
  131. package/tests/async-utilities.js +0 -22
  132. package/tests/mocks/framepay-mock.js +0 -15
  133. package/tests/mocks/rebilly-api-mock.js +0 -11
  134. package/tests/mocks/rebilly-instruments-mock.js +0 -141
  135. package/tests/mocks/storefront-api-mock.js +0 -62
  136. package/tests/mocks/storefront-mock.js +0 -20
  137. package/tests/msw/server.js +0 -14
  138. package/tests/setup-test.js +0 -30
  139. package/vitest.config.js +0 -18
@@ -1,115 +0,0 @@
1
- const errorTemplate = (error) => {
2
- const title = 'Error';
3
-
4
- function displayString(message = null) {
5
- if (message === null) {
6
- message = 'An unexpected error occurred';
7
-
8
- if (typeof error === 'string') {
9
- message = error;
10
- }
11
-
12
- if (error.error) {
13
- message = error.error;
14
- }
15
-
16
- if (error.message) {
17
- message = error.message;
18
- }
19
- }
20
-
21
- return `<p class="rebilly-instruments-error-card-message">${message}</p>`;
22
- }
23
-
24
- function displayList() {
25
- function displayDetail(detail) {
26
- let detailMessage = detail;
27
- if (detail['data-rebilly']) {
28
- detailMessage = `"${detail['data-rebilly']}" ${detail.error}`;
29
- }
30
- return detailMessage;
31
- }
32
-
33
- if (error.details.length > 1) {
34
- return `<ul class="rebilly-instruments-error-card-details">
35
- ${error.details
36
- .map((detail) => `<li>${displayDetail(detail)}</li>`)
37
- .join('')}
38
- </ul>`;
39
- }
40
-
41
- return displayString(displayDetail(error.details[0]));
42
- }
43
-
44
- return `<div class="rebilly-instruments-error-card">
45
- <header class="rebilly-instruments-error-card-header">
46
- <p class="rebilly-instruments-error-card-title">${title}</p>
47
- <button class="rebilly-instruments-error-card-close-button">
48
- <svg class="rebilly-instruments-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
49
- <path d="M12 10.5858l2.8284-2.8284c.3906-.3906 1.0237-.3906 1.4142 0 .3906.3905.3906 1.0236 0 1.4142L13.4142 12l2.8284 2.8284c.3906.3906.3906 1.0237 0 1.4142-.3905.3906-1.0236.3906-1.4142 0L12 13.4142l-2.8284 2.8284c-.3906.3906-1.0237.3906-1.4142 0-.3906-.3905-.3906-1.0236 0-1.4142L10.5858 12 7.7574 9.1716c-.3906-.3906-.3906-1.0237 0-1.4142.3905-.3906 1.0236-.3906 1.4142 0L12 10.5858z" fill-rule="nonzero"/>
50
- </svg>
51
- </button>
52
- </header>
53
- ${error.details ? displayList() : displayString()}
54
- </div>`;
55
- };
56
-
57
- export function clearError() {
58
- const errorContainer = document.querySelector('#rebilly-instruments-error');
59
- if (!errorContainer) return;
60
-
61
- errorContainer.innerHTML = '';
62
- }
63
-
64
- export function showError(error, isCloseable = true) {
65
- if (!error) return;
66
- const errorContainer = document.querySelector('#rebilly-instruments-error');
67
- if (!errorContainer) return;
68
-
69
- errorContainer.innerHTML = errorTemplate(error);
70
-
71
- function clickOutsideError(e) {
72
- if (errorContainer.contains(e.target)) return;
73
-
74
- window.removeEventListener('click', clickOutsideError, false);
75
- clearError();
76
- }
77
-
78
- function windowBlur() {
79
- setTimeout(() => {
80
- if (document.activeElement.tagName === 'IFRAME') {
81
- window.removeEventListener('click', windowBlur, false);
82
- clearError();
83
- }
84
- });
85
- }
86
-
87
- const closeButton = document.querySelector(
88
- '.rebilly-instruments-error-card-close-button',
89
- );
90
-
91
- if (isCloseable) {
92
- closeButton.addEventListener('click', clearError);
93
-
94
- window.addEventListener('click', clickOutsideError);
95
- window.addEventListener('blur', windowBlur, { once: true });
96
- } else {
97
- const errorBox = document.querySelector(
98
- '.rebilly-instruments-error-card',
99
- );
100
- errorBox.classList.add('not-closeable');
101
- closeButton.remove();
102
- }
103
-
104
- if (errorContainer.scrollIntoView) {
105
- errorContainer.scrollIntoView({
106
- behavior: 'smooth',
107
- block: 'end',
108
- inline: 'nearest',
109
- });
110
- }
111
- console.error('Rebilly Instruments Error', error);
112
-
113
- // Must focus to ensure window blur event will trigger
114
- window.focus();
115
- }
package/src/views/form.js DELETED
@@ -1,61 +0,0 @@
1
- import state from '../state';
2
- import iframes from '../state/iframes';
3
- import { ViewIframe } from './common/iframe';
4
- import { mountMethodSelector } from './method-selector';
5
- import { mountAmountSelector } from './amount-selector';
6
-
7
- export const baseMethodSelectorHTML = () => `
8
- <div data-rebilly-instruments="content" class="rebilly-instruments-content">
9
- <div data-rebilly-instruments="content-error" id="rebilly-instruments-error"></div>
10
- <div data-rebilly-instruments="form"></div>
11
- </div>
12
- `;
13
-
14
- export async function mountForm() {
15
- state.form.innerHTML += baseMethodSelectorHTML();
16
- const container = document.querySelector(
17
- '[data-rebilly-instruments="form"]',
18
- );
19
- const { paymentMethodsUrl: url } = state?.options?._computed || {};
20
- const name = 'rebilly-instruments-form';
21
-
22
- const modelSafeState = state.toModel();
23
- const model = {
24
- options: modelSafeState.options,
25
- data: modelSafeState.data,
26
- mainStyleVars: modelSafeState.mainStyleVars,
27
- };
28
-
29
- const args = {
30
- name,
31
- url: `${url}?name=${name}`,
32
- container,
33
- model,
34
- };
35
-
36
- const iframe = await new ViewIframe(args);
37
- iframe.bindEventListeners({ loader: state.loader });
38
-
39
- iframes.form = iframe;
40
-
41
- state.loader.stopLoading({ id: 'rebilly-instruments-form' });
42
-
43
- return {
44
- then: (callback) => callback(),
45
- };
46
- }
47
-
48
- export function determineFirstView() {
49
- if (state.options?.deposit) {
50
- mountAmountSelector();
51
- } else {
52
- mountMethodSelector();
53
- }
54
- }
55
-
56
- export function removeForm() {
57
- const container = document.querySelector(
58
- '[data-rebilly-instruments="form"]',
59
- );
60
- container.remove();
61
- }
@@ -1,135 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Methods Selector Component > should inject the proper HTML for express methods 1`] = `
4
- <div
5
- class="rebilly-instruments-form"
6
- style="max-width: 750px; position: relative; min-height: calc(calc((4 * var(--rebilly-spacingFormElementMinHeight)) + (2 * var(--rebilly-fontLineHeightBase)) + (2 * var(--rebilly-spacingM)) + var(--rebilly-spacing2xs) + var(--rebilly-fontSizeS) + calc(2 * (var(--rebilly-spacingXs) + var(--rebilly-spacingS))) + var(--rebilly-spacingL)) + + + 4px);"
7
- >
8
-
9
-
10
- <div
11
- class="rebilly-instruments-loader is-active"
12
- style="padding: NaNpx"
13
- >
14
-
15
-
16
- <div
17
- class="rebilly-instruments-methods-loader"
18
- >
19
-
20
-
21
- <div
22
- class="rebilly-instruments-loader-form-el is-el-loading"
23
- />
24
-
25
-
26
- <div
27
- class="rebilly-instruments-divider"
28
- >
29
-
30
-
31
- <span
32
- class="rebilly-instruments-divider-label"
33
- >
34
- <span
35
- class="is-el-loading"
36
- >
37
- Divi
38
- </span>
39
- </span>
40
-
41
-
42
- </div>
43
-
44
-
45
- <div
46
- class="rebilly-instruments-loader-display-flex rebilly-instruments-loader-justify-end"
47
- >
48
-
49
-
50
- <div
51
- class="rebilly-instruments-methods-loader-card-icon is-el-loading"
52
- />
53
-
54
-
55
- <div
56
- class="rebilly-instruments-methods-loader-card-icon is-el-loading"
57
- />
58
-
59
-
60
- </div>
61
-
62
-
63
- <div
64
- class="rebilly-instruments-loader-form-el is-el-loading"
65
- />
66
-
67
-
68
- <div
69
- class="rebilly-instruments-methods-loader-form-fields"
70
- >
71
-
72
-
73
- <div
74
- class="rebilly-instruments-loader-form-label"
75
- >
76
- <small
77
- class="is-el-loading"
78
- >
79
- Card holder name
80
- </small>
81
- </div>
82
-
83
-
84
- <div
85
- class="rebilly-instruments-loader-form-el is-el-loading"
86
- />
87
-
88
-
89
- </div>
90
-
91
-
92
- <div
93
- class="rebilly-instruments-loader-form-el is-button"
94
- >
95
- Continue
96
- </div>
97
-
98
-
99
- </div>
100
-
101
-
102
- </div>
103
-
104
-
105
-
106
- <div
107
- class="rebilly-instruments-content"
108
- data-rebilly-instruments="content"
109
- >
110
-
111
-
112
- <div
113
- data-rebilly-instruments="content-error"
114
- id="rebilly-instruments-error"
115
- />
116
-
117
-
118
- <div
119
- data-rebilly-instruments="form"
120
- >
121
- <iframe
122
- allow="payment"
123
- class="rebilly-instruments-iframe"
124
- loading="lazy"
125
- name="rebilly-instruments-form"
126
- src="https://forms.test.rebilly.dev?name=rebilly-instruments-form"
127
- />
128
- </div>
129
-
130
-
131
- </div>
132
-
133
-
134
- </div>
135
- `;
@@ -1,52 +0,0 @@
1
- export default function mountExpressMethod({ state, id }) {
2
- const { Rebilly } = window;
3
- const container = document.querySelector(
4
- `.rebilly-instruments-${id}-method`,
5
- );
6
-
7
- // Hack: The correct way to do this is to accept the options via the framepay package
8
- // Will remove once these options are added to framepay
9
- function updateApplePayStyling() {
10
- const applePayButton = document.querySelector(
11
- '#rebilly-apple-pay-button',
12
- );
13
- const {
14
- applePayDisplayOptions: { buttonHeight },
15
- } = state.options.digitalWallet.applePay;
16
-
17
- applePayButton.style.margin = '0px';
18
- applePayButton.style.width = '100%';
19
- applePayButton.style.height = buttonHeight;
20
- applePayButton.style.cursor = 'pointer';
21
- }
22
-
23
- function mountButton() {
24
- if (!container.children.length) {
25
- const rebillyMountFunction = {
26
- 'google-pay': 'googlePay',
27
- 'pay-pal-billing-agreement': 'paypal',
28
- 'apple-pay': 'applePay',
29
- };
30
-
31
- if (rebillyMountFunction[id]) {
32
- Rebilly[rebillyMountFunction[id]].mount(
33
- `.rebilly-instruments-${id}-method`,
34
- );
35
-
36
- if (id === 'apple-pay') {
37
- updateApplePayStyling();
38
- }
39
- } else {
40
- console.warn(`method '${id}' is not supported`);
41
- }
42
- }
43
- }
44
-
45
- Rebilly?.on('ready', () => {
46
- mountButton();
47
- });
48
-
49
- Rebilly?.on('error', (error) => {
50
- console.error(error);
51
- });
52
- }
@@ -1,53 +0,0 @@
1
- import state from '../../state';
2
- import { getMethodData } from './get-method-data';
3
-
4
- export function generateDigitalWallet({ expressMethods = [] }) {
5
- const output = {};
6
-
7
- const { paymentInstruments } = state.options;
8
-
9
- const transactionData = {
10
- countryCode: state.options.countryCode,
11
- label: state.options.websiteId,
12
- };
13
-
14
- if (state.data?.amountAndCurrency) {
15
- const { amount, currency } = state.data.amountAndCurrency;
16
- transactionData.amount = amount;
17
- transactionData.currency = currency;
18
- }
19
-
20
- expressMethods.forEach((method) => {
21
- const { METHOD_TYPE } = getMethodData(method);
22
-
23
- if (method.feature?.name === 'Google Pay') {
24
- output[METHOD_TYPE] = {
25
- transactionData,
26
- merchantConfig: {
27
- merchantName: method.feature.merchantName,
28
- merchantOrigin: method.feature.merchantOrigin,
29
- },
30
- googlePayDisplayOptions:
31
- paymentInstruments.googlePay.displayOptions,
32
- };
33
- }
34
-
35
- if (method.feature?.name === 'Apple Pay') {
36
- output[METHOD_TYPE] = {
37
- transactionData,
38
- merchantConfig: {
39
- merchantName:
40
- paymentInstruments.applePay?.merchantConfig
41
- ?.merchantName,
42
- // Apple Pay code cannot run in an iframe, and the merchant origin must be
43
- // registered as a merchant domain, so we can just send the current URL.
44
- merchantOrigin: window.location.hostname,
45
- },
46
- applePayDisplayOptions:
47
- paymentInstruments.applePay.displayOptions,
48
- };
49
- }
50
- });
51
-
52
- return output;
53
- }
@@ -1,121 +0,0 @@
1
- import { generateDigitalWallet } from './generate-digital-wallet';
2
- import ReadyToPayModel from '@/storefront/models/ready-to-pay-model';
3
- import SummaryModel from '@/storefront/models/summary-model';
4
- import { DataInstance } from '@/functions/mount/fetch-data';
5
- import state from '@/state';
6
-
7
- describe('generateDigitalWallet', () => {
8
- function setupState() {
9
- state.options = {
10
- websiteId: 'test-website-id',
11
- countryCode: 'US',
12
- paymentInstruments: {
13
- googlePay: {
14
- displayOptions: {
15
- buttonColor: 'black',
16
- buttonType: 'plain',
17
- buttonHeight: '48px',
18
- },
19
- },
20
- applePay: {
21
- displayOptions: {
22
- buttonColor: 'black',
23
- buttonType: 'buy',
24
- buttonHeight: '48px',
25
- },
26
- merchantConfig: {
27
- merchantName: 'Test Store Name',
28
- },
29
- },
30
- },
31
- };
32
-
33
- state.data = new DataInstance({
34
- previewPurchase: {
35
- total: 1,
36
- currency: 'USD',
37
- },
38
- });
39
- }
40
-
41
- it('should generate the correct digital wallet config for Google pay', () => {
42
- const expressMethods = [
43
- new ReadyToPayModel({
44
- method: 'payment-card',
45
- feature: {
46
- name: 'Google Pay',
47
- merchantName: 'google-pay-merchant-name',
48
- merchantOrigin: 'google-pay-merchant-origin',
49
- },
50
- brands: ['Visa'],
51
- }),
52
- ];
53
- setupState();
54
-
55
- const output = generateDigitalWallet({ expressMethods });
56
-
57
- const expectedOutput = {
58
- googlePay: {
59
- transactionData: {
60
- amount: 1,
61
- currency: 'USD',
62
- countryCode: 'US',
63
- label: 'test-website-id',
64
- },
65
- merchantConfig: {
66
- merchantName: 'google-pay-merchant-name',
67
- merchantOrigin: 'google-pay-merchant-origin',
68
- },
69
- googlePayDisplayOptions: {
70
- buttonColor: 'black',
71
- buttonType: 'plain',
72
- buttonHeight: '48px',
73
- },
74
- },
75
- };
76
-
77
- expect(output).toMatchObject(expectedOutput);
78
- });
79
-
80
- it('should generate the correct digital wallet config for Apple pay', () => {
81
- delete window.location;
82
- window.location = new URL(
83
- 'https://rebilly-apple-pay-test-tunnel.ngrok.io/',
84
- );
85
-
86
- const expressMethods = [
87
- new ReadyToPayModel({
88
- method: 'payment-card',
89
- feature: {
90
- name: 'Apple Pay',
91
- },
92
- brands: ['Visa'],
93
- }),
94
- ];
95
- setupState();
96
-
97
- const output = generateDigitalWallet({ expressMethods });
98
-
99
- const expectedOutput = {
100
- applePay: {
101
- transactionData: {
102
- amount: 1,
103
- currency: 'USD',
104
- countryCode: 'US',
105
- label: 'test-website-id',
106
- },
107
- merchantConfig: {
108
- merchantName: 'Test Store Name',
109
- merchantOrigin: 'rebilly-apple-pay-test-tunnel.ngrok.io',
110
- },
111
- applePayDisplayOptions: {
112
- buttonColor: 'black',
113
- buttonType: 'buy',
114
- buttonHeight: '48px',
115
- },
116
- },
117
- };
118
-
119
- expect(output).toMatchObject(expectedOutput);
120
- });
121
- });
@@ -1,56 +0,0 @@
1
- import merge from 'lodash.merge';
2
- import state from '../../state';
3
-
4
- export function generateFramepayConfig({ methodIds } = {}) {
5
- const { options, data } = state;
6
-
7
- const config = {
8
- style: options.themeFramepay,
9
- locale: options?.locale || 'auto',
10
- organizationId: options.organizationId,
11
- websiteId: options.websiteId,
12
- methods: data.readyToPay,
13
- };
14
-
15
- if (methodIds.includes('pay-pal-billing-agreement')) {
16
- config.transactionData = merge(
17
- typeof config.transactionData === 'object'
18
- ? config.transactionData
19
- : {},
20
- data.amountAndCurrency,
21
- );
22
- config.paypal = options.paymentInstruments.paypal;
23
- }
24
-
25
- if (methodIds.includes('google-pay')) {
26
- config.transactionData = merge(
27
- typeof config.transactionData === 'object'
28
- ? config.transactionData
29
- : {},
30
- options.digitalWallet.googlePay?.transactionData,
31
- );
32
- config.googlePay =
33
- options.digitalWallet.googlePay.googlePayDisplayOptions;
34
- }
35
-
36
- if (methodIds.includes('apple-pay')) {
37
- config.transactionData = merge(
38
- typeof config.transactionData === 'object'
39
- ? config.transactionData
40
- : {},
41
- options.digitalWallet.applePay?.transactionData,
42
- );
43
- config.applePay = options.digitalWallet.applePay.applePayDisplayOptions;
44
- }
45
-
46
- if (options.publishableKey) {
47
- config.publishableKey = options.publishableKey;
48
- }
49
-
50
- if (options.jwt) {
51
- config.jwt = options.jwt;
52
- config.sandbox = options.apiMode === 'sandbox';
53
- }
54
-
55
- return config;
56
- }