@rebilly/framepay-react 4.0.6 → 5.0.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 (59) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/index.d.ts +1 -1
  3. package/build/index.spec.js +1 -1
  4. package/build/lib/components/elements/applepay-element.js +2 -2
  5. package/build/lib/components/elements/bank-element.js +3 -3
  6. package/build/lib/components/elements/base-element.js +14 -13
  7. package/build/lib/components/elements/card-element.js +3 -3
  8. package/build/lib/components/elements/googlepay-element.js +2 -2
  9. package/build/lib/components/elements/iban-element.js +4 -4
  10. package/build/lib/components/elements/paypal-element.js +2 -2
  11. package/build/lib/components/injector.js +20 -20
  12. package/build/lib/components/provider.js +11 -11
  13. package/build/lib/constants.js +1 -1
  14. package/build/lib/context.js +2 -4
  15. package/build/lib/dom-util.js +1 -5
  16. package/build/lib/framepay-error.d.ts +1 -1
  17. package/build/lib/framepay-error.js +4 -4
  18. package/build/lib/get-rebilly-api.js +2 -2
  19. package/package.json +6 -16
  20. package/src/index.spec.ts +1 -1
  21. package/src/index.ts +3 -3
  22. package/src/lib/components/elements/applepay-element.tsx +2 -2
  23. package/src/lib/components/elements/bank-element.spec.tsx +12 -12
  24. package/src/lib/components/elements/bank-element.tsx +4 -4
  25. package/src/lib/components/elements/base-element.tsx +16 -16
  26. package/src/lib/components/elements/card-element.spec.tsx +13 -13
  27. package/src/lib/components/elements/card-element.tsx +4 -4
  28. package/src/lib/components/elements/googlepay-element.tsx +2 -2
  29. package/src/lib/components/elements/iban-element.spec.tsx +9 -9
  30. package/src/lib/components/elements/iban-element.tsx +4 -4
  31. package/src/lib/components/elements/paypal-element.tsx +2 -2
  32. package/src/lib/components/injector.spec.tsx +3 -4
  33. package/src/lib/components/injector.tsx +50 -48
  34. package/src/lib/components/provider.spec.tsx +5 -7
  35. package/src/lib/components/provider.tsx +15 -15
  36. package/src/lib/constants.ts +1 -1
  37. package/src/lib/context.ts +1 -3
  38. package/src/lib/dom-util.ts +0 -4
  39. package/src/lib/framepay-error.ts +9 -6
  40. package/src/lib/get-rebilly-api.ts +1 -1
  41. package/test/e2e/cypress-support.js +1 -1
  42. package/test/e2e/fixtures/apple-pay.js +4 -8
  43. package/test/e2e/fixtures/bank-separate.js +68 -67
  44. package/test/e2e/fixtures/card-separate-brands.js +256 -139
  45. package/test/e2e/fixtures/card-separate-rebilly-fields.js +48 -57
  46. package/test/e2e/fixtures/card-separate.js +214 -112
  47. package/test/e2e/fixtures/checkout-combined.js +145 -95
  48. package/test/e2e/fixtures/google-pay.js +6 -10
  49. package/test/e2e/fixtures/iban.js +47 -45
  50. package/test/e2e/fixtures/multiple-methods.js +104 -98
  51. package/test/e2e/fixtures/nav.js +3 -4
  52. package/test/e2e/fixtures/paypal.js +5 -12
  53. package/test/e2e/fixtures/util.js +50 -37
  54. package/test/e2e/specs/card-separate-brands.cy.ts +2 -2
  55. package/test/e2e/specs/react-version.cy.ts +1 -1
  56. package/test/e2e/switch-react-version.js +5 -6
  57. package/test/unit/jest.config.js +18 -28
  58. package/test/unit/specs/declaration-mock.spec.tsx +1 -0
  59. package/tslint.json +0 -36
@@ -18,11 +18,11 @@ const params = {
18
18
  fontStretch: 'none',
19
19
  fontSomething: 'not-included',
20
20
  fontOtherThing: 'not-included',
21
- lineHeight: '20px'
21
+ lineHeight: '20px',
22
22
  },
