card-react-native 0.0.7
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/LICENSE +20 -0
- package/README.md +307 -0
- package/android/build.gradle +118 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/cardsdkreactnative/CardSdkReactNativePackage.kt +17 -0
- package/android/src/main/java/com/cardsdkreactnative/CardSdkReactNativeViewManager.kt +164 -0
- package/android/src/main/res/layout/cardview.xml +15 -0
- package/card-react-native.podspec +44 -0
- package/ios/CardSdkReactNative-Bridging-Header.h +2 -0
- package/ios/CardSdkReactNative.xcodeproj/project.pbxproj +283 -0
- package/ios/CardSdkReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/CardSdkReactNativeViewManager.m +21 -0
- package/ios/CardSdkReactNativeViewManager.swift +137 -0
- package/lib/commonjs/index.js +147 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/models/config.js +6 -0
- package/lib/commonjs/models/config.js.map +1 -0
- package/lib/commonjs/models/enums/TapCurrencyCode.js +188 -0
- package/lib/commonjs/models/enums/TapCurrencyCode.js.map +1 -0
- package/lib/commonjs/models/enums/index.js +28 -0
- package/lib/commonjs/models/enums/index.js.map +1 -0
- package/lib/commonjs/models/enums/sdkEnums.js +70 -0
- package/lib/commonjs/models/enums/sdkEnums.js.map +1 -0
- package/lib/commonjs/models/index.js +39 -0
- package/lib/commonjs/models/index.js.map +1 -0
- package/lib/commonjs/models/types.js +2 -0
- package/lib/commonjs/models/types.js.map +1 -0
- package/lib/module/index.js +123 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/config.js +2 -0
- package/lib/module/models/config.js.map +1 -0
- package/lib/module/models/enums/TapCurrencyCode.js +181 -0
- package/lib/module/models/enums/TapCurrencyCode.js.map +1 -0
- package/lib/module/models/enums/index.js +3 -0
- package/lib/module/models/enums/index.js.map +1 -0
- package/lib/module/models/enums/sdkEnums.js +56 -0
- package/lib/module/models/enums/sdkEnums.js.map +1 -0
- package/lib/module/models/index.js +4 -0
- package/lib/module/models/index.js.map +1 -0
- package/lib/module/models/types.js +2 -0
- package/lib/module/models/types.js.map +1 -0
- package/lib/typescript/src/index.d.ts +46 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/models/config.d.ts +114 -0
- package/lib/typescript/src/models/config.d.ts.map +1 -0
- package/lib/typescript/src/models/enums/TapCurrencyCode.d.ts +180 -0
- package/lib/typescript/src/models/enums/TapCurrencyCode.d.ts.map +1 -0
- package/lib/typescript/src/models/enums/index.d.ts +3 -0
- package/lib/typescript/src/models/enums/index.d.ts.map +1 -0
- package/lib/typescript/src/models/enums/sdkEnums.d.ts +48 -0
- package/lib/typescript/src/models/enums/sdkEnums.d.ts.map +1 -0
- package/lib/typescript/src/models/index.d.ts +4 -0
- package/lib/typescript/src/models/index.d.ts.map +1 -0
- package/lib/typescript/src/models/types.d.ts +5 -0
- package/lib/typescript/src/models/types.d.ts.map +1 -0
- package/package.json +163 -0
- package/src/index.tsx +194 -0
- package/src/models/config.ts +124 -0
- package/src/models/enums/TapCurrencyCode.ts +356 -0
- package/src/models/enums/index.ts +2 -0
- package/src/models/enums/sdkEnums.ts +54 -0
- package/src/models/index.ts +3 -0
- package/src/models/types.ts +16 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare enum SupportedBrands {
|
|
2
|
+
AMEX = "AMEX",
|
|
3
|
+
CARTESBANCAIRES = "CARTESBANCAIRES",
|
|
4
|
+
DISCOVER = "DISCOVER",
|
|
5
|
+
EFTPOS = "EFTPOS",
|
|
6
|
+
ELECTRON = "ELECTRON",
|
|
7
|
+
IDCREDIT = "IDCREDIT",
|
|
8
|
+
INTERAC = "INTERAC",
|
|
9
|
+
JCB = "JCB",
|
|
10
|
+
MAESTRO = "MAESTRO",
|
|
11
|
+
MASTERCARD = "MASTERCARD",
|
|
12
|
+
PRIVATELABEL = "PRIVATELABEL",
|
|
13
|
+
QUICPAY = "QUICPAY",
|
|
14
|
+
SUICA = "SUICA",
|
|
15
|
+
VISA = "VISA",
|
|
16
|
+
VPAY = "VPAY",
|
|
17
|
+
MADA = "MADA"
|
|
18
|
+
}
|
|
19
|
+
export declare enum Scope {
|
|
20
|
+
Token = "Token",
|
|
21
|
+
Authenticate = "Authenticate"
|
|
22
|
+
}
|
|
23
|
+
export declare enum SdkMode {
|
|
24
|
+
production = 0,
|
|
25
|
+
sandbox = 1
|
|
26
|
+
}
|
|
27
|
+
export declare enum Locale {
|
|
28
|
+
en = "en",
|
|
29
|
+
ar = "ar"
|
|
30
|
+
}
|
|
31
|
+
export declare enum SupportedCards {
|
|
32
|
+
All = "All",
|
|
33
|
+
Debit = "DEBIT",
|
|
34
|
+
Credit = "CREDIT"
|
|
35
|
+
}
|
|
36
|
+
export declare enum Theme {
|
|
37
|
+
light = "light",
|
|
38
|
+
dark = "dark"
|
|
39
|
+
}
|
|
40
|
+
export declare enum Edges {
|
|
41
|
+
curved = "curved",
|
|
42
|
+
flat = "flat"
|
|
43
|
+
}
|
|
44
|
+
export declare enum Direction {
|
|
45
|
+
ltr = "ltr",
|
|
46
|
+
rtl = "rtl"
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=sdkEnums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkEnums.d.ts","sourceRoot":"","sources":["../../../../../src/models/enums/sdkEnums.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,eAAe,oBAAoB;IACnC,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,oBAAY,KAAK;IACf,KAAK,UAAU;IACf,YAAY,iBAAiB;CAC9B;AAED,oBAAY,OAAO;IACjB,UAAU,IAAA;IACV,OAAO,IAAA;CACR;AAED,oBAAY,MAAM;IAChB,EAAE,OAAO;IACT,EAAE,OAAO;CACV;AAED,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,oBAAY,KAAK;IACf,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,oBAAY,KAAK;IACf,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}` : S;
|
|
2
|
+
export type CamelKeysToSnakeCase<T> = T extends Array<infer U> ? CamelKeysToSnakeCase<U>[] : T extends object ? {
|
|
3
|
+
[K in keyof T as CamelToSnakeCase<K & string>]: CamelKeysToSnakeCase<T[K]>;
|
|
4
|
+
} : T;
|
|
5
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/models/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAC3C,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,GAC5B,GAAG,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GACtB,GAAG,GACH,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAC7C,CAAC,CAAC;AAER,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAC1D,oBAAoB,CAAC,CAAC,CAAC,EAAE,GACzB,CAAC,SAAS,MAAM,GAChB;KACG,CAAC,IAAI,MAAM,CAAC,IAAI,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,oBAAoB,CAClE,CAAC,CAAC,CAAC,CAAC,CACL;CACF,GACD,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "card-react-native",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"description": "Tap Card SDK Wrapper",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/src/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"*.podspec",
|
|
17
|
+
"!lib/typescript/example",
|
|
18
|
+
"!ios/build",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!android/gradle",
|
|
21
|
+
"!android/gradlew",
|
|
22
|
+
"!android/gradlew.bat",
|
|
23
|
+
"!android/local.properties",
|
|
24
|
+
"!**/__tests__",
|
|
25
|
+
"!**/__fixtures__",
|
|
26
|
+
"!**/__mocks__",
|
|
27
|
+
"!**/.*"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
|
+
"prepack": "bob build",
|
|
34
|
+
"release": "release-it",
|
|
35
|
+
"example": "yarn --cwd example",
|
|
36
|
+
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
|
37
|
+
"build:ios": "cd example/ios && xcodebuild -workspace CardSdkReactNativeExample.xcworkspace -scheme CardSdkReactNativeExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
|
|
38
|
+
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"react-native",
|
|
43
|
+
"ios",
|
|
44
|
+
"android"
|
|
45
|
+
],
|
|
46
|
+
"repository": "https://github.com/Tap-Payments/Card-React-Native",
|
|
47
|
+
"author": "mahmoudAllam <m.allam@tap.company> (https://github.com/mAllamTapPayments)",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/Tap-Payments/Card-React-Native/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/Tap-Payments/Card-React-Native#readme",
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
58
|
+
"@evilmartians/lefthook": "^1.2.2",
|
|
59
|
+
"@react-native/eslint-config": "^0.72.2",
|
|
60
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
61
|
+
"@types/jest": "^28.1.2",
|
|
62
|
+
"@types/react": "~17.0.21",
|
|
63
|
+
"@types/react-native": "0.70.0",
|
|
64
|
+
"commitlint": "^17.0.2",
|
|
65
|
+
"del-cli": "^5.0.0",
|
|
66
|
+
"eslint": "^8.4.1",
|
|
67
|
+
"eslint-config-prettier": "^8.5.0",
|
|
68
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
69
|
+
"jest": "^28.1.1",
|
|
70
|
+
"pod-install": "^0.1.0",
|
|
71
|
+
"prettier": "^2.0.5",
|
|
72
|
+
"react": "18.2.0",
|
|
73
|
+
"react-native": "0.72.4",
|
|
74
|
+
"react-native-builder-bob": "^0.20.0",
|
|
75
|
+
"release-it": "^15.0.0",
|
|
76
|
+
"turbo": "^1.10.7",
|
|
77
|
+
"typescript": "^5.0.2"
|
|
78
|
+
},
|
|
79
|
+
"resolutions": {
|
|
80
|
+
"@types/react": "17.0.21"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"react": "*",
|
|
84
|
+
"react-native": "*"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">= 18.0.0"
|
|
88
|
+
},
|
|
89
|
+
"packageManager": "^yarn@1.22.15",
|
|
90
|
+
"jest": {
|
|
91
|
+
"preset": "react-native",
|
|
92
|
+
"modulePathIgnorePatterns": [
|
|
93
|
+
"<rootDir>/example/node_modules",
|
|
94
|
+
"<rootDir>/lib/"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"commitlint": {
|
|
98
|
+
"extends": [
|
|
99
|
+
"@commitlint/config-conventional"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"release-it": {
|
|
103
|
+
"git": {
|
|
104
|
+
"commitMessage": "chore: release ${version}",
|
|
105
|
+
"tagName": "v${version}"
|
|
106
|
+
},
|
|
107
|
+
"npm": {
|
|
108
|
+
"publish": true
|
|
109
|
+
},
|
|
110
|
+
"github": {
|
|
111
|
+
"release": true
|
|
112
|
+
},
|
|
113
|
+
"plugins": {
|
|
114
|
+
"@release-it/conventional-changelog": {
|
|
115
|
+
"preset": "angular"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"eslintConfig": {
|
|
120
|
+
"root": true,
|
|
121
|
+
"extends": [
|
|
122
|
+
"@react-native",
|
|
123
|
+
"prettier"
|
|
124
|
+
],
|
|
125
|
+
"rules": {
|
|
126
|
+
"prettier/prettier": [
|
|
127
|
+
"error",
|
|
128
|
+
{
|
|
129
|
+
"quoteProps": "consistent",
|
|
130
|
+
"singleQuote": true,
|
|
131
|
+
"tabWidth": 2,
|
|
132
|
+
"trailingComma": "es5",
|
|
133
|
+
"useTabs": false
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"eslintIgnore": [
|
|
139
|
+
"node_modules/",
|
|
140
|
+
"lib/"
|
|
141
|
+
],
|
|
142
|
+
"prettier": {
|
|
143
|
+
"quoteProps": "consistent",
|
|
144
|
+
"singleQuote": true,
|
|
145
|
+
"tabWidth": 2,
|
|
146
|
+
"trailingComma": "es5",
|
|
147
|
+
"useTabs": false
|
|
148
|
+
},
|
|
149
|
+
"react-native-builder-bob": {
|
|
150
|
+
"source": "src",
|
|
151
|
+
"output": "lib",
|
|
152
|
+
"targets": [
|
|
153
|
+
"commonjs",
|
|
154
|
+
"module",
|
|
155
|
+
[
|
|
156
|
+
"typescript",
|
|
157
|
+
{
|
|
158
|
+
"project": "tsconfig.build.json"
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requireNativeComponent,
|
|
3
|
+
UIManager,
|
|
4
|
+
Platform,
|
|
5
|
+
type ViewStyle,
|
|
6
|
+
findNodeHandle,
|
|
7
|
+
type NativeSyntheticEvent,
|
|
8
|
+
LayoutAnimation,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import type { Config } from './models';
|
|
12
|
+
import React, {
|
|
13
|
+
useImperativeHandle,
|
|
14
|
+
type Ref,
|
|
15
|
+
forwardRef,
|
|
16
|
+
useRef,
|
|
17
|
+
useCallback,
|
|
18
|
+
type MutableRefObject,
|
|
19
|
+
useState,
|
|
20
|
+
} from 'react';
|
|
21
|
+
|
|
22
|
+
export * from './models';
|
|
23
|
+
|
|
24
|
+
const LINKING_ERROR =
|
|
25
|
+
`The package 'card-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
26
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
27
|
+
'- You rebuilt the app after installing the package\n' +
|
|
28
|
+
'- You are not using Expo Go\n';
|
|
29
|
+
|
|
30
|
+
const ComponentName = 'CardSdkReactNativeView';
|
|
31
|
+
|
|
32
|
+
export const CardSdkReactNativeView =
|
|
33
|
+
UIManager.getViewManagerConfig(ComponentName) != null
|
|
34
|
+
? requireNativeComponent<ITapCardViewNativeProps>(ComponentName)
|
|
35
|
+
: () => {
|
|
36
|
+
throw new Error(LINKING_ERROR);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export interface ITapCardViewInputRef {
|
|
40
|
+
generateToken: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type TapCardViewInputRef = Ref<ITapCardViewInputRef>;
|
|
44
|
+
export interface ITapCardViewProps {
|
|
45
|
+
style: ViewStyle;
|
|
46
|
+
config: Config;
|
|
47
|
+
ref: TapCardViewInputRef;
|
|
48
|
+
onSuccess: (token: Object) => void;
|
|
49
|
+
onReady: () => void;
|
|
50
|
+
onFocus: () => void;
|
|
51
|
+
onHeightChange: (height: number) => void;
|
|
52
|
+
onBinIdentification: (binIdentification: Object) => void;
|
|
53
|
+
onInvalidInput: (invalid: boolean) => void;
|
|
54
|
+
onError: (error: object) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ITapCardViewNativeProps {
|
|
58
|
+
style: ViewStyle;
|
|
59
|
+
config: Config;
|
|
60
|
+
ref: TapCardViewInputRef;
|
|
61
|
+
onSuccess: ({
|
|
62
|
+
nativeEvent: { data },
|
|
63
|
+
}: NativeSyntheticEvent<{ data: Object }>) => void;
|
|
64
|
+
onReadyCallback: () => void;
|
|
65
|
+
onFocusCallback: () => void;
|
|
66
|
+
onHeightChange: ({
|
|
67
|
+
nativeEvent: { data },
|
|
68
|
+
}: NativeSyntheticEvent<{ data: number }>) => void;
|
|
69
|
+
onBinIdentification: ({
|
|
70
|
+
nativeEvent: { data },
|
|
71
|
+
}: NativeSyntheticEvent<{ data: Object }>) => void;
|
|
72
|
+
onInvalidInput: ({
|
|
73
|
+
nativeEvent: { data },
|
|
74
|
+
}: NativeSyntheticEvent<{ data: boolean }>) => void;
|
|
75
|
+
onError: ({
|
|
76
|
+
nativeEvent: { data },
|
|
77
|
+
}: NativeSyntheticEvent<{ data: Object }>) => void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// UIManager.setLayoutAnimationEnabledExperimental &&
|
|
81
|
+
// UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
82
|
+
|
|
83
|
+
function TapCardView(
|
|
84
|
+
{
|
|
85
|
+
style,
|
|
86
|
+
config,
|
|
87
|
+
onSuccess,
|
|
88
|
+
onReady,
|
|
89
|
+
onFocus,
|
|
90
|
+
onHeightChange,
|
|
91
|
+
onBinIdentification,
|
|
92
|
+
onInvalidInput,
|
|
93
|
+
onError,
|
|
94
|
+
}: ITapCardViewProps,
|
|
95
|
+
ref: TapCardViewInputRef
|
|
96
|
+
) {
|
|
97
|
+
const viewRef =
|
|
98
|
+
useRef<ITapCardViewInputRef>() as MutableRefObject<ITapCardViewInputRef>;
|
|
99
|
+
const [height, setHeight] = useState(style.height ?? 95);
|
|
100
|
+
const [addFlex, setAddFlex] = useState(false);
|
|
101
|
+
|
|
102
|
+
const generateToken = useCallback(() => {
|
|
103
|
+
return UIManager.dispatchViewManagerCommand(
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
findNodeHandle(viewRef.current),
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
UIManager.CardSdkReactNativeView.Commands.generateToken,
|
|
108
|
+
[]
|
|
109
|
+
);
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
useImperativeHandle(
|
|
113
|
+
ref,
|
|
114
|
+
() => ({
|
|
115
|
+
generateToken: () => {
|
|
116
|
+
generateToken();
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
[generateToken]
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const handleOnSuccess = ({
|
|
123
|
+
nativeEvent: { data },
|
|
124
|
+
}: NativeSyntheticEvent<{ data: Object }>) => {
|
|
125
|
+
onSuccess(data);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const handleOnHeightChange = ({
|
|
129
|
+
nativeEvent: { data },
|
|
130
|
+
}: NativeSyntheticEvent<{ data: number }>) => {
|
|
131
|
+
LayoutAnimation.spring();
|
|
132
|
+
setHeight(data);
|
|
133
|
+
onHeightChange(data);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const handleOnReady = () => {
|
|
137
|
+
onReady();
|
|
138
|
+
setAddFlex(true);
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
setAddFlex(false);
|
|
141
|
+
}, 1);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const handleOnFocus = () => {
|
|
145
|
+
onFocus();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const handleOnBinIdentification = ({
|
|
149
|
+
nativeEvent: { data },
|
|
150
|
+
}: NativeSyntheticEvent<{ data: Object }>) => {
|
|
151
|
+
onBinIdentification(data);
|
|
152
|
+
};
|
|
153
|
+
const handleOnInvalidInput = ({
|
|
154
|
+
nativeEvent: { data },
|
|
155
|
+
}: NativeSyntheticEvent<{ data: boolean }>) => {
|
|
156
|
+
onInvalidInput(data);
|
|
157
|
+
};
|
|
158
|
+
const handleOnError = ({
|
|
159
|
+
nativeEvent: { data },
|
|
160
|
+
}: NativeSyntheticEvent<{ data: object }>) => {
|
|
161
|
+
onError(data);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<View
|
|
166
|
+
style={{
|
|
167
|
+
...style,
|
|
168
|
+
height: height,
|
|
169
|
+
flex: addFlex ? 0.1 : 0,
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<CardSdkReactNativeView
|
|
173
|
+
style={{ ...style, flex: 1, height: height }}
|
|
174
|
+
config={{
|
|
175
|
+
...config,
|
|
176
|
+
features: {
|
|
177
|
+
...config.features,
|
|
178
|
+
nfc: Platform.OS === 'ios' ? false : config.features.nfc,
|
|
179
|
+
},
|
|
180
|
+
}}
|
|
181
|
+
ref={viewRef}
|
|
182
|
+
onSuccess={handleOnSuccess}
|
|
183
|
+
onReadyCallback={handleOnReady}
|
|
184
|
+
onFocusCallback={handleOnFocus}
|
|
185
|
+
onHeightChange={handleOnHeightChange}
|
|
186
|
+
onBinIdentification={handleOnBinIdentification}
|
|
187
|
+
onInvalidInput={handleOnInvalidInput}
|
|
188
|
+
onError={handleOnError}
|
|
189
|
+
/>
|
|
190
|
+
</View>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export default forwardRef(TapCardView);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Direction,
|
|
3
|
+
Edges,
|
|
4
|
+
Locale,
|
|
5
|
+
Scope,
|
|
6
|
+
SupportedBrands,
|
|
7
|
+
SupportedCards,
|
|
8
|
+
TapCurrencyCode,
|
|
9
|
+
Theme,
|
|
10
|
+
} from './enums';
|
|
11
|
+
|
|
12
|
+
export type Merchant = { id: String };
|
|
13
|
+
export type PaymentAgreement = {
|
|
14
|
+
id: String;
|
|
15
|
+
contract: Contract;
|
|
16
|
+
};
|
|
17
|
+
export type Contract = {
|
|
18
|
+
id: String;
|
|
19
|
+
};
|
|
20
|
+
export type Transaction = {
|
|
21
|
+
metadata: Object;
|
|
22
|
+
reference: String;
|
|
23
|
+
paymentAgreement: PaymentAgreement;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type Phone = { countryCode: String; number: String };
|
|
27
|
+
export type Fields = {
|
|
28
|
+
card: { cardHolder: boolean; cvv: boolean };
|
|
29
|
+
};
|
|
30
|
+
export type InterfaceConfig = {
|
|
31
|
+
locale: Locale;
|
|
32
|
+
theme: Theme;
|
|
33
|
+
edges: Edges;
|
|
34
|
+
cardDirection: Direction;
|
|
35
|
+
colorStyle: 'monochrome' | 'colored';
|
|
36
|
+
powered: true;
|
|
37
|
+
};
|
|
38
|
+
export type Addons = {
|
|
39
|
+
loader: boolean;
|
|
40
|
+
};
|
|
41
|
+
export type Acceptance = {
|
|
42
|
+
supportedSchemes: SupportedBrands[];
|
|
43
|
+
supportedFundSource: SupportedCards[];
|
|
44
|
+
supportedPaymentAuthentications: ['3DS'] | [];
|
|
45
|
+
};
|
|
46
|
+
export type Contact = {
|
|
47
|
+
email: String;
|
|
48
|
+
phone: Phone;
|
|
49
|
+
};
|
|
50
|
+
export type Name = {
|
|
51
|
+
lang: Locale;
|
|
52
|
+
first: String;
|
|
53
|
+
last: String;
|
|
54
|
+
middle: String;
|
|
55
|
+
};
|
|
56
|
+
export type Customer = {
|
|
57
|
+
id: String;
|
|
58
|
+
name: Name[];
|
|
59
|
+
nameOnCard: String;
|
|
60
|
+
editable: boolean;
|
|
61
|
+
contact: Contact;
|
|
62
|
+
};
|
|
63
|
+
export type AuthenticationTransactionInvoice = {
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type AuthenticationPost = {
|
|
68
|
+
url: String;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type AuthenticationTransaction = {
|
|
72
|
+
transaction: String;
|
|
73
|
+
order: String;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type Order = {
|
|
77
|
+
id: String;
|
|
78
|
+
amount: number;
|
|
79
|
+
currency: TapCurrencyCode;
|
|
80
|
+
description: String;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type Invoice = {
|
|
84
|
+
id: String;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type Post = {
|
|
88
|
+
url: String;
|
|
89
|
+
};
|
|
90
|
+
export type Redirect = {
|
|
91
|
+
url: String;
|
|
92
|
+
};
|
|
93
|
+
export type Features = {
|
|
94
|
+
scanner: boolean;
|
|
95
|
+
acceptanceBadge: boolean;
|
|
96
|
+
nfc: boolean;
|
|
97
|
+
customerCards: {
|
|
98
|
+
saveCard: boolean;
|
|
99
|
+
autoSaveCard: boolean;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export type Config = {
|
|
103
|
+
publicKey: String;
|
|
104
|
+
merchant: Merchant;
|
|
105
|
+
transaction: Transaction;
|
|
106
|
+
order: Order;
|
|
107
|
+
invoice: Invoice;
|
|
108
|
+
post: Post;
|
|
109
|
+
operator: { publicKey: String };
|
|
110
|
+
purpose:
|
|
111
|
+
| 'PAYMENT_TRANSACTION'
|
|
112
|
+
| 'RECURRING_TRANSACTION'
|
|
113
|
+
| 'INSTALLMENT_TRANSACTION'
|
|
114
|
+
| 'ADD_CARD'
|
|
115
|
+
| 'CARDHOLDER_VERIFICATION';
|
|
116
|
+
fields: Fields;
|
|
117
|
+
acceptance: Acceptance;
|
|
118
|
+
addons: Addons;
|
|
119
|
+
interface: InterfaceConfig;
|
|
120
|
+
scope: Scope;
|
|
121
|
+
customer: Customer;
|
|
122
|
+
redirect: Redirect;
|
|
123
|
+
features: Features;
|
|
124
|
+
};
|