@coinflowlabs/react 4.1.2 → 4.2.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/build/cjs/card-form/CoinflowCardForm.d.ts +101 -0
- package/build/cjs/card-form/CoinflowCardForm.js +129 -0
- package/build/cjs/card-form/CoinflowCardForm.js.map +1 -0
- package/build/cjs/card-form/TokenEx.d.ts +106 -0
- package/build/cjs/card-form/TokenEx.js +4 -0
- package/build/cjs/card-form/TokenEx.js.map +1 -0
- package/build/cjs/card-form/useCardFormIframe.d.ts +77 -0
- package/build/cjs/card-form/useCardFormIframe.js +160 -0
- package/build/cjs/card-form/useCardFormIframe.js.map +1 -0
- package/build/cjs/common/CoinflowLibMessageHandlers.d.ts +13 -3
- package/build/cjs/common/CoinflowLibMessageHandlers.js +19 -11
- package/build/cjs/common/CoinflowLibMessageHandlers.js.map +1 -1
- package/build/cjs/common/CoinflowTypes.d.ts +10 -1
- package/build/cjs/common/CoinflowTypes.js +8 -1
- package/build/cjs/common/CoinflowTypes.js.map +1 -1
- package/build/cjs/index.d.ts +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/index.js.map +1 -1
- package/build/esm/card-form/CoinflowCardForm.d.ts +101 -0
- package/build/esm/card-form/CoinflowCardForm.js +125 -0
- package/build/esm/card-form/CoinflowCardForm.js.map +1 -0
- package/build/esm/card-form/TokenEx.d.ts +106 -0
- package/build/esm/card-form/TokenEx.js +3 -0
- package/build/esm/card-form/TokenEx.js.map +1 -0
- package/build/esm/card-form/useCardFormIframe.d.ts +77 -0
- package/build/esm/card-form/useCardFormIframe.js +156 -0
- package/build/esm/card-form/useCardFormIframe.js.map +1 -0
- package/build/esm/common/CoinflowLibMessageHandlers.d.ts +13 -3
- package/build/esm/common/CoinflowLibMessageHandlers.js +19 -11
- package/build/esm/common/CoinflowLibMessageHandlers.js.map +1 -1
- package/build/esm/common/CoinflowTypes.d.ts +10 -1
- package/build/esm/common/CoinflowTypes.js +7 -0
- package/build/esm/common/CoinflowTypes.js.map +1 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/build/cjs/CoinflowCardForm.d.ts +0 -39
- package/build/cjs/CoinflowCardForm.js +0 -97
- package/build/cjs/CoinflowCardForm.js.map +0 -1
- package/build/esm/CoinflowCardForm.d.ts +0 -39
- package/build/esm/CoinflowCardForm.js +0 -94
- package/build/esm/CoinflowCardForm.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CardType, CoinflowEnvs } from '../common';
|
|
3
|
+
import { CardFormInputStyles } from './useCardFormIframe';
|
|
4
|
+
export type CoinflowCardTokenResponse = {
|
|
5
|
+
token: string;
|
|
6
|
+
};
|
|
7
|
+
export interface CoinflowCardNumberInputProps {
|
|
8
|
+
env: CoinflowEnvs;
|
|
9
|
+
css: CardFormInputStyles & {
|
|
10
|
+
cvv: CardFormInputStyles;
|
|
11
|
+
};
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface CoinflowCvvOnlyInputProps {
|
|
15
|
+
token: string;
|
|
16
|
+
cardType: CardType;
|
|
17
|
+
env: CoinflowEnvs;
|
|
18
|
+
css: CardFormInputStyles & {
|
|
19
|
+
cvv: CardFormInputStyles;
|
|
20
|
+
};
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Allows merchants to collect card information from their customers in a PCI-compliant way and receive the tokenized card number.
|
|
25
|
+
*
|
|
26
|
+
* Usage:
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const ref = useRef<{getToken(): Promise<{token: string}>}>();
|
|
29
|
+
*
|
|
30
|
+
* <CoinflowCardNumberInput
|
|
31
|
+
* ref={coinflowCardFormRef}
|
|
32
|
+
* env={'ref'}
|
|
33
|
+
* debug={true}
|
|
34
|
+
* css={{
|
|
35
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
36
|
+
* focus:
|
|
37
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
38
|
+
* error:
|
|
39
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
40
|
+
* cvv: {
|
|
41
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
42
|
+
* focus:
|
|
43
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
44
|
+
* error:
|
|
45
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
46
|
+
* },
|
|
47
|
+
* }}
|
|
48
|
+
* />
|
|
49
|
+
* <CoinflowCvvInput />
|
|
50
|
+
*
|
|
51
|
+
* <button onClick={() => {
|
|
52
|
+
* ref.current?.getToken()
|
|
53
|
+
* .then(({token}) => console.log(token))
|
|
54
|
+
* .catch(e => console.error('GET TOKEN ERROR', e))
|
|
55
|
+
* }}>Get Token</button>
|
|
56
|
+
*
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const CoinflowCardNumberInput: React.ForwardRefExoticComponent<CoinflowCardNumberInputProps & React.RefAttributes<unknown>>;
|
|
60
|
+
/**
|
|
61
|
+
* The CVV number input for creating a new tokenized card
|
|
62
|
+
*/
|
|
63
|
+
export declare function CoinflowCvvInput(): React.JSX.Element;
|
|
64
|
+
/**
|
|
65
|
+
* Allows merchants to collect the CVV for an already tokenized card in a PCI-compliant way and receive the token with the CVV linked.
|
|
66
|
+
*
|
|
67
|
+
* Usage:
|
|
68
|
+
* ```tsx
|
|
69
|
+
* const ref = useRef<{getToken(): Promise<{token: string}>}>();
|
|
70
|
+
*
|
|
71
|
+
* <CoinflowCvvOnlyInput
|
|
72
|
+
* ref={ref}
|
|
73
|
+
* cardType={'visa'}
|
|
74
|
+
* token={'411111YJM5TX1111'}
|
|
75
|
+
* env={import.meta.env.VITE_ENV as CoinflowEnvs}
|
|
76
|
+
* debug={true}
|
|
77
|
+
* css={{
|
|
78
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
79
|
+
* focus:
|
|
80
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
81
|
+
* error:
|
|
82
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
83
|
+
* cvv: {
|
|
84
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
85
|
+
* focus:
|
|
86
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
87
|
+
* error:
|
|
88
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
89
|
+
* },
|
|
90
|
+
* }}
|
|
91
|
+
* />
|
|
92
|
+
*
|
|
93
|
+
* <button onClick={() => {
|
|
94
|
+
* ref.current?.getToken()
|
|
95
|
+
* .then(({token}) => console.log(token))
|
|
96
|
+
* .catch(e => console.error('GET TOKEN ERROR', e))
|
|
97
|
+
* }}>Get Token</button>
|
|
98
|
+
*
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const CoinflowCvvOnlyInput: React.ForwardRefExoticComponent<CoinflowCvvOnlyInputProps & React.RefAttributes<unknown>>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoinflowCvvOnlyInput = exports.CoinflowCvvInput = exports.CoinflowCardNumberInput = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
var useCardFormIframe_1 = require("./useCardFormIframe");
|
|
7
|
+
/**
|
|
8
|
+
* Allows merchants to collect card information from their customers in a PCI-compliant way and receive the tokenized card number.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const ref = useRef<{getToken(): Promise<{token: string}>}>();
|
|
13
|
+
*
|
|
14
|
+
* <CoinflowCardNumberInput
|
|
15
|
+
* ref={coinflowCardFormRef}
|
|
16
|
+
* env={'ref'}
|
|
17
|
+
* debug={true}
|
|
18
|
+
* css={{
|
|
19
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
20
|
+
* focus:
|
|
21
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
22
|
+
* error:
|
|
23
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
24
|
+
* cvv: {
|
|
25
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
26
|
+
* focus:
|
|
27
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
28
|
+
* error:
|
|
29
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
30
|
+
* },
|
|
31
|
+
* }}
|
|
32
|
+
* />
|
|
33
|
+
* <CoinflowCvvInput />
|
|
34
|
+
*
|
|
35
|
+
* <button onClick={() => {
|
|
36
|
+
* ref.current?.getToken()
|
|
37
|
+
* .then(({token}) => console.log(token))
|
|
38
|
+
* .catch(e => console.error('GET TOKEN ERROR', e))
|
|
39
|
+
* }}>Get Token</button>
|
|
40
|
+
*
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
exports.CoinflowCardNumberInput = (0, react_1.forwardRef)(function (props, ref) {
|
|
44
|
+
var _a = (0, useCardFormIframe_1.useCardFormIframe)(props.env), tokenExIframe = _a.tokenExIframe, initializeTokenExIframe = _a.initializeTokenExIframe;
|
|
45
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
46
|
+
getToken: function () {
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
48
|
+
return tslib_1.__generator(this, function (_a) {
|
|
49
|
+
if (!tokenExIframe)
|
|
50
|
+
throw new Error('Unable to get token');
|
|
51
|
+
return [2 /*return*/, tokenExIframe.tokenize()];
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
}); });
|
|
56
|
+
(0, react_1.useEffect)(function () {
|
|
57
|
+
var sdkScriptTag = document.createElement('script');
|
|
58
|
+
sdkScriptTag.src =
|
|
59
|
+
props.env === 'prod'
|
|
60
|
+
? 'https://htp.tokenex.com/iframe/iframe-v3.min.js'
|
|
61
|
+
: 'https://test-htp.tokenex.com/iframe/iframe-v3.min.js';
|
|
62
|
+
document.head.appendChild(sdkScriptTag);
|
|
63
|
+
initializeTokenExIframe(props);
|
|
64
|
+
}, [initializeTokenExIframe, props]);
|
|
65
|
+
return react_1.default.createElement("div", { id: useCardFormIframe_1.TokenExCardNumberIframeId });
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* The CVV number input for creating a new tokenized card
|
|
69
|
+
*/
|
|
70
|
+
function CoinflowCvvInput() {
|
|
71
|
+
return react_1.default.createElement("div", { id: useCardFormIframe_1.TokenExCvvContainerID });
|
|
72
|
+
}
|
|
73
|
+
exports.CoinflowCvvInput = CoinflowCvvInput;
|
|
74
|
+
/**
|
|
75
|
+
* Allows merchants to collect the CVV for an already tokenized card in a PCI-compliant way and receive the token with the CVV linked.
|
|
76
|
+
*
|
|
77
|
+
* Usage:
|
|
78
|
+
* ```tsx
|
|
79
|
+
* const ref = useRef<{getToken(): Promise<{token: string}>}>();
|
|
80
|
+
*
|
|
81
|
+
* <CoinflowCvvOnlyInput
|
|
82
|
+
* ref={ref}
|
|
83
|
+
* cardType={'visa'}
|
|
84
|
+
* token={'411111YJM5TX1111'}
|
|
85
|
+
* env={import.meta.env.VITE_ENV as CoinflowEnvs}
|
|
86
|
+
* debug={true}
|
|
87
|
+
* css={{
|
|
88
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
89
|
+
* focus:
|
|
90
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
91
|
+
* error:
|
|
92
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
93
|
+
* cvv: {
|
|
94
|
+
* base: 'font-family: Arial, sans-serif;padding: 0 8px;border: 1px solid rgba(0, 0, 0, 0.2);margin: 0;width: 100%;font-size: 13px;line-height: 30px;height: 32px;box-sizing: border-box;-moz-box-sizing: border-box;',
|
|
95
|
+
* focus:
|
|
96
|
+
* 'box-shadow: 0 0 6px 0 rgba(0, 132, 255, 0.5);border: 1px solid rgba(0, 132, 255, 0.5);outline: 0;',
|
|
97
|
+
* error:
|
|
98
|
+
* 'box-shadow: 0 0 6px 0 rgba(224, 57, 57, 0.5);border: 1px solid rgba(224, 57, 57, 0.5);',
|
|
99
|
+
* },
|
|
100
|
+
* }}
|
|
101
|
+
* />
|
|
102
|
+
*
|
|
103
|
+
* <button onClick={() => {
|
|
104
|
+
* ref.current?.getToken()
|
|
105
|
+
* .then(({token}) => console.log(token))
|
|
106
|
+
* .catch(e => console.error('GET TOKEN ERROR', e))
|
|
107
|
+
* }}>Get Token</button>
|
|
108
|
+
*
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
exports.CoinflowCvvOnlyInput = (0, react_1.forwardRef)(function (props, ref) {
|
|
112
|
+
var _a = (0, useCardFormIframe_1.useCardFormIframe)(props.env), tokenExIframe = _a.tokenExIframe, initializeCvvOnlyTokenExIframe = _a.initializeCvvOnlyTokenExIframe;
|
|
113
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
114
|
+
getToken: function () {
|
|
115
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
116
|
+
return tslib_1.__generator(this, function (_a) {
|
|
117
|
+
if (!tokenExIframe)
|
|
118
|
+
throw new Error('Unable to get token');
|
|
119
|
+
return [2 /*return*/, tokenExIframe.tokenize()];
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
}); });
|
|
124
|
+
(0, react_1.useEffect)(function () {
|
|
125
|
+
initializeCvvOnlyTokenExIframe(props);
|
|
126
|
+
}, [initializeCvvOnlyTokenExIframe, props]);
|
|
127
|
+
return react_1.default.createElement("div", { id: useCardFormIframe_1.TokenExCvvContainerID });
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=CoinflowCardForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoinflowCardForm.js","sourceRoot":"","sources":["../../../src/card-form/CoinflowCardForm.tsx"],"names":[],"mappings":";;;;AAAA,qDAAwE;AAExE,yDAK6B;AAoB7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,uBAAuB,GAAG,IAAA,kBAAU,EAC/C,UAAC,KAAmC,EAAE,GAAG;IACjC,IAAA,KAA2C,IAAA,qCAAiB,EAChE,KAAK,CAAC,GAAG,CACV,EAFM,aAAa,mBAAA,EAAE,uBAAuB,6BAE5C,CAAC;IAEF,IAAA,2BAAmB,EAAC,GAAG,EAAE,cAAM,OAAA,CAAC;QACxB,QAAQ;;;oBACZ,IAAI,CAAC,aAAa;wBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;oBAC3D,sBAAO,aAAa,CAAC,QAAQ,EAAE,EAAC;;;SACjC;KACF,CAAC,EAL6B,CAK7B,CAAC,CAAC;IAEJ,IAAA,iBAAS,EAAC;QACR,IAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACtD,YAAY,CAAC,GAAG;YACd,KAAK,CAAC,GAAG,KAAK,MAAM;gBAClB,CAAC,CAAC,iDAAiD;gBACnD,CAAC,CAAC,sDAAsD,CAAC;QAC7D,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAExC,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;IAErC,OAAO,uCAAK,EAAE,EAAE,6CAAyB,GAAQ,CAAC;AACpD,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,uCAAK,EAAE,EAAE,yCAAqB,GAAQ,CAAC;AAChD,CAAC;AAFD,4CAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACU,QAAA,oBAAoB,GAAG,IAAA,kBAAU,EAC5C,UAAC,KAAgC,EAAE,GAAG;IAC9B,IAAA,KAAkD,IAAA,qCAAiB,EACvE,KAAK,CAAC,GAAG,CACV,EAFM,aAAa,mBAAA,EAAE,8BAA8B,oCAEnD,CAAC;IAEF,IAAA,2BAAmB,EAAC,GAAG,EAAE,cAAM,OAAA,CAAC;QACxB,QAAQ;;;oBACZ,IAAI,CAAC,aAAa;wBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;oBAC3D,sBAAO,aAAa,CAAC,QAAQ,EAAE,EAAC;;;SACjC;KACF,CAAC,EAL6B,CAK7B,CAAC,CAAC;IAEJ,IAAA,iBAAS,EAAC;QACR,8BAA8B,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,EAAE,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC,CAAC;IAE5C,OAAO,uCAAK,EAAE,EAAE,yCAAqB,GAAQ,CAAC;AAChD,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export interface TokenizationResponse {
|
|
2
|
+
cardType: string;
|
|
3
|
+
cvvIncluded: true;
|
|
4
|
+
firstSix: string;
|
|
5
|
+
lastFour: string;
|
|
6
|
+
referenceNumber: string;
|
|
7
|
+
token: string;
|
|
8
|
+
tokenHMAC: string;
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
namespace TokenEx {
|
|
12
|
+
interface FraudServicesConfig {
|
|
13
|
+
useKount?: boolean;
|
|
14
|
+
kount?: {
|
|
15
|
+
merchantId?: string;
|
|
16
|
+
mode?: string;
|
|
17
|
+
anId?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface Config {
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
enablePrettyFormat?: boolean;
|
|
23
|
+
maskInput?: boolean;
|
|
24
|
+
enableValidateOnBlur?: boolean;
|
|
25
|
+
enableAriaRequired?: boolean;
|
|
26
|
+
pci?: boolean;
|
|
27
|
+
cvvOnly?: boolean;
|
|
28
|
+
allowUnknownCardTypes?: boolean;
|
|
29
|
+
enableAutoComplete?: boolean;
|
|
30
|
+
returnAutoCompleteValues?: boolean;
|
|
31
|
+
returnKhash?: boolean;
|
|
32
|
+
returnWhash?: boolean;
|
|
33
|
+
enforceLuhnCompliance?: boolean;
|
|
34
|
+
use3DS?: boolean;
|
|
35
|
+
validateOnKeyUp?: boolean;
|
|
36
|
+
validateOnCvvKeyUp?: boolean;
|
|
37
|
+
expiresInSeconds?: number;
|
|
38
|
+
useExtendedBIN?: boolean;
|
|
39
|
+
inlineIframeJavaScript?: boolean;
|
|
40
|
+
iframeVersion?: number;
|
|
41
|
+
authenticationKey?: string;
|
|
42
|
+
origin?: string;
|
|
43
|
+
tokenExID?: string;
|
|
44
|
+
timestamp?: string;
|
|
45
|
+
tokenScheme?: string;
|
|
46
|
+
token?: string;
|
|
47
|
+
customDataLabel?: string;
|
|
48
|
+
customCvvDataLabel?: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
cvvTitle?: string;
|
|
51
|
+
inputTitle?: string;
|
|
52
|
+
cvvInputTitle?: string;
|
|
53
|
+
cardMaxLengths?: {
|
|
54
|
+
visa?: number;
|
|
55
|
+
mastercard?: number;
|
|
56
|
+
americanExpress?: number;
|
|
57
|
+
discover?: number;
|
|
58
|
+
jcb?: number;
|
|
59
|
+
diners?: number;
|
|
60
|
+
};
|
|
61
|
+
fraudServices?: FraudServicesConfig;
|
|
62
|
+
threeDSMethodNotificationUrl?: string;
|
|
63
|
+
customDataTypes?: string | object;
|
|
64
|
+
cvvContainerID?: string;
|
|
65
|
+
cvvPlaceholder?: string;
|
|
66
|
+
cardType?: string;
|
|
67
|
+
forterSiteId?: string;
|
|
68
|
+
forterUsername?: string;
|
|
69
|
+
customRegEx?: string;
|
|
70
|
+
placeholder?: string;
|
|
71
|
+
inputType?: string;
|
|
72
|
+
inputMode?: string;
|
|
73
|
+
font?: string;
|
|
74
|
+
cvv?: boolean;
|
|
75
|
+
styles: {
|
|
76
|
+
base: string;
|
|
77
|
+
focus: string;
|
|
78
|
+
error: string;
|
|
79
|
+
cvv: {
|
|
80
|
+
base: string;
|
|
81
|
+
focus: string;
|
|
82
|
+
error: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
interface IframeAPI {
|
|
87
|
+
load(): void;
|
|
88
|
+
on: (event: string, callback: (data?: any) => void) => void;
|
|
89
|
+
tokenize(): void;
|
|
90
|
+
validate(): void;
|
|
91
|
+
reset(): void;
|
|
92
|
+
blur(): void;
|
|
93
|
+
cvvBlur(): void;
|
|
94
|
+
focus(): void;
|
|
95
|
+
cvvFocus(): void;
|
|
96
|
+
remove(): void;
|
|
97
|
+
toggleMask(): void;
|
|
98
|
+
toggleCvvMask(): void;
|
|
99
|
+
setPAN(pan: string): void;
|
|
100
|
+
binLookup(): void;
|
|
101
|
+
validateConfig(): void;
|
|
102
|
+
setFraudServicesRequestDetails(data: string): void;
|
|
103
|
+
}
|
|
104
|
+
function Iframe(containerID: string, configuration: Config): IframeAPI;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenEx.js","sourceRoot":"","sources":["../../../src/card-form/TokenEx.ts"],"names":[],"mappings":";AAAA,kDAAkD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { CardType, CoinflowEnvs } from '../common';
|
|
3
|
+
import { TokenizationResponse } from './TokenEx';
|
|
4
|
+
export declare const TokenExCardNumberIframeId = "tokenExCardNumber";
|
|
5
|
+
export declare const TokenExCvvContainerID = "tokenExCardCvv";
|
|
6
|
+
export interface TokenExIframe extends ReturnType<typeof TokenEx.Iframe> {
|
|
7
|
+
tokenize: () => Promise<TokenizationResponse>;
|
|
8
|
+
}
|
|
9
|
+
export interface TokenExIFrameConfiguration {
|
|
10
|
+
origin: string;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
tokenExID: string;
|
|
13
|
+
tokenScheme: string;
|
|
14
|
+
authenticationKey: string;
|
|
15
|
+
pci: true;
|
|
16
|
+
token?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CardFormInputStyles {
|
|
19
|
+
base: CSSProperties | string;
|
|
20
|
+
focus?: CSSProperties | string;
|
|
21
|
+
error?: CSSProperties | string;
|
|
22
|
+
}
|
|
23
|
+
export declare function useCardFormIframe(env: CoinflowEnvs): {
|
|
24
|
+
tokenExIframe: TokenExIframe | undefined;
|
|
25
|
+
initializeTokenExIframe: ({ css, fontFamily, debug, }: {
|
|
26
|
+
css: CardFormInputStyles & {
|
|
27
|
+
cvv: CardFormInputStyles;
|
|
28
|
+
};
|
|
29
|
+
fontFamily?: string;
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
}) => Promise<{
|
|
32
|
+
tokenize: () => Promise<TokenizationResponse>;
|
|
33
|
+
load(): void;
|
|
34
|
+
on: (event: string, callback: (data?: any) => void) => void;
|
|
35
|
+
validate(): void;
|
|
36
|
+
reset(): void;
|
|
37
|
+
blur(): void;
|
|
38
|
+
cvvBlur(): void;
|
|
39
|
+
focus(): void;
|
|
40
|
+
cvvFocus(): void;
|
|
41
|
+
remove(): void;
|
|
42
|
+
toggleMask(): void;
|
|
43
|
+
toggleCvvMask(): void;
|
|
44
|
+
setPAN(pan: string): void;
|
|
45
|
+
binLookup(): void;
|
|
46
|
+
validateConfig(): void;
|
|
47
|
+
setFraudServicesRequestDetails(data: string): void;
|
|
48
|
+
}>;
|
|
49
|
+
initializeCvvOnlyTokenExIframe: ({ token, cardType, css, debug, fontFamily, }: {
|
|
50
|
+
token: string;
|
|
51
|
+
cardType: CardType;
|
|
52
|
+
css: CardFormInputStyles & {
|
|
53
|
+
cvv: CardFormInputStyles;
|
|
54
|
+
};
|
|
55
|
+
debug?: boolean;
|
|
56
|
+
fontFamily?: string;
|
|
57
|
+
}) => Promise<{
|
|
58
|
+
tokenize: () => Promise<TokenizationResponse>;
|
|
59
|
+
load(): void;
|
|
60
|
+
on: (event: string, callback: (data?: any) => void) => void;
|
|
61
|
+
validate(): void;
|
|
62
|
+
reset(): void;
|
|
63
|
+
blur(): void;
|
|
64
|
+
cvvBlur(): void;
|
|
65
|
+
focus(): void;
|
|
66
|
+
cvvFocus(): void;
|
|
67
|
+
remove(): void;
|
|
68
|
+
toggleMask(): void;
|
|
69
|
+
toggleCvvMask(): void;
|
|
70
|
+
setPAN(pan: string): void;
|
|
71
|
+
binLookup(): void;
|
|
72
|
+
validateConfig(): void;
|
|
73
|
+
setFraudServicesRequestDetails(data: string): void;
|
|
74
|
+
}>;
|
|
75
|
+
loaded: boolean;
|
|
76
|
+
cachedToken: string | undefined;
|
|
77
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useCardFormIframe = exports.TokenExCvvContainerID = exports.TokenExCardNumberIframeId = void 0;
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
6
|
+
var react_1 = require("react");
|
|
7
|
+
var common_1 = require("../common");
|
|
8
|
+
exports.TokenExCardNumberIframeId = 'tokenExCardNumber';
|
|
9
|
+
exports.TokenExCvvContainerID = 'tokenExCardCvv';
|
|
10
|
+
var CARD_TYPE_MAPPING = (_a = {},
|
|
11
|
+
_a[common_1.CardType.VISA] = 'visa',
|
|
12
|
+
_a[common_1.CardType.MASTERCARD] = 'masterCard',
|
|
13
|
+
_a[common_1.CardType.AMEX] = 'americanExpress',
|
|
14
|
+
_a[common_1.CardType.DISCOVER] = 'discover',
|
|
15
|
+
_a);
|
|
16
|
+
function useCardFormIframe(env) {
|
|
17
|
+
var _this = this;
|
|
18
|
+
var _a = (0, react_1.useState)(false), loaded = _a[0], setLoaded = _a[1];
|
|
19
|
+
var _b = (0, react_1.useState)(undefined), tokenExIframe = _b[0], setTokenExIframe = _b[1];
|
|
20
|
+
var _c = (0, react_1.useState)(undefined), cachedToken = _c[0], setCachedToken = _c[1];
|
|
21
|
+
var getIframeConfig = (0, react_1.useCallback)(function (_a) {
|
|
22
|
+
var token = _a.token;
|
|
23
|
+
return fetch(new common_1.CoinflowUtils(env).url + '/api/checkout/authentication-key', {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
origins: [window.location.origin],
|
|
30
|
+
token: token,
|
|
31
|
+
}),
|
|
32
|
+
}).then(function (res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
33
|
+
return tslib_1.__generator(this, function (_a) {
|
|
34
|
+
switch (_a.label) {
|
|
35
|
+
case 0: return [4 /*yield*/, res.json()];
|
|
36
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}); });
|
|
40
|
+
}, [env]);
|
|
41
|
+
var getStylesAndFont = (0, react_1.useCallback)(function (css) {
|
|
42
|
+
var styles = {
|
|
43
|
+
base: CSSPropertiesToComponent(css.base),
|
|
44
|
+
focus: CSSPropertiesToComponent(css.focus),
|
|
45
|
+
error: CSSPropertiesToComponent(css.error),
|
|
46
|
+
cvv: {
|
|
47
|
+
base: CSSPropertiesToComponent(css.cvv.base),
|
|
48
|
+
focus: CSSPropertiesToComponent(css.cvv.focus),
|
|
49
|
+
error: CSSPropertiesToComponent(css.cvv.error),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
return { styles: styles };
|
|
53
|
+
}, []);
|
|
54
|
+
var loadIframe = (0, react_1.useCallback)(function (iframe) {
|
|
55
|
+
var tokenize = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
56
|
+
return tslib_1.__generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
iframe.tokenize();
|
|
60
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
61
|
+
iframe.on('tokenize', function (data) {
|
|
62
|
+
setCachedToken(data.token);
|
|
63
|
+
resolve(data);
|
|
64
|
+
});
|
|
65
|
+
iframe.on('validate', function (data) {
|
|
66
|
+
// noinspection PointlessBooleanExpressionJS
|
|
67
|
+
var isInvalid = !data.isValid || data.isCvvValid === false;
|
|
68
|
+
if (isInvalid)
|
|
69
|
+
reject(data);
|
|
70
|
+
});
|
|
71
|
+
})];
|
|
72
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}); };
|
|
76
|
+
iframe.on('change', function () { return setCachedToken(undefined); });
|
|
77
|
+
iframe.on('cvvChange', function () { return setCachedToken(undefined); });
|
|
78
|
+
iframe.on('load', function () {
|
|
79
|
+
setTimeout(function () { return setLoaded(true); }, 350);
|
|
80
|
+
var el = document.querySelector('#tx_iframe_tokenExCardNumber');
|
|
81
|
+
if (el)
|
|
82
|
+
el.scrolling = 'no';
|
|
83
|
+
});
|
|
84
|
+
setLoaded(false);
|
|
85
|
+
iframe.load();
|
|
86
|
+
var overriden = tslib_1.__assign(tslib_1.__assign({}, iframe), { tokenize: tokenize });
|
|
87
|
+
setTokenExIframe(overriden);
|
|
88
|
+
return overriden;
|
|
89
|
+
}, []);
|
|
90
|
+
var initializeCvvOnlyTokenExIframe = (0, react_1.useCallback)(function (_a) { return tslib_1.__awaiter(_this, [_a], void 0, function (_b) {
|
|
91
|
+
var type, iframeConfig, styles, config, iframe;
|
|
92
|
+
var token = _b.token, cardType = _b.cardType, css = _b.css, debug = _b.debug, fontFamily = _b.fontFamily;
|
|
93
|
+
return tslib_1.__generator(this, function (_c) {
|
|
94
|
+
switch (_c.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
type = CARD_TYPE_MAPPING[cardType];
|
|
97
|
+
return [4 /*yield*/, getIframeConfig({ token: token })];
|
|
98
|
+
case 1:
|
|
99
|
+
iframeConfig = _c.sent();
|
|
100
|
+
styles = getStylesAndFont(css).styles;
|
|
101
|
+
config = tslib_1.__assign(tslib_1.__assign({}, iframeConfig), { placeholder: 'CVV', enablePrettyFormat: true, styles: styles, token: token, cvvOnly: true, cvv: true, cvvContainerID: exports.TokenExCvvContainerID, cardType: type, debug: debug !== null && debug !== void 0 ? debug : false, font: fontFamily });
|
|
102
|
+
iframe = TokenEx.Iframe(exports.TokenExCvvContainerID, config);
|
|
103
|
+
return [2 /*return*/, loadIframe(iframe)];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}); }, [getIframeConfig, getStylesAndFont, loadIframe]);
|
|
107
|
+
var initializeTokenExIframe = (0, react_1.useCallback)(function (_a) { return tslib_1.__awaiter(_this, [_a], void 0, function (_b) {
|
|
108
|
+
var iframeConfig, styles, iframe;
|
|
109
|
+
var css = _b.css, fontFamily = _b.fontFamily, debug = _b.debug;
|
|
110
|
+
return tslib_1.__generator(this, function (_c) {
|
|
111
|
+
switch (_c.label) {
|
|
112
|
+
case 0: return [4 /*yield*/, getIframeConfig({})];
|
|
113
|
+
case 1:
|
|
114
|
+
iframeConfig = _c.sent();
|
|
115
|
+
styles = getStylesAndFont(css).styles;
|
|
116
|
+
iframe = TokenEx.Iframe(exports.TokenExCardNumberIframeId, tslib_1.__assign(tslib_1.__assign({}, iframeConfig), { placeholder: '0000 0000 0000 0000', cvvPlaceholder: 'CVV', enablePrettyFormat: true, cvv: true, cvvContainerID: exports.TokenExCvvContainerID, styles: styles, font: fontFamily, debug: debug !== null && debug !== void 0 ? debug : false }));
|
|
117
|
+
return [2 /*return*/, loadIframe(iframe)];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); }, [getIframeConfig, getStylesAndFont, loadIframe]);
|
|
121
|
+
(0, react_1.useEffect)(function () {
|
|
122
|
+
if (!tokenExIframe)
|
|
123
|
+
return;
|
|
124
|
+
tokenExIframe.load();
|
|
125
|
+
return function () { return tokenExIframe.remove(); };
|
|
126
|
+
}, [tokenExIframe]);
|
|
127
|
+
return {
|
|
128
|
+
tokenExIframe: tokenExIframe,
|
|
129
|
+
initializeTokenExIframe: initializeTokenExIframe,
|
|
130
|
+
initializeCvvOnlyTokenExIframe: initializeCvvOnlyTokenExIframe,
|
|
131
|
+
loaded: loaded,
|
|
132
|
+
cachedToken: cachedToken,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
exports.useCardFormIframe = useCardFormIframe;
|
|
136
|
+
function CSSPropertiesToComponent(dict) {
|
|
137
|
+
if (!dict)
|
|
138
|
+
return '';
|
|
139
|
+
if (typeof dict === 'string')
|
|
140
|
+
return dict;
|
|
141
|
+
var str = '';
|
|
142
|
+
var _loop_1 = function (key, value) {
|
|
143
|
+
var clo = '';
|
|
144
|
+
key.split('').forEach(function (lt) {
|
|
145
|
+
if (lt.toUpperCase() === lt) {
|
|
146
|
+
clo += '-' + lt.toLowerCase();
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
clo += lt;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
str += clo + ':' + value + ';';
|
|
153
|
+
};
|
|
154
|
+
for (var _i = 0, _a = Object.entries(dict); _i < _a.length; _i++) {
|
|
155
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
156
|
+
_loop_1(key, value);
|
|
157
|
+
}
|
|
158
|
+
return str;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=useCardFormIframe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCardFormIframe.js","sourceRoot":"","sources":["../../../src/card-form/useCardFormIframe.tsx"],"names":[],"mappings":";;;;;AAAA,+BAAsE;AACtE,oCAAgE;AA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,aAAa,eAAA;QACb,uBAAuB,yBAAA;QACvB,8BAA8B,gCAAA;QAC9B,MAAM,QAAA;QACN,WAAW,aAAA;KACZ,CAAC;AACJ,CAAC;AA3KD,8CA2KC;AAED,SAAS,wBAAwB,CAC/B,IAAwC;IAExC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE1C,IAAI,GAAG,GAAG,EAAE,CAAC;4BACD,GAAG,EAAE,KAAK;QACpB,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAA,EAAE;YACtB,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC5B,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,GAAG,IAAI,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC,CAAC;QACH,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC;;IATjC,KAA2B,UAAoB,EAApB,KAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAApB,cAAoB,EAApB,IAAoB;QAApC,IAAA,WAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;gBAAV,GAAG,EAAE,KAAK;KAUrB;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import { CoinflowPurchaseProps } from './CoinflowTypes';
|
|
1
|
+
import { CoinflowPurchaseProps, OnSuccessMethod } from './CoinflowTypes';
|
|
2
2
|
export type WalletCall = {
|
|
3
3
|
method: IFrameMessageMethods;
|
|
4
4
|
data: string;
|
|
5
|
+
} | SuccessWalletCall;
|
|
6
|
+
type SuccessWalletCall = {
|
|
7
|
+
method: IFrameMessageMethods.Success;
|
|
8
|
+
data: string;
|
|
9
|
+
info: {
|
|
10
|
+
paymentId: string;
|
|
11
|
+
hash?: string;
|
|
12
|
+
};
|
|
5
13
|
};
|
|
6
14
|
export interface IFrameMessageHandlers {
|
|
7
15
|
handleSendTransaction: (transaction: string) => Promise<string>;
|
|
8
16
|
handleSignMessage?: (message: string) => Promise<string>;
|
|
9
17
|
handleSignTransaction?: (transaction: string) => Promise<string>;
|
|
10
18
|
handleHeightChange?: (height: string) => void;
|
|
19
|
+
onSuccess: OnSuccessMethod | undefined;
|
|
11
20
|
}
|
|
12
21
|
declare enum IFrameMessageMethods {
|
|
13
22
|
SignMessage = "signMessage",
|
|
14
23
|
SignTransaction = "signTransaction",
|
|
15
24
|
SendTransaction = "sendTransaction",
|
|
16
|
-
HeightChange = "heightChange"
|
|
25
|
+
HeightChange = "heightChange",
|
|
26
|
+
Success = "success"
|
|
17
27
|
}
|
|
18
28
|
export declare function getWalletPubkey({ wallet, }: Pick<CoinflowPurchaseProps, 'wallet'>): string | null | undefined;
|
|
19
29
|
export declare function handleIFrameMessage(rawMessage: string, handlers: IFrameMessageHandlers): Promise<string> | void;
|
|
20
|
-
export declare function getHandlers(
|
|
30
|
+
export declare function getHandlers(props: Pick<CoinflowPurchaseProps, 'wallet' | 'blockchain' | 'onSuccess'>): Omit<IFrameMessageHandlers, 'handleHeightChange'>;
|
|
21
31
|
export {};
|