23
23
  invalid: {
24
- fontWeight: 'bold'
25
- }
24
+ fontWeight: 'bold',
25
+ },
26
26
  },
27
27
  classes: {
28
28
  base: 'rebilly-framepay',
@@ -30,13 +30,13 @@ const params = {
30
30
  valid: 'rebilly-framepay-valid',
31
31
  invalid: 'rebilly-framepay-invalid',
32
32
  buttons: 'rebilly-framepay-buttons',
33
- webkitAutofill: 'rebilly-framepay-webkit-autofill'
33
+ webkitAutofill: 'rebilly-framepay-webkit-autofill',
34
34
  },
35
35
  icon: {
36
36
  foobar: 123,
37
37
  display: true,
38
- color: 'blue'
39
- }
38
+ color: 'blue',
39
+ },
40
40
  };
41
41
 
42
42
  class CardElementComponent extends Component {
@@ -48,25 +48,25 @@ class CardElementComponent extends Component {
48
48
  onReady: null,
49
49
  onChange: null,
50
50
  onFocus: null,
51
- onBlur: null
51
+ onBlur: null,
52
52
  },
53
53
  cvv: {
54
54
  onReady: null,
55
55
  onChange: null,
56
56
  onFocus: null,
57
- onBlur: null
57
+ onBlur: null,
58
58
  },
59
59
  expiry: {
60
60
  onReady: null,
61
61
  onChange: null,
62
62
  onFocus: null,
63
- onBlur: null
64
- }
63
+ onBlur: null,
64
+ },
65
65
  },
66
66
  token: {
67
67
  error: null,
68
- data: null
69
- }
68
+ data: null,
69
+ },
70
70
  };
71
71
  this.handleSubmit = this.handleSubmit.bind(this);
72
72
  }
@@ -79,19 +79,19 @@ class CardElementComponent extends Component {
79
79
  *
80
80
  */
81
81
  this.props.Rebilly.createToken(this.formNode, {
82
- billingAddress:{
82
+ billingAddress: {
83
83
  emails: [
84
84
  {
85
85
  label: 'email-extradata',
86
- value: 'email-extradata@email.local'
87
- }
88
- ]
89
- }
86
+ value: 'email-extradata@email.local',
87
+ },
88
+ ],
89
+ },
90
90
  })
91
- .then(data => {
91
+ .then((data) => {
92
92
  this.deepUpdateState({ token: { error: false, data } });
93
93
  })
94
- .catch(err => {
94
+ .catch((err) => {
95
95
  this.deepUpdateState({ token: { error: true, data: err } });
96
96
  });
97
97
  }
@@ -110,7 +110,7 @@ class CardElementComponent extends Component {
110
110
  <div className="example-2">
111
111
  <form
112
112
  id="form"
113
- ref={node => (this.formNode = node)}
113
+ ref={(node) => (this.formNode = node)}
114
114
  method="post"
115
115
  onSubmit={this.handleSubmit}
116
116
  >
@@ -151,29 +151,29 @@ class CardElementComponent extends Component {
151
151
  onReady={() =>
152
152
  this.deepUpdateState({
153
153
  events: {
154
- number: { onReady: true }
155
- }
154
+ number: { onReady: true },
155
+ },
156
156
  })
157
157
  }
158
- onChange={data =>
158
+ onChange={(data) =>
159
159
  this.deepUpdateState({
160
160
  events: {
161
- number: { onChange: data }
162
- }
161
+ number: { onChange: data },
162
+ },
163
163
  })
164
164
  }
165
165
  onFocus={() =>
166
166
  this.deepUpdateState({
167
167
  events: {
168
- number: { onFocus: true }
169
- }
168
+ number: { onFocus: true },
169
+ },
170
170
  })
171
171
  }
172
172
  onBlur={() =>
173
173
  this.deepUpdateState({
174
174
  events: {
175
- number: { onBlur: true }
176
- }
175
+ number: { onBlur: true },
176
+ },
177
177
  })
178
178
  }
179
179
  />
@@ -184,29 +184,29 @@ class CardElementComponent extends Component {
184
184
  onReady={() =>
185
185
  this.deepUpdateState({
186
186
  events: {
187
- cvv: { onReady: true }
188
- }
187
+ cvv: { onReady: true },
188
+ },
189
189
  })
190
190
  }
191
- onChange={data =>
191
+ onChange={(data) =>
192
192
  this.deepUpdateState({
193
193
  events: {
194
- cvv: { onChange: data }
195
- }
194
+ cvv: { onChange: data },
195
+ },
196
196
  })
197
197
  }
198
198
  onFocus={() =>
199
199
  this.deepUpdateState({
200
200
  events: {
201
- cvv: { onFocus: true }
202
- }
201
+ cvv: { onFocus: true },
202
+ },
203
203
  })
204
204
  }
205
205
  onBlur={() =>
206
206
  this.deepUpdateState({
207
207
  events: {
208
- cvv: { onBlur: true }
209
- }
208
+ cvv: { onBlur: true },
209
+ },
210
210
  })
211
211
  }
