@rebilly/instruments 3.2.1-beta.0 → 3.4.0-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.
Files changed (37) hide show
  1. package/dist/index.js +13 -13
  2. package/dist/index.min.js +13 -13
  3. package/package.json +1 -1
  4. package/src/functions/mount/index.js +5 -3
  5. package/src/functions/mount/mount.spec.js +5 -7
  6. package/src/functions/mount/setup-framepay-theme.js +44 -21
  7. package/src/functions/mount/setup-framepay.js +17 -38
  8. package/src/functions/mount/setup-options.js +6 -1
  9. package/src/functions/mount/setup-options.spec.js +1 -2
  10. package/src/functions/purchase.js +13 -4
  11. package/src/functions/setup.js +20 -2
  12. package/src/i18n/en.json +3 -1
  13. package/src/i18n/es.json +3 -1
  14. package/src/instance.spec.js +4 -2
  15. package/src/storefront/index.js +11 -9
  16. package/src/storefront/invoices.js +1 -1
  17. package/src/storefront/models/payment-metadata.js +7 -0
  18. package/src/storefront/models/ready-to-pay-model.js +6 -1
  19. package/src/storefront/payment-instruments.js +2 -2
  20. package/src/storefront/ready-to-pay.js +19 -5
  21. package/src/storefront/transactions.js +1 -1
  22. package/src/style/components/accordion.js +127 -0
  23. package/src/style/components/button.js +20 -0
  24. package/src/style/components/forms/checkbox.js +17 -19
  25. package/src/style/components/forms/form.js +1 -2
  26. package/src/style/components/forms/radio.js +80 -0
  27. package/src/style/components/index.js +5 -1
  28. package/src/style/helpers/index.js +3 -0
  29. package/src/style/payment-instruments/index.js +4 -0
  30. package/src/style/payment-instruments/payment-instrument-list.js +44 -0
  31. package/src/style/payment-instruments/payment-instrument.js +43 -0
  32. package/src/style/views/confirmation.js +0 -51
  33. package/src/views/method-selector/get-payment-methods.js +1 -1
  34. package/src/views/method-selector/mount-methods.js +126 -23
  35. package/tests/mocks/rebilly-api-mock.js +9 -0
  36. package/tests/mocks/rebilly-instruments-mock.js +22 -18
  37. package/tests/msw/server.js +2 -0
