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