@rebilly/instruments 3.3.2-beta.0 → 3.5.2-beta.0

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.
@@ -0,0 +1,44 @@
1
+ // -----------------------------------------------------------------------------
2
+ // This file contains all styles related to the payment instrument list component.
3
+ // -----------------------------------------------------------------------------
4
+ export const paymentInstrumentList = () => `
5
+ .rebilly-instruments-payment-instrument-list {
6
+ margin: 0;
7
+ padding: 0;
8
+ }
9
+
10
+ .rebilly-instruments-payment-instrument-list > li {
11
+ display: flex;
12
+ width: 100%;
13
+ align-items: center;
14
+ list-style-type: none;
15
+ padding: var(--rebilly-spacings-xs) 0;
16
+ }
17
+
18
+ .rebilly-instruments-payment-instrument-list > li:first-child {
19
+ padding-top: 0;
20
+ }
21
+
22
+ .rebilly-instruments-payment-instrument-list > li:last-child {
23
+ padding-bottom: 0;
24
+ }
25
+
26
+ .rebilly-instruments-payment-instrument-list > li + li {
27
+ border-top: 1px solid var(--rebilly-colorMutedBorder);
28
+ }
29
+
30
+ .rebilly-instruments-payment-instrument-list.is-relaxed > li {
31
+ min-height: var(--rebilly-spacings-form-element-min-height);
32
+ }
33
+
34
+ .rebilly-instruments-payment-instrument-list .rebilly-instruments-form-field {
35
+ width: 100%;
36
+ }
37
+
38
+ .rebilly-instruments-payment-instrument-list > li .rebilly-instruments-payment-instrument-list-container {
39
+ display: flex;
40
+ justify-content: space-between;
41
+ align-items: center;
42
+ width: 100%;
43
+ }
44
+ `;
@@ -0,0 +1,49 @@
1
+ // -----------------------------------------------------------------------------
2
+ // This file contains all styles related to the payment instrument component.
3
+ // -----------------------------------------------------------------------------
4
+ export const paymentInstrument = () => `
5
+ .rebilly-instruments-payment-instrument {
6
+ display: inline-flex;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ height: 26px;
10
+ margin: 0 0 var(--rebilly-spacings-l);
11
+ }
12
+
13
+ .rebilly-instruments-payment-instrument figure {
14
+ margin: 0 var(--rebilly-spacings-2xs) 0 0;
15
+ height: 26px;
16
+ padding: 0;
17
+ }
18
+
19
+ .rebilly-instruments-payment-instrument figure img {
20
+ width: auto;
21
+ height: 100%;
22
+ border-radius: 4px;
23
+ }
24
+
25
+ .rebilly-instruments-payment-instrument-brand,
26
+ .rebilly-instruments-payment-instrument-exp,
27
+ .rebilly-instruments-payment-instrument-last4 {
28
+ display: inline-block;
29
+ white-space: nowrap;
30
+ }
31
+
32
+ .rebilly-instruments-payment-instrument-brand {
33
+ margin: 0 0 0 var(--rebilly-spacings-s);
34
+ }
35
+
36
+ .rebilly-instruments-payment-instrument-last4 {
37
+ margin: 0 var(--rebilly-spacings-s);
38
+ }
39
+
40
+ .rebilly-instruments-payment-instrument-exp {
41
+ color: var(--rebilly-colorMutedText);
42
+ }
43
+
44
+ @media screen and (max-width: 480px) {
45
+ .rebilly-instruments-payment-instrument-exp {
46
+ display: none;
47
+ }
48
+ }
49
+ `;
@@ -23,55 +23,4 @@ export const confirmation = () => `
23
23
  .rebilly-instruments-confirmation-address-title .rebilly-instruments-link {
24
24
  margin-left: var(--rebilly-spacings-s);
25
25
  }
26
-
27
- .rebilly-instruments-confirmation-address-actions {
28
- margin-top: var(--rebilly-spacings-base);
29
- display: flex;
30
- }
31
-
32
- .rebilly-instruments-confirmation-address-actions :first-child {
33
- margin: 0 var(--rebilly-spacings-xs) 0 0;
34
- }
35
-
36
- .rebilly-instruments-confirmation-address-actions :last-child {
37
- margin: 0 0 0 var(--rebilly-spacings-xs);
38
- }
39
-
40
- .rebilly-instruments-confirmation-payment-method {
41
- display: inline-flex;
42
- align-items: center;
43
- justify-content: space-between;
44
- height: 26px;
45
- margin: 0 0 var(--rebilly-spacings-l);
46
- }
47
-
48
- .rebilly-instruments-confirmation-payment-method figure {
49
- margin: 0 var(--rebilly-spacings-2xs) 0 0;
50
- height: 26px;
51
- padding: 0;
52
- }
53
-
54
- .rebilly-instruments-confirmation-payment-method figure img {
55
- width: auto;
56
- height: 100%;
57
- border-radius: 4px;
58
- }
59
-
60
- .rebilly-instruments-confirmation-payment-method-brand,
61
- .rebilly-instruments-confirmation-payment-method-exp,
62
- .rebilly-instruments-confirmation-payment-method-last4 {
63
- display: inline-block;
64
- }
65
-
66
- .rebilly-instruments-confirmation-payment-method-brand {
67
- margin: 0 0 0 var(--rebilly-spacings-s);
68
- }
69
-
70
- .rebilly-instruments-confirmation-payment-method-last4 {
71
- margin: 0 var(--rebilly-spacings-s);
72
- }
73
-
74
- .rebilly-instruments-confirmation-payment-method-exp {
75
- color: var(--rebilly-colorMutedText);
76
- }
77
26
  `;