@@ -0,0 +1,127 @@
1
+ import { lighten } from '../utils/color-values';
2
+
3
+ // -----------------------------------------------------------------------------
4
+ // This file contains all styles related to the accordion component.
5
+ // -----------------------------------------------------------------------------
6
+
7
+ export const accordion = (theme) => `
8
+ /* ACCORDION CLOSED */
9
+ .rebilly-instruments-accordion {
10
+ border: 1px solid var(--rebilly-colorMutedBorder);
11
+ padding: 0 calc(var(--rebilly-spacings-m) - 4px);
12
+ background: var(--rebilly-colorBackground);
13
+ transition: border 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
14
+ margin: var(--rebilly-spacings-s) 0;
15
+ border-radius: var(--rebilly-borderRadius);
16
+ overflow: hidden;
17
+ cursor: pointer;
18
+ opacity: 0.8;
19
+ }
20
+
21
+ .rebilly-instruments-accordion:hover {
22
+ opacity: 1;
23
+ }
24
+
25
+ .rebilly-instruments-accordion:first-of-type {
26
+ margin-top: 0;
27
+ }
28
+
29
+ .rebilly-instruments-accordion:last-of-type {
30
+ margin-bottom: 0;
31
+ }
32
+
33
+ .rebilly-instruments-accordion .rebilly-instruments-accordion-summary::-webkit-details-marker {
34
+ display: none;
35
+ }
36
+
37
+ .rebilly-instruments-accordion .rebilly-instruments-accordion-summary {
38
+ display: flex;
39
+ align-items: center;
40
+ list-style: none;
41
+ padding: calc(var(--rebilly-spacings-m) - 14px) calc(var(--rebilly-spacings-m) - 4px);
42
+ margin: 0px calc(-1 * calc(var(--rebilly-spacings-m) - 4px));
43
+ background: var(--rebilly-colorBackground);
44
+ }
45
+
46
+ .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-summary-checkmark {
47
+ position: relative;
48
+ width: calc(var(--rebilly-spacings-m) - 4px);
49
+ height: calc(var(--rebilly-spacings-m) - 4px);
50
+ border-radius: 50%;
51
+ background: ${lighten(theme.colorText, 60)};
52
+ margin-left: var(--rebilly-spacings-m);
53
+ transition: all 0.2s ease;
54
+ }
55
+
56
+ .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-summary-checkmark::after {
57
+ content: '';
58
+ position: absolute;
59
+ border: solid var(--rebilly-colorBackground);
60
+ width: calc(var(--rebilly-spacings-xs) + 2px);
61
+ height: calc(var(--rebilly-spacings-xs) - 2px);
62
+ border-width: 2px 2px 0 0;
63
+ border-radius: 2px;
64
+ top: 50%;
65
+ left: 50%;
66
+ transform: translateY(-60%) translateX(-50%) rotate(135deg);
67
+ transition: all 0.2s ease;
68
+ }
69
+
70
+ .rebilly-instruments-accordion-summary:hover .rebilly-instruments-accordion-summary-checkmark {
71
+ background: var(--rebilly-colorText);
72
+ }
73
+
74
+ .rebilly-instruments-accordion .rebilly-instruments-accordion-summary img {
75
+ margin-right: var(--rebilly-spacings-s);
76
+ height: auto;
77
+ max-width: 40px;
78
+ width: 100%;
79
+ }
80
+
81
+ .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-title {
82
+ margin: 0;
83
+ font-weight: 500;
84
+ flex: 2;
85
+ }
86
+
87
+ .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-brands {
88
+ display: inline-flex;
89
+ justify-content: flex-end;
90
+ align-items: center;
91
+ }
92
+
93
+ .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-brands figure {
94
+ margin: auto;
95
+ padding: 0;
96
+ height: 26px;
97
+ }
98
+
99
+ .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-brands figure img {
100
+ width: auto;
101
+ height: 100%;
102
+ border-radius: 4px;
103
+ margin-right: var(--rebilly-spacings-xs);
104
+ }
105
+
106
+ .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-brands span {
107
+ color: var(--rebilly-colorMutedText);
108
+ margin: 0 0 0 var(--rebilly-spacings-xs);
109
+ font-size: calc(var(--rebilly-fontSizeBase) * 0.875);
110
+ line-height: 1;
111
+ }
112
+
113
+ /* ACCORDION OPENED */
114
+ .rebilly-instruments-accordion[open] {
115
+ padding: 0 calc(var(--rebilly-spacings-m) - 4px) calc(var(--rebilly-spacings-m) - 4px);
116
+ opacity: 1;
117
+ }
118
+
119
+ .rebilly-instruments-accordion[open] .rebilly-instruments-accordion-summary {
120
+ border-bottom: 1px solid var(--rebilly-colorMutedBorder);
121
+ margin-bottom: calc(var(--rebilly-spacings-m) - 4px);
122
+ }
123
+
124
+ .rebilly-instruments-accordion[open] .rebilly-instruments-accordion-summary .rebilly-instruments-accordion-summary-checkmark {
125
+ background: ${theme.colorPrimary};
126
+ }
127
+ `;
@@ -50,6 +50,9 @@ export const button = () => `
50
50
  }
51
51
 
52
52
  .rebilly-instruments-button.rebilly-instruments-button-secondary {
53
+ font-size: var(--rebilly-buttonFontSize);
54
+ font-family: var(--rebilly-buttonFontFamily);
55
+ line-height: var(--rebilly-buttonFontLineHeight);
53
56
  background: var(--rebilly-colorBackground);
54
57
  color: var(--rebilly-buttonColorBackground);
55
58
  border-color: var(--rebilly-buttonColorBackground);
@@ -76,4 +79,21 @@ export const button = () => `
76
79
  .rebilly-instruments-button:first-of-type { margin-top: 0; }
77
80
 
78
81
  .rebilly-instruments-button:last-of-type { margin-bottom: 0; }
82
+
83
+ .rebilly-instruments-button-group {
84
+ display: flex;
85
+ align-items: center;
86
+ }
87
+
88
+ .rebilly-instruments-button-group .rebilly-instruments-button {
89
+ margin: 0 var(--rebilly-spacings-xs);
90
+ }
91
+
92
+ .rebilly-instruments-button-group .rebilly-instruments-button:first-of-type {
93
+ margin-left: 0;
94
+ }
95
+
96
+ .rebilly-instruments-button-group .rebilly-instruments-button:last-of-type {
97
+ margin-right: 0;
98
+ }
79
99
  `;
@@ -1,8 +1,7 @@
1
- import { lighten } from '../../utils/color-values';
2
1
  // -----------------------------------------------------------------------------
3
2
  // This file contains all styles related to the checkbox component.
4
3
  // -----------------------------------------------------------------------------
5
- export const checkbox = (theme) => `
4
+ export const checkbox = () => `
6
5
  /**
7
6
  * Checkbox
8
7
  */
@@ -33,10 +32,10 @@ export const checkbox = (theme) => `
33
32
  position: relative;
34
33
  top: 0;
35
34
  left: 0;
