@rebilly/framepay-react 5.6.1 → 6.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/.env.example +2 -2
- package/CHANGELOG.md +11 -0
- package/README.md +17 -17
- package/build/lib/components/elements/applepay-element.js +3 -3
- package/build/lib/components/elements/bank-element.js +2 -2
- package/build/lib/components/elements/base-element.js +3 -3
- package/build/lib/components/elements/card-element.js +2 -2
- package/build/lib/components/elements/googlepay-element.js +3 -3
- package/build/lib/components/elements/iban-element.js +2 -2
- package/build/lib/components/elements/paypal-element.js +3 -3
- package/build/lib/components/injector.js +22 -22
- package/build/lib/components/provider.js +4 -4
- package/build/lib/constants.js +3 -3
- package/build/lib/context.js +3 -3
- package/build/lib/framepay-error.js +2 -2
- package/build/lib/get-framepay-api.d.ts +1 -0
- package/build/lib/get-framepay-api.js +14 -0
- package/package.json +2 -2
- package/src/lib/components/elements/applepay-element.tsx +2 -2
- package/src/lib/components/elements/bank-element.spec.tsx +15 -15
- package/src/lib/components/elements/bank-element.tsx +1 -1
- package/src/lib/components/elements/base-element.tsx +2 -2
- package/src/lib/components/elements/card-element.spec.tsx +12 -12
- package/src/lib/components/elements/card-element.tsx +1 -1
- package/src/lib/components/elements/googlepay-element.tsx +2 -2
- package/src/lib/components/elements/iban-element.spec.tsx +12 -12
- package/src/lib/components/elements/iban-element.tsx +1 -1
- package/src/lib/components/elements/paypal-element.tsx +2 -2
- package/src/lib/components/injector.spec.tsx +6 -6
- package/src/lib/components/injector.tsx +22 -22
- package/src/lib/components/provider.tsx +3 -3
- package/src/lib/constants.ts +2 -2
- package/src/lib/context.ts +2 -2
- package/src/lib/framepay-error.ts +1 -1
- package/src/lib/get-framepay-api.ts +11 -0
- package/test/e2e/fixtures/apple-pay.js +1 -1
- package/test/e2e/fixtures/bank-separate.js +3 -3
- package/test/e2e/fixtures/card-separate-brands.js +5 -5
- package/test/e2e/fixtures/card-separate-rebilly-fields.js +3 -3
- package/test/e2e/fixtures/card-separate.js +3 -3
- package/test/e2e/fixtures/checkout-combined.js +3 -3
- package/test/e2e/fixtures/google-pay.js +1 -1
- package/test/e2e/fixtures/iban.js +2 -2
- package/test/e2e/fixtures/multiple-methods.js +2 -2
- package/test/e2e/fixtures/paypal.js +1 -1
- package/types/context.d.ts +1 -1
- package/types/elements.d.ts +9 -9
- package/types/injector.d.ts +8 -8
- package/types/rebilly/api.d.ts +8 -8
- package/types/rebilly/init-framepay-events.d.ts +4 -0
- package/types/rebilly/payment-methods.d.ts +1 -1
- package/types/rebilly/settings.d.ts +2 -2
- package/build/lib/get-rebilly-api.d.ts +0 -1
- package/build/lib/get-rebilly-api.js +0 -14
- package/src/lib/get-rebilly-api.ts +0 -11
- package/types/rebilly/init-rebilly-events.d.ts +0 -4
package/build/lib/constants.js
CHANGED
|
@@ -36,12 +36,12 @@ exports.REACT_VERSION = React.version;
|
|
|
36
36
|
* Remote FramePay library CDN link.
|
|
37
37
|
*/
|
|
38
38
|
exports.FRAMEPAY_SCRIPT_LINK = process.env.FRAMEPAY_SCRIPT_LINK ||
|
|
39
|
-
'https://framepay.rebilly.com/
|
|
39
|
+
'https://framepay.rebilly.com/framepay.js';
|
|
40
40
|
/**
|
|
41
41
|
* Remote FramePay style CDN link.
|
|
42
42
|
*/
|
|
43
43
|
exports.FRAMEPAY_STYLE_LINK = process.env.FRAMEPAY_STYLE_LINK ||
|
|
44
|
-
'https://framepay.rebilly.com/
|
|
44
|
+
'https://framepay.rebilly.com/framepay.css';
|
|
45
45
|
/**
|
|
46
46
|
* Supported FramePay card types
|
|
47
47
|
*/
|
|
@@ -56,4 +56,4 @@ exports.SUPPORTED_CARD_BRANDS = {
|
|
|
56
56
|
MasterCard: "MasterCard" /* MasterCard */,
|
|
57
57
|
Visa: "Visa" /* Visa */,
|
|
58
58
|
};
|
|
59
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi9jb25zdGFudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDJDQUErQjtBQUUvQjs7Ozs7R0FLRztBQUVIOzs7R0FHRztBQUNVLFFBQUEsYUFBYSxHQUFHLEtBQUssQ0FBQyxPQUFPLENBQUM7QUFFM0M7O0dBRUc7QUFDVSxRQUFBLG9CQUFvQixHQUM3QixPQUFPLENBQUMsR0FBRyxDQUFDLG9CQUFvQjtJQUNoQywwQ0FBMEMsQ0FBQztBQUUvQzs7R0FFRztBQUNVLFFBQUEsbUJBQW1CLEdBQzVCLE9BQU8sQ0FBQyxHQUFHLENBQUMsbUJBQW1CO0lBQy9CLDJDQUEyQyxDQUFDO0FBRWhEOztHQUVHO0FBQ1UsUUFBQSxxQkFBcUIsR0FBOEI7SUFDNUQsSUFBSSwrQkFBMEI7SUFDOUIsWUFBWSxvQ0FBa0M7SUFDOUMsR0FBRywyQkFBeUI7SUFDNUIsVUFBVSxnQ0FBZ0M7SUFDMUMsUUFBUSwyQkFBOEI7SUFDdEMsR0FBRyxpQkFBeUI7SUFDNUIsT0FBTyx5QkFBNkI7SUFDcEMsVUFBVSwrQkFBZ0M7SUFDMUMsSUFBSSxtQkFBMEI7Q0FDakMsQ0FBQyJ9
|
package/build/lib/context.js
CHANGED
|
@@ -25,9 +25,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.ContextConsumer = exports.ContextProvider = void 0;
|
|
26
26
|
var React = __importStar(require("react"));
|
|
27
27
|
var constants_1 = require("./constants");
|
|
28
|
-
var
|
|
28
|
+
var get_framepay_api_1 = __importDefault(require("./get-framepay-api"));
|
|
29
29
|
var defaultContextValue = {
|
|
30
|
-
api: (0,
|
|
30
|
+
api: (0, get_framepay_api_1.default)(),
|
|
31
31
|
error: null,
|
|
32
32
|
ready: false,
|
|
33
33
|
};
|
|
@@ -43,4 +43,4 @@ var ContextProvider = ProvidedContext.Provider;
|
|
|
43
43
|
exports.ContextProvider = ContextProvider;
|
|
44
44
|
var ContextConsumer = ProvidedContext.Consumer;
|
|
45
45
|
exports.ContextConsumer = ContextConsumer;
|
|
46
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29udGV4dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkNBQStCO0FBQy9CLHlDQUE0QztBQUM1Qyx3RUFBZ0Q7QUFFaEQsSUFBTSxtQkFBbUIsR0FBRztJQUN4QixHQUFHLEVBQUUsSUFBQSwwQkFBYyxHQUFFO0lBQ3JCLEtBQUssRUFBRSxJQUFJO0lBQ1gsS0FBSyxFQUFFLEtBQUs7Q0FDZixDQUFDO0FBRUYsSUFBSSxlQUFlLENBQUM7QUFDcEIsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLHlCQUFhLENBQUMsSUFBSSxTQUFTLENBQUMsSUFBSSxDQUFDLHlCQUFhLENBQUMsRUFBRTtJQUM5RCxJQUFNLGtCQUFrQixHQUFHLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQUFDO0lBQzNELGVBQWUsR0FBRyxrQkFBa0IsQ0FBQyxtQkFBbUIsQ0FBQyxDQUFDO0NBQzdEO0tBQU07SUFDSCxlQUFlLEdBQUcsS0FBSyxDQUFDLGFBQWEsQ0FBa0IsbUJBQW1CLENBQUMsQ0FBQztDQUMvRTtBQUVELElBQU0sZUFBZSxHQUFHLGVBQWUsQ0FBQyxRQUFRLENBQUM7QUFHeEMsMENBQWU7QUFGeEIsSUFBTSxlQUFlLEdBQUcsZUFBZSxDQUFDLFFBQVEsQ0FBQztBQUV2QiwwQ0FBZSJ9
|
|
@@ -10,7 +10,7 @@ exports.ERROR_CODES = {
|
|
|
10
10
|
exports.defaultErrorMessages = (_a = {},
|
|
11
11
|
_a[exports.ERROR_CODES.remoteScriptError] = "Can't load the FramePay remote script",
|
|
12
12
|
_a[exports.ERROR_CODES.elementMountError] = "Can't mount the element component",
|
|
13
|
-
_a[exports.ERROR_CODES.initializeError] = "\n FramePay initialize error\r\n\n See https://github.com/Rebilly/framepay-react/tree/alpha#the-framepay-context-framepayprovider\r\n\n See https://rebilly.
|
|
13
|
+
_a[exports.ERROR_CODES.initializeError] = "\n FramePay initialize error\r\n\n See https://github.com/Rebilly/framepay-react/tree/alpha#the-framepay-context-framepayprovider\r\n\n See https://www.rebilly.com/docs/dev-docs/framepay-global-reference/#framepay.initialize",
|
|
14
14
|
_a);
|
|
15
15
|
var ErrorBuilder = /** @class */ (function () {
|
|
16
16
|
function ErrorBuilder() {
|
|
@@ -37,4 +37,4 @@ var FramePayError = function (_a) {
|
|
|
37
37
|
};
|
|
38
38
|
FramePayError.codes = exports.ERROR_CODES;
|
|
39
39
|
exports.default = FramePayError;
|
|
40
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWVwYXktZXJyb3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2ZyYW1lcGF5LWVycm9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBYSxRQUFBLFdBQVcsR0FBRztJQUN2QixpQkFBaUIsRUFBRSxxQkFBcUI7SUFDeEMsZUFBZSxFQUFFLGtCQUFrQjtJQUNuQyxpQkFBaUIsRUFBRSxxQkFBcUI7Q0FDN0IsQ0FBQztBQUVILFFBQUEsb0JBQW9CLEdBQUcsQ0FBQTtJQUNoQyxHQUFDLG1CQUFXLENBQUMsaUJBQWlCLElBQUcsdUNBQXVDO0lBQ3hFLEdBQUMsbUJBQVcsQ0FBQyxpQkFBaUIsSUFBRyxtQ0FBbUM7SUFDcEUsR0FBQyxtQkFBVyxDQUFDLGVBQWUsSUFBRyx1UEFHOEQ7TUFDeEUsQ0FBQSxDQUFDO0FBRTFCO0lBQUE7SUF3QkEsQ0FBQztJQXZCRywyQkFBSSxHQUFKLFVBQUssRUFTSjtZQVJHLElBQUksVUFBQSxFQUNKLE9BQU8sYUFBQSxFQUNQLEtBQUssV0FBQTtRQWFMLE9BQU87WUFDSCxJQUFJLE1BQUE7WUFDSixPQUFPLFNBQUE7WUFDUCxPQUFPLEVBQUUsNEJBQW9CLENBQUMsSUFBSSxDQUFDO1lBQ25DLEtBQUssRUFBRSxLQUFLLElBQUksSUFBSTtTQUN2QixDQUFDO0lBQ04sQ0FBQztJQUNMLG1CQUFDO0FBQUQsQ0FBQyxBQXhCRCxJQXdCQztBQUVELElBQU0sT0FBTyxHQUFHLElBQUksWUFBWSxFQUFFLENBQUM7QUFFbkMsSUFBTSxhQUFhLEdBQUcsVUFBQyxFQVN0QjtRQVJHLElBQUksVUFBQSxFQUNKLGVBQVksRUFBWixPQUFPLG1CQUFHLEVBQUUsS0FBQSxFQUNaLGFBQVUsRUFBVixLQUFLLG1CQUFHLEVBQUUsS0FBQTtJQU9WLE9BQUEsT0FBTyxDQUFDLElBQUksQ0FBQztRQUNULElBQUksTUFBQTtRQUNKLE9BQU8sU0FBQTtRQUNQLEtBQUssT0FBQTtLQUNSLENBQUM7QUFKRixDQUlFLENBQUM7QUFFUCxhQUFhLENBQUMsS0FBSyxHQUFHLG1CQUFXLENBQUM7QUFFbEMsa0JBQWUsYUFBYSxDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getFramepayApi(): FramepayApi;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Just simple wrapper of remote FramePay api
|
|
5
|
+
*/
|
|
6
|
+
var remoteApi = function () {
|
|
7
|
+
// @ts-ignore todo setup typescript config correctly
|
|
8
|
+
return typeof window !== 'undefined' ? window.Framepay : undefined;
|
|
9
|
+
};
|
|
10
|
+
function getFramepayApi() {
|
|
11
|
+
return remoteApi();
|
|
12
|
+
}
|
|
13
|
+
exports.default = getFramepayApi;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LWZyYW1lcGF5LWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvZ2V0LWZyYW1lcGF5LWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBOztHQUVHO0FBQ0gsSUFBTSxTQUFTLEdBQUc7SUFDZCxvREFBb0Q7SUFDcEQsT0FBTyxPQUFPLE1BQU0sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLFNBQVMsQ0FBQztBQUN2RSxDQUFDLENBQUM7QUFFRixTQUF3QixjQUFjO0lBQ2xDLE9BQU8sU0FBUyxFQUFFLENBQUM7QUFDdkIsQ0FBQztBQUZELGlDQUVDIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebilly/framepay-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "A React wrapper for Rebilly's FramePay offering out-of-the-box support for Redux and other common React features",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"author": "Rebilly",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"eslint-plugin-react": "^7.33.2",
|
|
81
81
|
"express": "^4.17.3",
|
|
82
82
|
"jest": "^29.5.0",
|
|
83
|
-
"jest-environment-jsdom": "^29.
|
|
83
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
84
84
|
"npm-run-all": "^4.1.5",
|
|
85
85
|
"parcel-bundler": "^1.12.5",
|
|
86
86
|
"portfinder": "^1.0.20",
|
|
@@ -7,7 +7,7 @@ export default class ApplePayElement extends BaseElement<
|
|
|
7
7
|
ApplePayState
|
|
8
8
|
> {
|
|
9
9
|
setupElement() {
|
|
10
|
-
const {
|
|
10
|
+
const { Framepay } = this.props;
|
|
11
11
|
|
|
12
12
|
const makeElement = () => {
|
|
13
13
|
// elementNode already checked in BaseElement.handleSetupElement
|
|
@@ -20,7 +20,7 @@ export default class ApplePayElement extends BaseElement<
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
|
-
return
|
|
23
|
+
return Framepay.applePay.mount(this.elementNode);
|
|
24
24
|
} catch (e) {
|
|
25
25
|
throw FramePayError({
|
|
26
26
|
code: FramePayError.codes.elementMountError,
|
|
@@ -16,9 +16,9 @@ describe('BankElement', () => {
|
|
|
16
16
|
render(
|
|
17
17
|
<BankElement
|
|
18
18
|
{...props}
|
|
19
|
-
|
|
20
|
-
...props.
|
|
21
|
-
bankAccount: props.
|
|
19
|
+
Framepay={{
|
|
20
|
+
...props.Framepay,
|
|
21
|
+
bankAccount: props.Framepay.bankAccount,
|
|
22
22
|
ready: false,
|
|
23
23
|
}}
|
|
24
24
|
elementType="bankRoutingNumber"
|
|
@@ -39,9 +39,9 @@ describe('BankElement', () => {
|
|
|
39
39
|
render(
|
|
40
40
|
<BankElement
|
|
41
41
|
{...props}
|
|
42
|
-
|
|
43
|
-
...props.
|
|
44
|
-
bankAccount: props.
|
|
42
|
+
Framepay={{
|
|
43
|
+
...props.Framepay,
|
|
44
|
+
bankAccount: props.Framepay.bankAccount,
|
|
45
45
|
ready: true,
|
|
46
46
|
}}
|
|
47
47
|
elementType="bankAccountType"
|
|
@@ -59,16 +59,16 @@ describe('BankElement', () => {
|
|
|
59
59
|
done();
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
props.
|
|
62
|
+
props.Framepay.bankAccount.mount(Arg.any(), Arg.any()).returns(element);
|
|
63
63
|
|
|
64
64
|
class TmpComponent extends React.Component {
|
|
65
65
|
render() {
|
|
66
66
|
return (
|
|
67
67
|
<BankElement
|
|
68
68
|
{...props}
|
|
69
|
-
|
|
70
|
-
...props.
|
|
71
|
-
bankAccount: props.
|
|
69
|
+
Framepay={{
|
|
70
|
+
...props.Framepay,
|
|
71
|
+
bankAccount: props.Framepay.bankAccount,
|
|
72
72
|
ready: true,
|
|
73
73
|
}}
|
|
74
74
|
elementType="bankRoutingNumber"
|
|
@@ -84,10 +84,10 @@ describe('BankElement', () => {
|
|
|
84
84
|
it('should render the empty div element', () => {
|
|
85
85
|
const props = Substitute.for<BankProps>();
|
|
86
86
|
|
|
87
|
-
props.
|
|
87
|
+
props.Framepay.ready.returns(true);
|
|
88
88
|
|
|
89
89
|
const { container } = render(
|
|
90
|
-
<BankElement {...props}
|
|
90
|
+
<BankElement {...props} Framepay={props.Framepay} />,
|
|
91
91
|
);
|
|
92
92
|
expect(container.firstChild).toMatchInlineSnapshot(`<div />`);
|
|
93
93
|
});
|
|
@@ -99,10 +99,10 @@ describe('BankElement', () => {
|
|
|
99
99
|
render(
|
|
100
100
|
<BankElement
|
|
101
101
|
{...props}
|
|
102
|
-
|
|
103
|
-
...props.
|
|
102
|
+
Framepay={{
|
|
103
|
+
...props.Framepay,
|
|
104
104
|
bankAccount: {
|
|
105
|
-
...props.
|
|
105
|
+
...props.Framepay.bankAccount,
|
|
106
106
|
mount: null,
|
|
107
107
|
},
|
|
108
108
|
ready: true,
|
|
@@ -33,7 +33,7 @@ export default class BaseElement<
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
handleSetupElement() {
|
|
36
|
-
if (!this.props.
|
|
36
|
+
if (!this.props.Framepay.ready) {
|
|
37
37
|
/**
|
|
38
38
|
* The remote api isn't ready
|
|
39
39
|
*/
|
|
@@ -69,7 +69,7 @@ export default class BaseElement<
|
|
|
69
69
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
70
|
const rules: ReadonlyArray<any> = [
|
|
71
71
|
// @ts-ignore todo fix typing issues
|
|
72
|
-
[this.props.
|
|
72
|
+
[this.props.Framepay.ready, nextProps.Framepay.ready],
|
|
73
73
|
// @ts-ignore todo fix typing issues
|
|
74
74
|
[this.state.mounted, nextState.mounted],
|
|
75
75
|
// @ts-ignore todo fix typing issues
|
|
@@ -8,14 +8,14 @@ describe('CardElement', () => {
|
|
|
8
8
|
it('should not setup the element while api is not ready', () => {
|
|
9
9
|
const props = Substitute.for<CardProps>();
|
|
10
10
|
|
|
11
|
-
props.
|
|
11
|
+
props.Framepay.ready.returns(false);
|
|
12
12
|
|
|
13
13
|
const setupElementSpy = jest.spyOn(
|
|
14
14
|
CardElement.prototype,
|
|
15
15
|
'setupElement',
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
-
render(<CardElement {...props}
|
|
18
|
+
render(<CardElement {...props} Framepay={props.Framepay} />);
|
|
19
19
|
|
|
20
20
|
expect(setupElementSpy).not.toHaveBeenCalled();
|
|
21
21
|
});
|
|
@@ -29,7 +29,7 @@ describe('CardElement', () => {
|
|
|
29
29
|
|
|
30
30
|
const { rerender } = render(
|
|
31
31
|
<CardElement
|
|
32
|
-
|
|
32
|
+
Framepay={{
|
|
33
33
|
ready: false,
|
|
34
34
|
}}
|
|
35
35
|
/>,
|
|
@@ -39,8 +39,8 @@ describe('CardElement', () => {
|
|
|
39
39
|
|
|
40
40
|
rerender(
|
|
41
41
|
<CardElement
|
|
42
|
-
|
|
43
|
-
card: props.
|
|
42
|
+
Framepay={{
|
|
43
|
+
card: props.Framepay.card,
|
|
44
44
|
ready: true,
|
|
45
45
|
}}
|
|
46
46
|
/>,
|
|
@@ -52,7 +52,7 @@ describe('CardElement', () => {
|
|
|
52
52
|
it('should render the empty div element', () => {
|
|
53
53
|
const props = Substitute.for<CardProps>();
|
|
54
54
|
const { container } = render(
|
|
55
|
-
<CardElement {...props}
|
|
55
|
+
<CardElement {...props} Framepay={props.Framepay} />,
|
|
56
56
|
);
|
|
57
57
|
expect(container.firstChild).toMatchInlineSnapshot(`<div />`);
|
|
58
58
|
});
|
|
@@ -70,10 +70,10 @@ describe('CardElement', () => {
|
|
|
70
70
|
return (
|
|
71
71
|
<CardElement
|
|
72
72
|
{...props}
|
|
73
|
-
|
|
74
|
-
...props.
|
|
73
|
+
Framepay={{
|
|
74
|
+
...props.Framepay,
|
|
75
75
|
card: {
|
|
76
|
-
...props.
|
|
76
|
+
...props.Framepay.card,
|
|
77
77
|
mount: () => element,
|
|
78
78
|
},
|
|
79
79
|
ready: true,
|
|
@@ -94,10 +94,10 @@ describe('CardElement', () => {
|
|
|
94
94
|
render(
|
|
95
95
|
<CardElement
|
|
96
96
|
{...props}
|
|
97
|
-
|
|
98
|
-
...props.
|
|
97
|
+
Framepay={{
|
|
98
|
+
...props.Framepay,
|
|
99
99
|
card: {
|
|
100
|
-
...props.
|
|
100
|
+
...props.Framepay.card,
|
|
101
101
|
mount: null,
|
|
102
102
|
},
|
|
103
103
|
ready: true,
|
|
@@ -7,7 +7,7 @@ export default class GooglePayElement extends BaseElement<
|
|
|
7
7
|
GooglePayState
|
|
8
8
|
> {
|
|
9
9
|
setupElement() {
|
|
10
|
-
const {
|
|
10
|
+
const { Framepay } = this.props;
|
|
11
11
|
|
|
12
12
|
const makeElement = () => {
|
|
13
13
|
// elementNode already checked in BaseElement.handleSetupElement
|
|
@@ -20,7 +20,7 @@ export default class GooglePayElement extends BaseElement<
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
|
-
return
|
|
23
|
+
return Framepay.googlePay.mount(this.elementNode);
|
|
24
24
|
} catch (e) {
|
|
25
25
|
throw FramePayError({
|
|
26
26
|
code: FramePayError.codes.elementMountError,
|
|
@@ -8,11 +8,11 @@ describe('IBANElement', () => {
|
|
|
8
8
|
it('should not setup the element while api is not ready', () => {
|
|
9
9
|
const props = Substitute.for<IBANProps>();
|
|
10
10
|
|
|
11
|
-
props.
|
|
11
|
+
props.Framepay.ready.returns(false);
|
|
12
12
|
|
|
13
13
|
const spy = jest.spyOn(IBANElement.prototype, 'setupElement');
|
|
14
14
|
|
|
15
|
-
render(<IBANElement {...props}
|
|
15
|
+
render(<IBANElement {...props} Framepay={props.Framepay} />);
|
|
16
16
|
expect(spy).not.toHaveBeenCalled();
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -20,10 +20,10 @@ describe('IBANElement', () => {
|
|
|
20
20
|
const props = Substitute.for<IBANProps>();
|
|
21
21
|
const spy = jest.spyOn(IBANElement.prototype, 'setupElement');
|
|
22
22
|
|
|
23
|
-
props.
|
|
23
|
+
props.Framepay.ready.returns(false);
|
|
24
24
|
|
|
25
25
|
const { rerender } = render(
|
|
26
|
-
<IBANElement {...props}
|
|
26
|
+
<IBANElement {...props} Framepay={props.Framepay} />,
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
expect(spy).toHaveBeenCalledTimes(0);
|
|
@@ -33,7 +33,7 @@ describe('IBANElement', () => {
|
|
|
33
33
|
rerender(
|
|
34
34
|
<IBANElement
|
|
35
35
|
{...nextProps}
|
|
36
|
-
|
|
36
|
+
Framepay={{ iban: nextProps.Framepay.iban, ready: true }}
|
|
37
37
|
/>,
|
|
38
38
|
);
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ describe('IBANElement', () => {
|
|
|
43
43
|
it('should render the empty div element', () => {
|
|
44
44
|
const props = Substitute.for<IBANProps>();
|
|
45
45
|
const { container } = render(
|
|
46
|
-
<IBANElement {...props}
|
|
46
|
+
<IBANElement {...props} Framepay={props.Framepay} />,
|
|
47
47
|
);
|
|
48
48
|
expect(container.firstChild).toMatchInlineSnapshot(`<div />`);
|
|
49
49
|
});
|
|
@@ -61,10 +61,10 @@ describe('IBANElement', () => {
|
|
|
61
61
|
return (
|
|
62
62
|
<IBANElement
|
|
63
63
|
{...props}
|
|
64
|
-
|
|
65
|
-
...props.
|
|
64
|
+
Framepay={{
|
|
65
|
+
...props.Framepay,
|
|
66
66
|
iban: {
|
|
67
|
-
...props.
|
|
67
|
+
...props.Framepay.iban,
|
|
68
68
|
mount: () => element,
|
|
69
69
|
},
|
|
70
70
|
ready: true,
|
|
@@ -85,10 +85,10 @@ describe('IBANElement', () => {
|
|
|
85
85
|
render(
|
|
86
86
|
<IBANElement
|
|
87
87
|
{...props}
|
|
88
|
-
|
|
89
|
-
...props.
|
|
88
|
+
Framepay={{
|
|
89
|
+
...props.Framepay,
|
|
90
90
|
iban: {
|
|
91
|
-
...props.
|
|
91
|
+
...props.Framepay.iban,
|
|
92
92
|
mount: null,
|
|
93
93
|
},
|
|
94
94
|
ready: true,
|
|
@@ -19,7 +19,7 @@ export default class IBANElement extends BaseElement<IBANProps, IBANState> {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
|
-
return this.props.
|
|
22
|
+
return this.props.Framepay.iban.mount(this.elementNode);
|
|
23
23
|
} catch (e) {
|
|
24
24
|
throw FramePayError({
|
|
25
25
|
code: FramePayError.codes.elementMountError,
|
|
@@ -7,7 +7,7 @@ export default class PaypalElement extends BaseElement<
|
|
|
7
7
|
PaypalState
|
|
8
8
|
> {
|
|
9
9
|
setupElement() {
|
|
10
|
-
const {
|
|
10
|
+
const { Framepay } = this.props;
|
|
11
11
|
|
|
12
12
|
const makeElement = () => {
|
|
13
13
|
// elementNode already checked in BaseElement.handleSetupElement
|
|
@@ -20,7 +20,7 @@ export default class PaypalElement extends BaseElement<
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
|
-
return
|
|
23
|
+
return Framepay.paypal.mount(this.elementNode);
|
|
24
24
|
} catch (e) {
|
|
25
25
|
throw FramePayError({
|
|
26
26
|
code: FramePayError.codes.elementMountError,
|
|
@@ -22,8 +22,8 @@ describe('Injector', () => {
|
|
|
22
22
|
render() {
|
|
23
23
|
return (
|
|
24
24
|
<div>
|
|
25
|
-
error: {this.props.
|
|
26
|
-
ready: {String(this.props.
|
|
25
|
+
error: {this.props.Framepay.error}
|
|
26
|
+
ready: {String(this.props.Framepay.ready)}
|
|
27
27
|
</div>
|
|
28
28
|
);
|
|
29
29
|
}
|
|
@@ -72,8 +72,8 @@ describe('Injector', () => {
|
|
|
72
72
|
render() {
|
|
73
73
|
return (
|
|
74
74
|
<div>
|
|
75
|
-
error: {this.props.
|
|
76
|
-
ready: {String(this.props.
|
|
75
|
+
error: {this.props.Framepay.error}
|
|
76
|
+
ready: {String(this.props.Framepay.ready)}
|
|
77
77
|
</div>
|
|
78
78
|
);
|
|
79
79
|
}
|
|
@@ -122,8 +122,8 @@ describe('Injector', () => {
|
|
|
122
122
|
render() {
|
|
123
123
|
return (
|
|
124
124
|
<div>
|
|
125
|
-
error: {this.props.
|
|
126
|
-
ready: {String(this.props.
|
|
125
|
+
error: {this.props.Framepay.error}
|
|
126
|
+
ready: {String(this.props.Framepay.ready)}
|
|
127
127
|
</div>
|
|
128
128
|
);
|
|
129
129
|
}
|
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
FramePayPaypalProps,
|
|
20
20
|
} from '../../../types/injector';
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const makeFramepayProps = (data: FramePayContext): FramepayProps =>
|
|
23
23
|
Object.assign(Object.create(data.api || {}), {
|
|
24
24
|
error: data.error,
|
|
25
25
|
ready: data.ready,
|
|
26
|
-
}) as
|
|
26
|
+
}) as FramepayProps;
|
|
27
27
|
|
|
28
28
|
function Hoc<P extends object>(
|
|
29
29
|
name: string,
|
|
@@ -71,7 +71,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
71
71
|
IBANElementComponent,
|
|
72
72
|
(data: FramePayContext) =>
|
|
73
73
|
({
|
|
74
|
-
|
|
74
|
+
Framepay: makeFramepayProps(data),
|
|
75
75
|
elementType: 'iban',
|
|
76
76
|
} as IBANProps),
|
|
77
77
|
);
|
|
@@ -84,7 +84,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
84
84
|
if (type === 'bankAccount') {
|
|
85
85
|
/**
|
|
86
86
|
* BankAccount
|
|
87
|
-
* @see https://rebilly.
|
|
87
|
+
* @see https://www.rebilly.com/docs/dev-docs/framepay-global-reference/#framepay.bban.mount
|
|
88
88
|
*/
|
|
89
89
|
|
|
90
90
|
/**
|
|
@@ -95,7 +95,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
95
95
|
BankElementComponent,
|
|
96
96
|
(data: FramePayContext) =>
|
|
97
97
|
({
|
|
98
|
-
|
|
98
|
+
Framepay: makeFramepayProps(data),
|
|
99
99
|
elementType: 'bankAccountType',
|
|
100
100
|
} as BankProps),
|
|
101
101
|
);
|
|
@@ -108,7 +108,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
108
108
|
BankElementComponent,
|
|
109
109
|
(data: FramePayContext) =>
|
|
110
110
|
({
|
|
111
|
-
|
|
111
|
+
Framepay: makeFramepayProps(data),
|
|
112
112
|
elementType: 'bankRoutingNumber',
|
|
113
113
|
} as BankProps),
|
|
114
114
|
);
|
|
@@ -121,7 +121,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
121
121
|
BankElementComponent,
|
|
122
122
|
(data: FramePayContext) =>
|
|
123
123
|
({
|
|
124
|
-
|
|
124
|
+
Framepay: makeFramepayProps(data),
|
|
125
125
|
elementType: 'bankAccountNumber',
|
|
126
126
|
} as BankProps),
|
|
127
127
|
);
|
|
@@ -136,14 +136,14 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
136
136
|
if (type === 'card') {
|
|
137
137
|
/**
|
|
138
138
|
* Default Card Element
|
|
139
|
-
* @see https://rebilly.
|
|
139
|
+
* @see https://www.rebilly.com/docs/dev-docs/framepay-global-reference/#framepay.card.mount
|
|
140
140
|
*/
|
|
141
141
|
const CardElement = Hoc(
|
|
142
142
|
'CardElement',
|
|
143
143
|
CardElementComponent,
|
|
144
144
|
(data: FramePayContext) =>
|
|
145
145
|
({
|
|
146
|
-
|
|
146
|
+
Framepay: makeFramepayProps(data),
|
|
147
147
|
} as CardProps),
|
|
148
148
|
);
|
|
149
149
|
|
|
@@ -155,7 +155,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
155
155
|
CardElementComponent,
|
|
156
156
|
(data: FramePayContext) =>
|
|
157
157
|
({
|
|
158
|
-
|
|
158
|
+
Framepay: makeFramepayProps(data),
|
|
159
159
|
elementType: 'cardCvv',
|
|
160
160
|
} as CardProps),
|
|
161
161
|
);
|
|
@@ -168,7 +168,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
168
168
|
CardElementComponent,
|
|
169
169
|
(data: FramePayContext) =>
|
|
170
170
|
({
|
|
171
|
-
|
|
171
|
+
Framepay: makeFramepayProps(data),
|
|
172
172
|
elementType: 'cardExpiry',
|
|
173
173
|
} as CardProps),
|
|
174
174
|
);
|
|
@@ -181,7 +181,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
181
181
|
CardElementComponent,
|
|
182
182
|
(data: FramePayContext) =>
|
|
183
183
|
({
|
|
184
|
-
|
|
184
|
+
Framepay: makeFramepayProps(data),
|
|
185
185
|
elementType: 'cardNumber',
|
|
186
186
|
} as CardProps),
|
|
187
187
|
);
|
|
@@ -204,7 +204,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
204
204
|
ApplePayElementComponent,
|
|
205
205
|
(data: FramePayContext) =>
|
|
206
206
|
({
|
|
207
|
-
|
|
207
|
+
Framepay: makeFramepayProps(data),
|
|
208
208
|
} as ApplePayProps),
|
|
209
209
|
);
|
|
210
210
|
|
|
@@ -223,7 +223,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
223
223
|
GooglePayElementComponent,
|
|
224
224
|
(data: FramePayContext) =>
|
|
225
225
|
({
|
|
226
|
-
|
|
226
|
+
Framepay: makeFramepayProps(data),
|
|
227
227
|
} as GooglePayProps),
|
|
228
228
|
);
|
|
229
229
|
|
|
@@ -242,7 +242,7 @@ const elementsFabric = (type: PaymentElements): object => {
|
|
|
242
242
|
PaypalElementComponent,
|
|
243
243
|
(data: FramePayContext) =>
|
|
244
244
|
({
|
|
245
|
-
|
|
245
|
+
Framepay: makeFramepayProps(data),
|
|
246
246
|
} as PaypalProps),
|
|
247
247
|
);
|
|
248
248
|
|
|
@@ -286,7 +286,7 @@ export function withFramePay<OriginalProps extends object>(
|
|
|
286
286
|
{...{
|
|
287
287
|
...this.props,
|
|
288
288
|
...elements,
|
|
289
|
-
|
|
289
|
+
Framepay: makeFramepayProps(data),
|
|
290
290
|
}}
|
|
291
291
|
/>
|
|
292
292
|
);
|
|
@@ -315,7 +315,7 @@ export function withFramePayCardComponent<OriginalProps extends object>(
|
|
|
315
315
|
{...{
|
|
316
316
|
...this.props,
|
|
317
317
|
...elements,
|
|
318
|
-
|
|
318
|
+
Framepay: makeFramepayProps(data),
|
|
319
319
|
}}
|
|
320
320
|
/>
|
|
321
321
|
);
|
|
@@ -344,7 +344,7 @@ export function withFramePayBankComponent<OriginalProps extends object>(
|
|
|
344
344
|
{...{
|
|
345
345
|
...this.props,
|
|
346
346
|
...elements,
|
|
347
|
-
|
|
347
|
+
Framepay: makeFramepayProps(data),
|
|
348
348
|
}}
|
|
349
349
|
/>
|
|
350
350
|
);
|
|
@@ -373,7 +373,7 @@ export function withFramePayIBANComponent<OriginalProps extends object>(
|
|
|
373
373
|
{...{
|
|
374
374
|
...this.props,
|
|
375
375
|
...elements,
|
|
376
|
-
|
|
376
|
+
Framepay: makeFramepayProps(data),
|
|
377
377
|
}}
|
|
378
378
|
/>
|
|
379
379
|
);
|
|
@@ -404,7 +404,7 @@ export function withFramePayApplePayComponent<OriginalProps extends object>(
|
|
|
404
404
|
{...{
|
|
405
405
|
...this.props,
|
|
406
406
|
...elements,
|
|
407
|
-
|
|
407
|
+
Framepay: makeFramepayProps(data),
|
|
408
408
|
}}
|
|
409
409
|
/>
|
|
410
410
|
);
|
|
@@ -435,7 +435,7 @@ export function withFramePayGooglePayComponent<OriginalProps extends object>(
|
|
|
435
435
|
{...{
|
|
436
436
|
...this.props,
|
|
437
437
|
...elements,
|
|
438
|
-
|
|
438
|
+
Framepay: makeFramepayProps(data),
|
|
439
439
|
}}
|
|
440
440
|
/>
|
|
441
441
|
);
|
|
@@ -464,7 +464,7 @@ export function withFramePayPaypalComponent<OriginalProps extends object>(
|
|
|
464
464
|
{...{
|
|
465
465
|
...this.props,
|
|
466
466
|
...elements,
|
|
467
|
-
|
|
467
|
+
Framepay: makeFramepayProps(data),
|
|
468
468
|
}}
|
|
469
469
|
/>
|
|
470
470
|
);
|