212
212
  />
@@ -217,29 +217,29 @@ class CardElementComponent extends Component {
217
217
  onReady={() =>
218
218
  this.deepUpdateState({
219
219
  events: {
220
- expiry: { onReady: true }
221
- }
220
+ expiry: { onReady: true },
221
+ },
222
222
  })
223
223
  }
224
- onChange={data =>
224
+ onChange={(data) =>
225
225
  this.deepUpdateState({
226
226
  events: {
227
- expiry: { onChange: data }
228
- }
227
+ expiry: { onChange: data },
228
+ },
229
229
  })
230
230
  }
231
231
  onFocus={() =>
232
232
  this.deepUpdateState({
233
233
  events: {
234
- expiry: { onFocus: true }
235
- }
234
+ expiry: { onFocus: true },
235
+ },
236
236
  })
237
237
  }
238
238
  onBlur={() =>
239
239
  this.deepUpdateState({
240
240
  events: {
241
- expiry: { onBlur: true }
242
- }
241
+ expiry: { onBlur: true },
242
+ },
243
243
  })
244
244
  }
245
245
  />
@@ -259,16 +259,7 @@ const CardElement = withFramePayCardComponent(CardElementComponent);
259
259
  class App extends Component {
260
260
  render() {
261
261
  return (
262
- <FramePayProvider
263
- injectStyle
264
- {...params}
265
- onReady={() => {
266
- //console.log('FramePayProvider.onReady');
267
- }}
268
- onError={err => {
269
- //console.log('FramePayProvider.onError', err);
270
- }}
271
- >
262
+ <FramePayProvider injectStyle {...params}>
272
263
  <div>
273
264
  {ReactVersion()}
274
265
  <CardElement />
@@ -18,11 +18,11 @@ const params = {
18
18
  fontStretch: 'none',
19
19
  fontSomething: 'not-included',
20
20
  fontOtherThing: 'not-included',
21
- lineHeight: '20px'
21
+ lineHeight: '20px',
22
22
  },
23
23
  invalid: {
24
- fontWeight: 'bold'
25
- }
24
+ fontWeight: 'bold',
25
+ },
26
26
  },
27
27
  classes: {
28
28
  base: 'rebilly-framepay',
@@ -30,17 +30,16 @@ const params = {
30
30
  valid: 'rebilly-framepay-valid',
31
31
  invalid: 'rebilly-framepay-invalid',
32
32
  buttons: 'rebilly-framepay-buttons',
33
- webkitAutofill: 'rebilly-framepay-webkit-autofill'
33
+ webkitAutofill: 'rebilly-framepay-webkit-autofill',
34
34
  },
35
35
  icon: {
36
36
  foobar: 123,
37
37
  display: true,
38
- color: 'blue'
39
- }
38
+ color: 'blue',
39
+ },
40
40
  };