@@ -43,7 +43,9 @@ export default function mountApplePay({
43
43
  Rebilly.initialize({
44
44
  publishableKey: state.options.publishableKey,
45
45
  organizationId: state.options.organizationId,
46
- digitalWallet
46
+ transactionData: digitalWallet.transactionData,
47
+ methods: state.data.readyToPay,
48
+ applePay: digitalWallet.applePayDisplayOptions,
47
49
  });
48
50
  } else {
49
51
  mountApplePayButton();
@@ -75,4 +77,4 @@ export default function mountApplePay({
75
77
  Rebilly.on('error', error => {
76
78
  console.error(error)
77
79
  });
78
- }
80
+ }
@@ -33,8 +33,8 @@ function displayBrands({summary, method}) {
33
33
  }
34
34
 
35
35
  const {brands} = method;
36
- summary.insertAdjacentHTML(
37
- 'beforeend',
36
+ summary.querySelector('.rebilly-instruments-accordion-title').insertAdjacentHTML(
37
+ 'afterend',
38
38
  `<div class="rebilly-instruments-accordion-brands">${(() => {
39
39
  if (brands.length >= 4) {
40
40
  const truncatedBrands = brands.slice(0, 3);
@@ -69,7 +69,8 @@ export function MountMethods({
69
69
  mainStyle: state.mainStyle,
70
70
  plans: state.data.plans,
71
71
  products: state.data.products,
72
- method
72
+ method,
73
+ readyToPay: state.data.readyToPay,
73
74
  };
74
75
 
75
76
  if (isAccordion) {
@@ -77,9 +78,9 @@ export function MountMethods({
77
78
  'beforeend',
78
79
  `<details class="rebilly-instruments-accordion for-${methodId}">
79
80
  <summary class="rebilly-instruments-accordion-summary">
80
- <span class="rebilly-instruments-accordion-summary-radio"></span>
81
81
  <img class="rebilly-instruments-accordion-${method.method}-img" src="${method.metadata.logo}" alt="${method.method}"/>
82
82
  <span class="rebilly-instruments-accordion-title" data-rebilly-i18n="paymentMethods.${method.method}">${method.metadata.name}</span>
83
+ <span class="rebilly-instruments-accordion-summary-checkmark"></span>
83
84
  </summary>
84
85
  <div id="${selector}" data-rebilly-instruments-type="${methodId}"></div>
85
86
  </details>`
@@ -137,7 +138,6 @@ export function MountMethods({
137
138
  );
138
139
  const container = document.querySelector(`#${selector}`);
139
140
 
140
- state.loader.stopLoading({ id: method.method });
141
141
  mountInline(state, {
142
142
  methodId,
143
143
  paymentMethodsUrl,
@@ -146,6 +146,7 @@ export function MountMethods({
146
146
  method
147
147
  });
148
148
  }
149
+ state.loader.stopLoading({ id: method.method });
149
150
  });
150
151
 
151
152
  if (isAccordion) {
@@ -153,7 +154,7 @@ export function MountMethods({
153
154
  const details = document.querySelectorAll('.rebilly-instruments-accordion');
154
155
  // Add the onclick listeners.
155
156
  details.forEach((targetDetail) => {
156
- targetDetail.addEventListener('click', () => {
157
+ targetDetail.querySelector('summary').addEventListener('click', () => {
157
158
  // Close all the accordion that are not targetDetail.
158
159
  details.forEach((detail) => {
159
160
  detail.removeAttribute('open');
@@ -8,7 +8,18 @@ import ProductModel from '@/storefront/models/product-model';
8
8
  import SummaryModel from '@/storefront/models/summary-model';
9
9
  import InvoiceModel from '@/storefront/models/invoice-model';
10
10
  import merge from 'lodash.merge';
11
- import { DataInstance } from '../../src/functions/mount/fetch-data';
11
+ import { DataInstance } from 'src/functions/mount/fetch-data';
12
+ import { sleep } from 'src/utils';
13
+ import setupFramepay from 'src/functions/mount/setup-framepay';
14
+
15
+ export const setupFramepayMock = async () => {
16
+ /*
17
+ * onload() is never called in JSDOM context but we want to test the rest of the setupFramepay code,
18
+ * so we run it asynchonously and wait for 10 ms
19
+ */
20
+ setupFramepay()
21
+ await sleep(10);
22
+ }
12
23
 
13
24
  export async function RenderMockRebillyInstruments(options = {}) {
14
25
  const testInvoice = new InvoiceModel({
@@ -34,14 +45,11 @@ export async function RenderMockRebillyInstruments(options = {}) {
34
45
  const framePayStyleUrl = 'https://dev.framepay.rebilly.com/rebilly.css';
35
46
 
36
47
  when(get(`${storefrontURL}/invoices/*`)).thenReturn(
37
- (() => {
38
- return ok(testInvoice);
39
- })()
48
+ (() => ok(testInvoice))()
40
49
  );
41
50
 
42
51
  when(post(`${storefrontURL}/ready-to-pay`)).thenReturn(
43
- (() => {
44
- return ok([
52
+ (() => ok([
45
53
  {
46
54
  method: 'payment-card',
47
55
  feature: {
@@ -52,26 +60,19 @@ export async function RenderMockRebillyInstruments(options = {}) {
52
60
  brands: ['Visa', 'MasterCard', 'American Express', 'Discover'],
53
61
  filters: []
54
62
  }
55
- ]);
56
- })()
63
+ ]))()
57
64
  );
58
65
 
59
66
  when(post(`${storefrontURL}/preview-purchase`)).thenReturn(
60
- (() => {
61
- return ok(testSummary);
62
- })()
67
+ (() => ok(testSummary))()
63
68
  );
64
69
 
65
70
  when(get(`${storefrontURL}/plans`)).thenReturn(
66
- (() => {
67
- return ok([testPlan]);
68
- })()
71
+ (() => ok([testPlan]))()
69
72
  );
70
73
 
71
74
  when(get(`${storefrontURL}/products`)).thenReturn(
72
- (() => {
73
- return ok([testProduct]);
74
- })()
75
+ (() => ok([testProduct]))()
75
76
  );
76
77
 
77
78
  const defaultOptions = {
@@ -111,7 +112,10 @@ export async function RenderMockRebillyInstruments(options = {}) {
111
112
  <div class="${mergedOptions.summary.replace('.', '')}"></div>
112
113
  `;
113
114
 
114
- await rebillyInstruments.mount(mergedOptions);
115
+ await rebillyInstruments.mount({
116
+ setupFramepay: setupFramepayMock,
117
+ ...mergedOptions,
118
+ });
115
119
 
116
120
  rebillyInstruments.mock = {
117
121
  data: (data) => {