36
- height: 24px;
37
- width: 24px;
35
+ width: calc(var(--rebilly-spacings-m) - 4px);
36
+ height: calc(var(--rebilly-spacings-m) - 4px);
38
37
  border-radius: 4px;
39
- box-shadow: inset 0 0 0 1px var(--rebilly-colorMutedBorder);
38
+ box-shadow: inset 0 0 0 2px var(--rebilly-colorMutedBorder);
40
39
  margin-right: var(--rebilly-spacings-s);
41
40
  background-color: transparent;
42
41
  transition: all 200ms;
@@ -45,17 +44,20 @@ export const checkbox = (theme) => `
45
44
  .rebilly-instruments-form-field-checkbox span:after {
46
45
  content: '';
47
46
  position: absolute;
48
- left: 9px;
49
- top: 4px;
50
- opacity: 0;
51
- width: 5px;
52
- height: 11px;
53
47
  border: solid var(--rebilly-colorPrimary);
54
- border-width: 0 2px 2px 0;
55
- -webkit-transform: rotate(45deg);
56
- -ms-transform: rotate(45deg);
57
- transform: rotate(45deg);
58
- transition: all 200ms;
48
+ width: calc(var(--rebilly-spacings-xs) + 4px);
49
+ height: calc(var(--rebilly-spacings-xs) - 2px);
50
+ border-width: 2px 2px 0 0;
51
+ border-radius: 2px;
52
+ top: 50%;
53
+ left: 50%;
54
+ opacity: 0;
55
+ transform: translateY(-60%) translateX(-50%) rotate(135deg);
56
+ transition: all 0.2s ease;
57
+ }
58
+
59
+ .rebilly-instruments-form-field-checkbox input[type="checkbox"]:focus ~ span {
60
+ box-shadow: inset 0 0 0 2px var(--rebilly-colorPrimary);
59
61
  }
60
62
 
61
63
  .rebilly-instruments-form-field-checkbox input[type="checkbox"]:checked ~ span {
@@ -66,10 +68,6 @@ export const checkbox = (theme) => `
66
68
  opacity: 1;
67
69
  }
68
70
 
69
- .rebilly-instruments-form-field-checkbox input[type="checkbox"]:focus ~ span {
70
- box-shadow: 0 0 0 2px ${lighten(theme.colorPrimary, 80)}, inset 0 0 0 1px var(--rebilly-colorPrimary);
71
- }
72
-
73
71
  .rebilly-instruments-form-field-checkbox input[type="checkbox"]:disabled ~ span {
74
72
  opacity: 0.6;
75
73
  }
@@ -13,7 +13,6 @@ export const form = () => `
13
13
  .rebilly-instruments-form select:-webkit-autofill:hover,
14
14
  .rebilly-instruments-form select:-webkit-autofill:focus {
15
15
  -webkit-text-fill-color: var(--rebilly-colorText);
16
- -webkit-box-shadow: 0 0 0px 1000px transparent inset;
17
- transition: background-color 5000s ease-in-out 0s;
16
+ transition: background-color 5000s ease-in-out 0s, box-shadow 200ms, border 200ms;
18
17
  }
19
18
  `;