41
41
 
42
42
  class CardElementComponent extends Component {
43
-
44
43
  constructor(props) {
45
44
  super(props);
46
45
  this.state = {
@@ -49,32 +48,32 @@ class CardElementComponent extends Component {
49
48
  onReady: null,
50
49
  onChange: null,
51
50
  onFocus: null,
52
- onBlur: null
51
+ onBlur: null,
53
52
  },
54
53
  cvv: {
55
54
  onReady: null,
56
55
  onChange: null,
57
56
  onFocus: null,
58
- onBlur: null
57
+ onBlur: null,
59
58
  },
60
59
  expiry: {
61
60
  onReady: null,
62
61
  onChange: null,
63
62
  onFocus: null,
64
- onBlur: null
65
- }
63
+ onBlur: null,
64
+ },
66
65
  },
67
66
  billingAddress: {
68
67
  firstName: 'first-name-value',
69
68
  lastName: 'last-name-value',
70
69
  address: 'address-value',
71
70
  country: 'GB',
72
- region: 'region-value'
71
+ region: 'region-value',
73
72
  },
74
73
  token: {
75
74
  error: null,
76
- data: null
77
- }
75
+ data: null,
76
+ },
78
77
  };
79
78
  this.handleSubmit = this.handleSubmit.bind(this);
80
79
  }
@@ -87,30 +86,30 @@ class CardElementComponent extends Component {
87
86
  *
88
87
  */
89
88
  const billingAddress = {
90
- ...this.state.billingAddress
89
+ ...this.state.billingAddress,
91
90
  };
92
91
  if (billingAddress.emails) {
93
92
  billingAddress.emails = [
94
93
  {
95
94
  label: 'Email',
96
- value: billingAddress.emails
97
- }
95
+ value: billingAddress.emails,
96
+ },
98
97
  ];
99
98
  }
100
99
  if (billingAddress.phoneNumbers) {
101
100
  billingAddress.phoneNumbers = [
102
101
  {
103
102
  label: 'Phone Number',
104
- value: billingAddress.phoneNumbers
105
- }
103
+ value: billingAddress.phoneNumbers,
104
+ },
106
105
  ];
107
106
  }
108
107
 
109
108
  this.props.Rebilly.createToken(this.formNode, { billingAddress })
