@rebilly/instruments 3.37.0 → 3.37.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 (34) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.js +15 -15
  3. package/dist/index.min.js +15 -15
  4. package/package.json +1 -1
  5. package/src/data/options-schema/schemas/options-schema.js +3 -7
  6. package/src/functions/mount/fetch-data.js +3 -15
  7. package/src/functions/mount/index.js +70 -4
  8. package/src/functions/mount/mount.spec.js +1 -6
  9. package/src/functions/mount/setup-options.js +6 -19
  10. package/src/functions/mount/setup-options.spec.js +3 -3
  11. package/src/functions/purchase.js +4 -10
  12. package/src/functions/show.js +4 -3
  13. package/src/functions/show.spec.js +2 -0
  14. package/src/i18n/en.json +0 -3
  15. package/src/i18n/es.json +0 -3
  16. package/src/storefront/ready-to-pay.js +0 -5
  17. package/src/storefront/summary.js +1 -1
  18. package/src/style/base/__snapshots__/theme.spec.js.snap +1 -1
  19. package/src/style/base/default-theme.js +1 -1
  20. package/src/views/common/iframe/base-iframe.js +1 -7
  21. package/src/views/confirmation.js +15 -14
  22. package/src/views/method-selector/__snapshots__/method-selector.spec.js.snap +59 -10
  23. package/src/views/method-selector/generate-digital-wallet.js +2 -2
  24. package/src/views/method-selector/generate-digital-wallet.spec.js +13 -2
  25. package/src/views/method-selector/get-payment-methods.js +5 -5
  26. package/src/views/method-selector/get-payment-methods.spec.js +3 -4
  27. package/src/views/method-selector/index.js +86 -151
  28. package/src/views/method-selector/method-selector.spec.js +1 -1
  29. package/src/views/result.js +18 -8
  30. package/src/views/summary.js +3 -11
  31. package/src/storefront/deposit-requests.js +0 -12
  32. package/src/storefront/models/deposit-request-model.js +0 -15
  33. package/src/views/amount-selector.js +0 -47
  34. package/src/views/form.js +0 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebilly/instruments",