@@ -0,0 +1,80 @@
1
+ // -----------------------------------------------------------------------------
2
+ // This file contains all styles related to the radio component.
3
+ // -----------------------------------------------------------------------------
4
+ export const radio = () => `
5
+ /**
6
+ * Checkbox
7
+ */
8
+ .rebilly-instruments-form-field-radio {
9
+ position: relative;
10
+ opacity: 1;
11
+ align-items: center;
12
+ display: flex;
13
+ flex-direction: row-reverse;
14
+ justify-content: start;
15
+ cursor: pointer;
16
+ transform: none;
17
+ }
18
+
19
+ .rebilly-instruments-form-field-radio > * {
20
+ cursor: pointer;
21
+ }
22
+
23
+ .rebilly-instruments-form-field-radio input[type="radio"] {
24
+ position: absolute;
25
+ opacity: 0;
26
+ cursor: pointer;
27
+ height: 0;
28
+ width: 0;
29
+ }
30
+
31
+ .rebilly-instruments-form-field-radio > span {
32
+ position: relative;
33
+ top: 0;
34
+ left: 0;
35
+ height: calc(var(--rebilly-spacings-m) - 4px);
36
+ width: calc(var(--rebilly-spacings-m) - 4px);
37
+ min-width: calc(var(--rebilly-spacings-m) - 4px);
38
+ border-radius: 50%;
39
+ box-shadow: inset 0 0 0 2px var(--rebilly-colorMutedBorder);
40
+ margin-right: var(--rebilly-spacings-s);
41
+ background-color: transparent;
42
+ transition: all 200ms;
43
+ }
44
+
45
+ .rebilly-instruments-form-field-radio > span:after {
46
+ content: '';
47
+ position: absolute;
48
+ left: 50%;
49
+ top: 50%;
50
+ transform: translateX(-50%) translateY(-50%);
51
+ opacity: 0;
52
+ width: calc(var(--rebilly-spacings-xs) + 4px);
53
+ height: calc(var(--rebilly-spacings-xs) + 4px);
54
+ border-radius: 50%;
55
+ background: var(--rebilly-colorMutedBorder);
56
+ transition: all 200ms;
57
+ }
58
+
59
+ .rebilly-instruments-form-field-radio:hover > span:after {
60
+ opacity: 1;
61
+ }
62
+
63
+ .rebilly-instruments-form-field-radio input[type="radio"]:checked ~ span {
64
+ box-shadow: inset 0 0 0 2px var(--rebilly-colorPrimary);
65
+ }
66
+
67
+ .rebilly-instruments-form-field-radio input[type="radio"]:checked ~ span:after {
68
+ background: var(--rebilly-colorPrimary);
69
+ opacity: 1;
70
+ }
71
+
72
+ .rebilly-instruments-form-field-radio input[type="radio"]:focus ~ span {
73
+ opacity: 1;
74
+ box-shadow: inset 0 0 0 2px var(--rebilly-colorPrimary);
75
+ }
76
+
77
+ .rebilly-instruments-form-field-radio input[type="radio"]:disabled ~ span {
78
+ opacity: 0.6;
79
+ }
80
+ `;
@@ -1,6 +1,7 @@
1
1
  import { expressMethods, methods } from './methods';
2
2
  import { form } from './forms/form';
3
3
  import { checkbox } from './forms/checkbox';
4
+ import { radio } from './forms/radio';
4
5
  import { field } from './forms/field';
5
6
  import { input } from './forms/input';
6
7
  import { label } from './forms/label';
@@ -12,6 +13,7 @@ import { loader } from './loader';
12
13
  import { icons } from './icons';
13
14
  import { address } from './address';
14
15
  import { overlay } from './overlay';
16
+ import { accordion } from './accordion';
15
17
 
16
18
  // Order of components matters for style cascade
17
19
  export const components = (theme) => `
@@ -24,7 +26,8 @@ export const components = (theme) => `
24
26
  ${input(theme)}
25
27
  ${select(theme)}
26
28
  ${label(theme)}
27
- ${checkbox(theme)}
29
+ ${checkbox()}
30
+ ${radio()}
28
31
  ${validation(theme)}
29
32
  ${button(theme)}
30
33
  ${divider(theme)}
@@ -32,4 +35,5 @@ export const components = (theme) => `
32
35
  ${icons(theme)}
33
36
  ${address(theme)}
34
37
  ${overlay(theme)}
38
+ ${accordion(theme)}
35
39
  `;
@@ -48,4 +48,7 @@ export const helpers = () => `
48
48
  .rebilly-instruments-helper-ml-xl { margin-left: var(--rebilly-spacings-xl) !important }
49
49
  .rebilly-instruments-helper-ml-xxl { margin-left: var(--rebilly-spacings-2xl) !important }
50
50
  .rebilly-instruments-helper-ml-0 { margin-left: 0!important }
51
+
52
+ .rebilly-instruments-display-flex { display: flex!important }
53
+ .rebilly-instruments-align-items-center { align-items: center!important }
51
54
  `;
@@ -1,5 +1,7 @@
1
1
  import { methodContent } from './content';
2
2
  import { paymentCard } from './payment-card';
3
+ import { paymentInstrumentList } from './payment-instrument-list';
4
+ import { paymentInstrument } from './payment-instrument';
3
5
 
4
6
  // Order of components matters for style cascade
5
7
  export const paymentInstruments = (theme) => `
@@ -7,4 +9,6 @@ export const paymentInstruments = (theme) => `
7
9
  ------------------------------------------------------------ */
8
10
  ${methodContent()}
9
11
  ${paymentCard(theme)}
12
+ ${paymentInstrument()}
13
+ ${paymentInstrumentList()}
10
14
  `;
@@ -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,43 @@
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
+ `;
@@ -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
  `;
@@ -3,7 +3,7 @@ import { getMethodData } from './get-method-data';
3
3
 
4
4
  const SUPPORTED_EXPRESS_METHODS = ['Google Pay', 'Apple Pay', 'paypal'];
5
5
 
6
- const SUPPORTED_METHODS = ['payment-card'];
6
+ const SUPPORTED_METHODS = ['payment-card', 'ach'];
7
7
 
8
8
  const isExpressMethod = ({ method, feature }) => {
9
9
  return (