110
- .then(data => {
109
+ .then((data) => {
111
110
  this.deepUpdateState({ token: { error: false, data } });
112
111
  })
113
- .catch(err => {
112
+ .catch((err) => {
114
113
  this.deepUpdateState({ token: { error: true, data: err } });
115
114
  });
116
115
  }
@@ -120,108 +119,211 @@ class CardElementComponent extends Component {
120
119
  }
121
120
 
122
121
  render() {
123
- return (<div>
124
- <h2>{this.props.title}</h2>
125
- <h3>FramePay version: {this.props.Rebilly.version}</h3>
126
- <div className="flex-wrapper">
127
- {prettyDebugRender(this.state)}
128
- <div className="example-2">
129
- <form id="form" ref={node => this.formNode = node} method="post" onSubmit={this.handleSubmit}>
130
- <fieldset>
131
- <div className="field">
132
- <input
133
- type="text"
134
- name="firstName"
135
- placeholder="First Name"
136
- defaultValue={this.state.billingAddress.firstName}
137
- onChange={e => {
138
- this.deepUpdateState({ billingAddress: { firstName: e.target.value } });
139
- }}/>
140
- </div>
141
- <div className="field">
142
- <input
143
- type="text"
144
- name="lastName"
145
- placeholder="Last Name"
146
- defaultValue={this.state.billingAddress.lastName}
147
- onChange={e => {
148
- this.deepUpdateState({ billingAddress: { lastName: e.target.value } });
149
- }}/>
150
- </div>
151
- <div className="field">
152
- <input
153
- type="text"
154
- name="email"
155
- placeholder="Email"
156
- defaultValue={this.state.billingAddress.emails}
157
- onChange={e => {
158
- this.deepUpdateState({ billingAddress: { emails: e.target.value } });
159
- }}/>
160
- </div>
161
- <div className="field">
162
- <input
163
- type="text"
164
- name="phone"
165
- placeholder="Phone"
166
- defaultValue={this.state.billingAddress.phoneNumbers}
167
- onChange={e => {
168
- this.deepUpdateState({ billingAddress: { phoneNumbers: e.target.value } });
169
- }}/>
170
- </div>
171
- <div className="field">
172
- <this.props.CardNumberElement
173
- onReady={() => this.deepUpdateState({ events: { number: { onReady: true } } })}
174
- onChange={(data) => this.deepUpdateState({ events: { number: { onChange: data } } })}
175
- onFocus={() => this.deepUpdateState({ events: { number: { onFocus: true } } })}
176
- onBlur={() => this.deepUpdateState({ events: { number: { onBlur: true } } })}
177
- />
178
- </div>
122
+ return (
123
+ <div>
124
+ <h2>{this.props.title}</h2>
125
+ <h3>FramePay version: {this.props.Rebilly.version}</h3>
126
+ <div className="flex-wrapper">
127
+ {prettyDebugRender(this.state)}
128
+ <div className="example-2">
129
+ <form
130
+ id="form"
131
+ ref={(node) => (this.formNode = node)}
132
+ method="post"
133
+ onSubmit={this.handleSubmit}
134
+ >
135
+ <fieldset>
136
+ <div className="field">
137
+ <input
138
+ type="text"
139
+ name="firstName"
140
+ placeholder="First Name"
141
+ defaultValue={
142
+ this.state.billingAddress.firstName
143
+ }
144
+ onChange={(e) => {
145
+ this.deepUpdateState({
146
+ billingAddress: {
147
+ firstName: e.target.value,
148
+ },
149
+ });
150
+ }}
151
+ />
152
+ </div>
153
+ <div className="field">
154
+ <input
155
+ type="text"
156
+ name="lastName"
157
+ placeholder="Last Name"
158
+ defaultValue={
159
+ this.state.billingAddress.lastName
160
+ }
161
+ onChange={(e) => {
162
+ this.deepUpdateState({
163
+ billingAddress: {
164
+ lastName: e.target.value,
165
+ },
166
+ });
167
+ }}
168
+ />
169
+ </div>
170
+ <div className="field">
171
+ <input
172
+ type="text"
173
+ name="email"
174
+ placeholder="Email"
175
+ defaultValue={
176
+ this.state.billingAddress.emails
177
+ }
178
+ onChange={(e) => {
179
+ this.deepUpdateState({
180
+ billingAddress: {
181
+ emails: e.target.value,
182
+ },
183
+ });
184
+ }}
185
+ />
186
+ </div>
187
+ <div className="field">
188
+ <input
189
+ type="text"
190
+ name="phone"
191
+ placeholder="Phone"
192
+ defaultValue={
193
+ this.state.billingAddress
194
+ .phoneNumbers
195
+ }
196
+ onChange={(e) => {
197
+ this.deepUpdateState({
198
+ billingAddress: {
199
+ phoneNumbers:
200
+ e.target.value,
201
+ },
202
+ });
203
+ }}
204
+ />
205
+ </div>
206
+ <div className="field">
207
+ <this.props.CardNumberElement
208
+ onReady={() =>
209
+ this.deepUpdateState({
210
+ events: {
211
+ number: { onReady: true },
212
+ },
213
+ })
214
+ }
215
+ onChange={(data) =>
216
+ this.deepUpdateState({
217
+ events: {
218
+ number: { onChange: data },
219
+ },
220
+ })
221
+ }
222
+ onFocus={() =>
223
+ this.deepUpdateState({
224
+ events: {
225
+ number: { onFocus: true },
226
+ },
227
+ })
228
+ }
229
+ onBlur={() =>
230
+ this.deepUpdateState({
231
+ events: {
232
+ number: { onBlur: true },
233
+ },
234
+ })
235
+ }
236
+ />
237
+ </div>
179
238
 
180
- <div className="field">
181
- <this.props.CardCvvElement
182
- onReady={() => this.deepUpdateState({ events: { cvv: { onReady: true } } })}
183
- onChange={(data) => this.deepUpdateState({ events: { cvv: { onChange: data } } })}
184
- onFocus={() => this.deepUpdateState({ events: { cvv: { onFocus: true } } })}
185
- onBlur={() => this.deepUpdateState({ events: { cvv: { onBlur: true } } })}
186
- />
187
- </div>
239
+ <div className="field">
240
+ <this.props.CardCvvElement
241
+ onReady={() =>
242
+ this.deepUpdateState({
243
+ events: {
244
+ cvv: { onReady: true },
245
+ },
246
+ })
247
+ }
248
+ onChange={(data) =>
249
+ this.deepUpdateState({
250
+ events: {
251
+ cvv: { onChange: data },
252
+ },
253
+ })
254
+ }
255
+ onFocus={() =>
256
+ this.deepUpdateState({
257
+ events: {
258
+ cvv: { onFocus: true },
259
+ },
260
+ })
261
+ }
262
+ onBlur={() =>
263
+ this.deepUpdateState({
264
+ events: {
265
+ cvv: { onBlur: true },
266
+ },
267
+ })
268
+ }
269
+ />
270
+ </div>
188
271
 
189
- <div className="field">
190
- <this.props.CardExpiryElement
191
- onReady={() => this.deepUpdateState({ events: { expiry: { onReady: true } } })}
192
- onChange={(data) => this.deepUpdateState({ events: { expiry: { onChange: data } } })}
193
- onFocus={() => this.deepUpdateState({ events: { expiry: { onFocus: true } } })}
194
- onBlur={() => this.deepUpdateState({ events: { expiry: { onBlur: true } } })}
195
- />
196
- </div>
197
- </fieldset>
198
- <button id="submit">Make Payment</button>
199
- </form>
272
+ <div className="field">
273
+ <this.props.CardExpiryElement
274
+ onReady={() =>
275
+ this.deepUpdateState({
276
+ events: {
277
+ expiry: { onReady: true },
278
+ },
279
+ })
280
+ }
281
+ onChange={(data) =>
282
+ this.deepUpdateState({
283
+ events: {
284
+ expiry: { onChange: data },
285
+ },
286
+ })
287
+ }
288
+ onFocus={() =>
289
+ this.deepUpdateState({
290
+ events: {
291
+ expiry: { onFocus: true },
292
+ },
293
+ })
294
+ }
295
+ onBlur={() =>
296
+ this.deepUpdateState({
297
+ events: {
298
+ expiry: { onBlur: true },
299
+ },
300
+ })
301
+ }
302
+ />
303
+ </div>
304
+ </fieldset>
305
+ <button id="submit">Make Payment</button>
306
+ </form>
307
+ </div>
200
308
  </div>
201
309
  </div>
202
- </div>);
310
+ );
203
311
  }
204
312
  }
205
313
 
206
314
  const CardElement = withFramePayCardComponent(CardElementComponent);
207
315
 
208
316
  class App extends Component {
209
-
210
317
  render() {
211
- return (<FramePayProvider injectStyle
212
- {...params}
213
- onReady={() => {
214
- //console.log('FramePayProvider.onReady');
215
- }}
216
- onError={(err) => {
217
- //console.log('FramePayProvider.onError', err);
218
- }}>
219
- <div>
220
- {ReactVersion()}
221
- <CardElement/>
222
- </div>
223
- </FramePayProvider>);
318
+ return (
319
+ <FramePayProvider injectStyle {...params}>
320
+ <div>
321
+ {ReactVersion()}
322
+ <CardElement />
323
+ </div>
324
+ </FramePayProvider>
325
+ );
224
326
  }
225
327
  }
226
328
 
227
- ReactDOM.render(<App/>, document.getElementById('app'));
329
+ ReactDOM.render(<App />, document.getElementById('app'));