3
- "version": "3.37.0",
3
+ "version": "3.37.1",
4
4
  "author": "Rebilly",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -78,9 +78,7 @@ export default {
78
78
  money: {
79
79
  type: 'object',
80
80
  properties: {
81
- amount: {
82
- type: 'number'
83
- },
81
+ amount: {type: 'number'},
84
82
  currency: {
85
83
  type: 'string',
86
84
  minLength: 3,
@@ -107,9 +105,7 @@ export default {
107
105
  minLength: 3,
108
106
  maxLength: 3,
109
107
  },
110
- amount: {
111
- type: 'number'
112
- },
108
+ amount: {type: 'number'},
113
109
  buttons: {
114
110
  type: 'array',
115
111
  items: {
@@ -122,7 +118,7 @@ export default {
122
118
  properties: {
123
119
  minimum: {type: 'number'},
124
120
  maximum: {type: 'number'},
125
- multipleOf: {type: 'number'}
121
+ increment: {type: 'number'}
126
122
  },
127
123
  }
128
124
  },
@@ -8,8 +8,6 @@ import { fetchInvoiceAndProducts as FetchInvoiceAndProducts } from '../../storef
8
8
  import { fetchTransaction as FetchTransaction } from '../../storefront/transactions';
9
9
  import { fetchAccountAndWebsite as FetchAccountAndWebsite } from '../../storefront/account-and-website';
10
10
  import { fetchPaymentInstrument as FetchInstruments } from '../../storefront/payment-instruments';
11
- import { fetchDepositRequest as FetchDepositRequest } from '../../storefront/deposit-requests';
12
- import DepositRequestModel from '../../storefront/models/deposit-request-model';
13
11
 
14
12
  export class DataInstance {
15
13
  constructor({
@@ -128,22 +126,11 @@ export async function fetchData({
128
126
  fetchInvoiceAndProducts = FetchInvoiceAndProducts,
129
127
  fetchTransaction = FetchTransaction,
130
128
  fetchAccountAndWebsite = FetchAccountAndWebsite,
131
- fetchInstruments = FetchInstruments,
132
- fetchDepositRequest = FetchDepositRequest,
129
+ fetchInstruments = FetchInstruments
133
130
  } = {}) {
134
131
  try {
135
132
  state.data = new DataInstance();
136
133
 
137
- if (state.options?.deposit) {
138
- if (state.options.deposit.depositRequestId) {
139
- state.data.deposit = await fetchDepositRequest({data: {
140
- id: state.options.deposit.depositRequestId,
141
- }});
142
- } else {
143
- state.data.deposit = new DepositRequestModel(state.options.deposit);
144
- }
145
- }
146
-
147
134
  let readyToPayPromise = Promise.resolve(null);
148
135
 
149
136
  let availableInstrumentsPromise = null;
@@ -162,7 +149,8 @@ export async function fetchData({
162
149
  state.data.transaction = await fetchTransaction({
163
150
  data: {
164
151
  id: state.options.transactionId
165
- }});
152
+ }, state
153
+ });
166
154
  }
167
155
 
168
156
  let productsPromise;
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable max-len */
2
2
  import state from '../../state';
3
3
  import { mountSummary } from '../../views/summary';
4
- import { mountForm, determineFirstView } from '../../views/form';
4
+ import { mountMethodSelector } from '../../views/method-selector';
5
5
  import { fetchData } from './fetch-data';
6
6
  import Events from '../../events';
7
7
  import setupElement from './setup-element';
@@ -14,7 +14,74 @@ import setupFramepayTheme from './setup-framepay-theme';
14
14
  import setupUserFlow from './setup-user-flow';
15
15
  import { showError } from '../../views/errors';
16
16
 
17
- /** See src/data/options-schema for options structure */
17
+ /**
18
+ * @typedef {object} ItemQuantity - Item quantity
19
+ * @property {number} default - The initial quantity value
20
+ * @property {number} [minimum=1] - minimum allowed quantity. if minimum, maximum or multipleOf are present, quantity will be "variable"
21
+ * @property {number} [maximum=Number.MAX_SAFE_INTEGER] - maximum allowed quantity
22
+ * @property {number} [multipleOf=1]
23
+ *
24
+ * @typedef {object} Item
25
+ * @property {string} planId - The Rebilly id of the plan.
26
+ * @property {number | ItemQuantity} quantity - The number of the plans to be purchased.
27
+ * @property {string} thumbnail - The source img for the product. Recommend 100px by 100px.
28
+ *
29
+ * @typedef {object} GooglePayDisplayOptions
30
+ * @property {"back" | "white"} [buttonColor=black] - Color of google pay button
31
+ * @property {"book" | "buy" | "checkout" | "donate" | "order" | "pay" | "plain" | "subscribe" | "short" | "long"} [buttonType=plain] - The length of the button
32
+ * @property {string} [buttonHeight=48px] - The value and units of the button to match other payment buttons
33
+ *
34
+ * @typedef {object} ApplePayDisplayOptions
35
+ * @property {"back" | "white"} [buttonColor=black] - Color of apple pay button
36
+ * @property {"short" | "long"} [buttonType=short] - The length of the button
37
+ * @property {string} [buttonHeight=48px] - The value and units of the button to match other payment buttons
38
+ *
39
+ * @typedef {object} ApplePayMerchantOptions
40
+ * @property {string} merchantName - The name of the merchant store.
41
+ *
42
+ * @typedef {object} GooglePay
43
+ * @property {GooglePayDisplayOptions} displayOptions - display options for google pay instrument
44
+ *
45
+ * @typedef {object} ApplePay
46
+ * @property {ApplePayDisplayOptions} displayOptions - display options for apple pay instrument
47
+ * @property {ApplePayMerchantOptions} merchantOptions - merchant options for apple pay instrument
48
+ *
49
+ * @typedef {object} PaymentCard
50
+ * @property {boolean} [popup=true] - Show method as a button with a form popup. Otherwise the form will be mounted inline.
51
+ *
52
+ * @typedef {object} Address
53
+ * @property {string} [name=default] - One of default, combined, or stacked.
54
+ * @property {string} [region=default] - One of default, split, or stacked.
55
+ * @property {Array.<"organization" | "phoneNumber">} show - Show extra fields listed.
56
+ * @property {Array.<"address" | "address2" | "email | "country" | "region" | "postalCode"">} hide - Hide the listed fields.
57
+ * @property {Array.<"organization" | "address" | "address2" | "email" | "phoneNumber" | "country" | "region" | "postalCode">} require - Require the listed fields.
58
+ *
59
+ * @typedef {object} PaymentInstruments
60
+ * @property {boolean} [compactExpressInstruments=true] - Show express methods as inline pill buttons, or list of full width button.
61
+ * @property {PaymentCard} paymentCard - settings for payment card instruments
62
+ * @property {GooglePay} googlePay - settings for google pay instruments
63
+ * @property {ApplePay} applePay - settings for apple pay instruments
64
+ * @property {Address} address - customization for address components for all payment instruments.
65
+ *
66
+ * @typedef {object} Features
67
+ * @property {boolean} [autoConfirmation=true] - Will mount the confirmation screen after `instrument-ready` event is triggered.
68
+ * @property {boolean} [autoResult=true] - Show results of transaction after `purchase-completed` event is triggered
69
+ */
70
+
71
+ /**
72
+ * Mount library with configurations.
73
+ * @param {object} options - The options object
74
+ * @param {function} options.setupFramepayInstance - Helper for adding FramePay scripts to the DOM
75
+ * @param {string | HTMLElement} options.form - The CSS class or HTML element were the form will be mounted.
76
+ * @param {string | HTMLElement} options.summary - The CSS class or HTML element were the summary will be mounted.
77
+ * @param {Item[]} options.items - Which plans the customer is purchasing.
78
+ * @param {string} options.invoiceId - The Rebilly id of the invoice used for purchasing.
79
+ * @param {string} options.jwt - The customer token to access the invoice.
80
+ * @param {string} [options.countryCode=USD] - The country code for the transaction
81
+ * @param {PaymentInstruments} options.paymentInstruments - settings for various payment instruments
82
+ * @param {Features} options.features - flags to enable and disable different features
83
+ * @param {string} options.locale - default: auto. Language to render component text
84
+ */
18
85
  export async function mount({
19
86
  setupFramepay = setupFramepayInstance,
20
87
  ...options
@@ -66,8 +133,7 @@ export async function mount({
66
133
 
67
134
  // Mount content
68
135
  if (state.form) {
69
- mountForm()
70
- .then(() => determineFirstView());
136
+ mountMethodSelector();
71
137
  }
72
138
  if (state.summary) {
73
139
  mountSummary();
@@ -35,12 +35,7 @@ describe('RebillyInstruments instance', () => {
35
35
 
36
36
  // Mounts form and summary
37
37
  const summarySelector = document.querySelector('.summary-selector');
38
- const iframe = summarySelector.querySelector('iframe');
39
- expect(iframe.getAttribute('name')).toEqual('rebilly-instruments-summary');
40
- expect(iframe.getAttribute('class')).toEqual('rebilly-instruments-iframe');
41
- expect(iframe.getAttribute('loading')).toEqual('lazy');
42
- expect(iframe.getAttribute('allow')).toEqual('payment');
43
- expect(iframe.getAttribute('src')).toEqual('https://forms.test.rebilly.dev?name=rebilly-instruments-summary');
38
+ expect(summarySelector.innerHTML).toContain('<iframe name="rebilly-instruments-summary" class="rebilly-instruments-iframe" loading="lazy" allow="payment" src="https://forms.test.rebilly.dev/summary"></iframe>');
44
39
 
45
40
  // Theme config overrides initial styles
46
41
  const STYLE_VARS = document.querySelectorAll('style[type="text/css"]')[0];
@@ -4,9 +4,10 @@ import { parseQuantity } from '../../utils/quantity';
4
4
  import { validateOptions } from '../../data/options-schema';
5
5
 
6
6
  export function handleComputedProperty(options) {
7
- options._computed = {
7
+ const _computed = {
8
8
  paymentMethodsUrl: options._dev?.paymentMethodsUrl ?? 'https://forms.secure-payments.app'
9
9
  };
10
+ options._computed = _computed;
10
11
  return options
11
12
  }
12
13
 
@@ -24,16 +25,8 @@ export function handleNestedPropertiesDefaultValues(options) {
24
25
  buttons: [],
25
26
  customAmount: {
26
27
  minimum: 1,
27
- maximum: 1000000000000,
28
- multipleOf: 1,
29
- }
30
- }, (options.deposit || {}));
31
- } else if (options.deposit?.depositRequestId) {
32
- options.deposit = merge({
33
- customAmount: {
34
- minimum: 1,
35
- maximum: 1000000000000,
36
- multipleOf: 1,
28
+ maximum: Number.MAX_SAFE_INTEGER,
29
+ increment: 1,
37
30
  }
38
31
  }, (options.deposit || {}));
39
32
  }
@@ -56,7 +49,6 @@ export function handleJwtDestructuring(options) {
56
49
  transactionId,
57
50
  invoiceId,
58
51
  websiteId,
59
- cashierRequestId
60
52
  }
61
53
  } = decodeJwt(options.jwt);
62
54
  Object.entries({
@@ -69,10 +61,6 @@ export function handleJwtDestructuring(options) {
69
61
  options[key] = value;
70
62
  }
71
63
  });
72
- if (cashierRequestId && !options.deposit) {
73
- options.deposit = {};
74
- options.deposit.depositRequestId = cashierRequestId;
75
- }
76
64
  }
77
65
 
78
66
  return options;
@@ -83,10 +71,9 @@ export default ({
83
71
  } = {}) => {
84
72
  let validOptions = validateOptions(options);
85
73
  if (validOptions) {
86
- validOptions = handleJwtDestructuring(validOptions);
87
- validOptions = handleNestedPropertiesDefaultValues(validOptions);
88
74
  validOptions = handleComputedProperty(validOptions);
75
+ validOptions = handleNestedPropertiesDefaultValues(validOptions);
76
+ validOptions = handleJwtDestructuring(validOptions);
89
77
  }
90
-
91
78
  return validOptions;
92
79
  }
@@ -217,7 +217,7 @@ describe('Setup options handleNestedPropertiesDefaultValues function', () => {
217
217
  buttons: [],
218
218
  customAmount: {
219
219
  minimum: 1,
220
- maximum: 1000000000000,
220
+ maximum: Number.MAX_SAFE_INTEGER,
221
221
  increment: 1,
222
222
  },
223
223
  currency: 'USD'
@@ -253,9 +253,9 @@ describe('Setup options handleNestedPropertiesDefaultValues function', () => {
253
253
  items: [{
254
254
  planId: 'plan_TEST',
255
255
  quantity: {
256
- minimum: 0.1,
256
+ minimum: 1,
257
257
  maximum: Number.MAX_SAFE_INTEGER,
258
- multipleOf: 0.1
258
+ multipleOf: 1
259
259
  }
260
260
  }]
261
261
  });
@@ -27,27 +27,21 @@ export async function makePayment({ payload }) {
27
27
  data.token = id;
28
28
  }
29
29
 
30
- if (state.options?.invoiceId) {
30
+ if (state.options.invoiceId) {
31
31
  data.invoiceId = state.options.invoiceId;
32
32
  }
33
33
 
34
- if (state.options?.transactionId) {
34
+ if (state.options.transactionId) {
35
35
  data.transactionId = state.options.transactionId;
36
36
  }
37
37
 
38
- if (state.options?.money) {
38
+ if (state.options.money) {
39
39
  data.websiteId = state.options.websiteId;
40
40
  data.amount = state.options.money.amount;
41
41
  data.currency = state.options.money.currency;
42
42
  }
43
-
44
- if (state.options?.deposit) {
45
- data.websiteId = state.options.websiteId;
46
- data.amount = state.data.amountAndCurrency.amount;
47
- data.currency = state.data.amountAndCurrency.currency;
48
- }
49
43
 
50
- if (state.data?.couponIds && Array.isArray(state.data.couponIds)) {
44
+ if (state.data.couponIds && Array.isArray(state.data.couponIds)) {
51
45
  data.couponIds = state.data.couponIds
52
46
  }
53
47
 
@@ -1,7 +1,6 @@
1
1
  import iframes from '../state/iframes';
2
2
  import { mountConfirmation } from '../views/confirmation';
3
3
  import { mountResult } from '../views/result';
4
- import { hideExtraUI as hideMethodSelectorUI} from '../views/method-selector'
5
4
 
6
5
  /**
7
6
  @typedef ShowParams
@@ -18,11 +17,13 @@ import { hideExtraUI as hideMethodSelectorUI} from '../views/method-selector'
18
17
  export async function show({ componentName, payload }) {
19
18
  switch (componentName) {
20
19
  case 'result':
21
- hideMethodSelectorUI();
20
+ if (iframes.hasFrame('form')) {
21
+ iframes.form.destroy();
22
+ iframes.form = null;
23
+ }
22
24
  mountResult({ payload });
23
25
  break;
24
26
  case 'confirmation':
25
- hideMethodSelectorUI();
26
27
  mountConfirmation({ payload });
27
28
  break;
28
29
  default:
@@ -12,6 +12,7 @@ describe('RebillyInstruments show', () => {
12
12
  .mockReturnValue(Promise.resolve());
13
13
 
14
14
  const instance = new RebillyInstrumentsInstance();
15
+ iframes.form = iframeMock;
15
16
 
16
17
  const payload = {
17
18
  test: 'value'
@@ -23,6 +24,7 @@ describe('RebillyInstruments show', () => {
23
24
  expect(mountResult).toBeCalledWith(
24
25
  expect.objectContaining({ payload })
25
26
  );
27
+ expect(iframes.form).toEqual(null);
26
28
  });
27
29
 
28
30
  it('should show confirmation component', async () => {
package/src/i18n/en.json CHANGED
@@ -7,9 +7,6 @@
7
7
  "shipping": "Shipping",
8
8
  "total": "Total"
9
9
  },
10
- "deposit": {
11
- "goBack": "Choose another amount"
12
- },
13
10
  "form": {
14
11
  "expressCheckout": "Express checkout",
15
12
  "or": "Or",
package/src/i18n/es.json CHANGED
@@ -7,9 +7,6 @@
7
7
  "shipping": "Envío",
8
8
  "total": "Total"
9
9
  },
10
- "deposit": {
11
- "goBack": "Elija otro monto a depositar"
12
- },
13
10
  "form": {
14
11
  "expressCheckout": "Chequeo rápido",
15
12
  "or": "O pague con",
@@ -85,11 +85,6 @@ export async function fetchReadyToPay({
85
85
  data.billingAddress = state.data.account.address;
86
86
  }
87
87
 
88
- if (state.data?.deposit) {
89
- data.amount = state.data.deposit.amount;
90
- data.currency = state.data.deposit.currency;
91
- }
92
-
93
88
  const { fields: readyToPayFields } = await state.storefront.purchase.readyToPay({ data });
94
89
  const readyToPay = Object.values(readyToPayFields);
95
90
 
@@ -16,6 +16,7 @@ export async function fetchSummary({ data = null } = {}) {
16
16
  }
17
17
  };
18
18
 
19
+
19
20
  const isBumpOfferSummary = () => state.data.summaryLineItems.every(
20
21
  item => bumpOfferProductsIds.includes(item.planId)
21
22
  );
@@ -49,7 +50,6 @@ export async function fetchSummary({ data = null } = {}) {
49
50
  if (data?.billingAddress) {
50
51
  payload.data.billingAddress = data.billingAddress;
51
52
  }
52
-
53
53
  if (data?.deliveryAddress) {
54
54
  payload.data.deliveryAddress = data.deliveryAddress;
55
55
  }
@@ -8,7 +8,7 @@ Object {
8
8
  --rebilly-colorMutedText: rgba(13, 43, 62, 0.5);
9
9
  --rebilly-colorMutedBorder: #DCE3EA;
10
10
  --rebilly-colorDanger: #CD5C5C;
11
- --rebilly-fontFamily: -apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial sans-serif;
11
+ --rebilly-fontFamily: Avenir, Helvetica, Arial, sans-serif;
12
12
  --rebilly-fontSizeBase: 16px;
13
13
  --rebilly-fontWeightBase: 500;
14
14
  --rebilly-fontLineHeightBase: calc(16px * 1.5);
@@ -49,7 +49,7 @@ const properties = {
49
49
  fontFamily: {
50
50
  fallback: {
51
51
  type: 'static',
52
- value: "-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial sans-serif",
52
+ value: 'Avenir, Helvetica, Arial, sans-serif',
53
53
  }
54
54
  },
55
55
  fontSizeBase: {
@@ -6,8 +6,7 @@ export default class BaseIframe {
6
6
  url = '',
7
7
  model = {},
8
8
  container = null,
9
- classListArray = [],
10
- route = null,
9
+ classListArray = []
11
10
  } = {}) {
12
11
  classListArray = Array.isArray(classListArray) ? classListArray : [];
13
12
  if (!classListArray.includes('rebilly-instruments-iframe')) {
@@ -23,11 +22,6 @@ export default class BaseIframe {
23
22
 
24
23
  return (async () => {
25
24
  this.component = await this.createComponent();
26
-
27
- if (route) {
28
- this.component.call('route', route);
29
- }
30
-
31
25
  return this;
32
26
  })();
33
27
  }
@@ -1,9 +1,9 @@
1
1
  import state from '../state';
2
2
  import iframes from '../state/iframes';
3
- import { mountForm } from './form';
4
3
  import { updateSummary } from './summary';
5
- import { purchase} from '../functions/purchase';
6
- import { setup } from '../functions/setup';
4
+
5
+ export const baseConfirmationHTML =
6
+ '<div class="rebilly-instruments-confirmation"></div>';
7
7
 
8
8
  export async function mountConfirmation({ payload: instrument }) {
9
9
  if (
@@ -14,10 +14,7 @@ export async function mountConfirmation({ payload: instrument }) {
14
14
  }
15
15
 
16
16
  const iframe = iframes.form;
17
- if (!iframe) {
18
- await mountForm();
19
- }
20
-
17
+
21
18
  const modelSafeState = state.toModel();
22
19
  const model = {
23
20
  options: modelSafeState.options,
@@ -32,11 +29,15 @@ export async function mountConfirmation({ payload: instrument }) {
32
29
 
33
30
  iframe?.component?.call('update', model);
34
31
 
35
- iframe?.component?.on(`${iframe.name}-confirm-purchase`, (confirmedInstrument) => {
36
- purchase({ payload: confirmedInstrument });
37
- });
38
-
39
- iframe?.component?.on(`${iframe.name}-confirm-setup`, (confirmedInstrument) => {
40
- setup({ payload: confirmedInstrument });
41
- });
32
+ document.querySelectorAll('[data-rebilly-instruments="express-method"]')
33
+ .forEach(el => {
34
+ el.style.overflow = 'hidden';
35
+ el.style.height = '0px';
36
+ });
37
+ document.querySelectorAll('[data-rebilly-instruments="bump-offer"]')
38
+ .forEach(el => {
39
+ el.style.overflow = 'hidden';
40
+ el.style.height = '0px';
41
+ el.style.marginBottom = '0px';
42
+ })
42
43
  }
@@ -105,28 +105,77 @@ exports[`Methods Selector Component should inject the proper HTML for express me
105
105
 
106
106
  <div
107
107
  class="rebilly-instruments-content"
108
- data-rebilly-instruments="content"
109
108
  >
110
109
 
111
110
 
112
111
  <div
113
- data-rebilly-instruments="content-error"
114
112
  id="rebilly-instruments-error"
115
113
  />
116
114
 
117
115
 
116
+
118
117
  <div
119
- data-rebilly-instruments="form"
118
+ class="rebilly-instruments-method-selector "
119
+ data-rebilly-instruments="express-method"
120
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
- />
121
+
122
+
123
+ <div
124
+ class="rebilly-instruments-express-methods "
125
+ >
126
+
127
+
128
+ <span
129
+ class="rebilly-instruments-express-methods-label"
130
+ data-rebilly-i18n="form.expressCheckout"
131
+ >
132
+ Express checkout
133
+ </span>
134
+
135
+
136
+ <div
137
+ class="rebilly-instruments-express-methods-container"
138
+ >
139
+
140
+
141
+ <div
142
+ class="rebilly-instruments-google-pay-method"
143
+ />
144
+
145
+
146
+ </div>
147
+
148
+
149
+ </div>
150
+
151
+
152
+ <div
153
+ class="rebilly-instruments-divider"
154
+ data-rebilly-instruments="divider"
155
+ style="display: none;"
156
+ >
157
+
158
+
159
+ <span
160
+ class="rebilly-instruments-divider-label"
161
+ data-rebilly-i18n="form.or"
162
+ >
163
+ Or
164
+ </span>
165
+
166
+
167
+ </div>
168
+
169
+
128
170
  </div>
129
171
 
172
+
173
+ <div
174
+ class="rebilly-instruments-methods"
175
+ data-rebilly-instruments="methods"
176
+ style="display: none;"
177
+ />
178
+
130
179
 
131
180
  </div>
132
181
 
@@ -1,7 +1,7 @@
1
1
  import state from '../../state';
2
2
  import { getMethodData } from './get-method-data';
3
3
 
4
- export function generateDigitalWallet({ expressMethods = [] }) {
4
+ export function generateDigitalWallet({ EXPRESS_METHODS }) {
5
5
  const output = {};
6
6
 
7
7
  const { paymentInstruments } = state.options;
@@ -20,7 +20,7 @@ export function generateDigitalWallet({ expressMethods = [] }) {
20
20
  transactionData.currency = currency;
21
21
  }
22
22
 
23
- expressMethods.forEach(method => {
23
+ EXPRESS_METHODS.forEach(method => {
24
24
  const { METHOD_TYPE } = getMethodData(method);
25
25
 
26
26
  if (method.feature?.name === 'Google Pay') {
@@ -38,6 +38,11 @@ describe('generateDigitalWallet', () => {
38
38
  });
39
39
  }
40
40
 
41
+ const summary = new SummaryModel({
42
+ currency: 'USD',
43
+ total: 1,
44
+ });
45
+
41
46
  it('should generate the correct digital wallet config for Google pay', () => {
42
47
  const expressMethods = [
43
48
  new ReadyToPayModel({
@@ -52,7 +57,10 @@ describe('generateDigitalWallet', () => {
52
57
  ];
53
58
  setupState();
54
59
 
55
- const output = generateDigitalWallet({expressMethods});
60
+ const output = generateDigitalWallet({
61
+ EXPRESS_METHODS: expressMethods,
62
+ summary
63
+ });
56
64
 
57
65
  const expectedOutput ={
58
66
  googlePay: {
@@ -92,7 +100,10 @@ describe('generateDigitalWallet', () => {
92
100
  ];
93
101
  setupState();
94
102
 
95
- const output = generateDigitalWallet({expressMethods});
103
+ const output = generateDigitalWallet({
104
+ EXPRESS_METHODS: expressMethods,
105
+ summary
106
+ });
96
107
 
97
108
  const expectedOutput = {
98
109
  applePay: {
@@ -2,20 +2,20 @@ import state from '../../state';
2
2
 
3
3
  export function getPaymentMethods() {
4
4
  const result = {
5
- expressMethods: [],
6
- methods: []
5
+ EXPRESS_METHODS: [],
6
+ METHODS: []
7
7
  };
8
8
 
9
9
  state.data.readyToPay?.forEach((method) => {
10
10
  if (method.metadata.isExpressMethod) {
11
- result.expressMethods.push(method);
11
+ result.EXPRESS_METHODS.push(method);
12
12
  } else {
13
- result.methods.push(method);
13
+ result.METHODS.push(method);
14
14
  }
15
15
  });
16
16
 
17
17
  if (!window.ApplePaySession) {
18
- result.expressMethods = result.expressMethods.filter(method => method?.feature?.name !== 'Apple Pay');
18
+ result.EXPRESS_METHODS = result.EXPRESS_METHODS.filter(method => method?.feature?.name !== 'Apple Pay');
19
19
  state.loader.stopLoading({ id: 'applePay-express' });
20
20
  }
21
21