fidel-react-native 1.6.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +1 -51
  2. package/README.md +4 -378
  3. package/android/build.gradle +12 -8
  4. package/android/jacoco.gradle +2 -2
  5. package/android/src/main/java/com/fidelreactlibrary/FidelModule.java +61 -44
  6. package/android/src/main/java/com/fidelreactlibrary/FidelPackage.java +64 -49
  7. package/android/src/main/java/com/fidelreactlibrary/adapters/CardVerificationConfigurationProperties.java +22 -0
  8. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelCardSchemesAdapter.java +46 -29
  9. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelCardVerificationChoiceAdapter.java +57 -0
  10. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelCountryAdapter.java +47 -19
  11. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelProgramTypeAdapter.java +46 -0
  12. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelSetupAdapter.java +108 -6
  13. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelSetupProperties.java +67 -0
  14. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelVerificationConfigurationAdapter.java +35 -0
  15. package/android/src/main/java/com/fidelreactlibrary/adapters/ImageFromReadableMapAdapter.java +5 -1
  16. package/android/src/main/java/com/fidelreactlibrary/adapters/ResultsAdapter.java +288 -0
  17. package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/CardSchemesAdapter.java +6 -2
  18. package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/CardVerificationChoiceAdapter.java +11 -0
  19. package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/CountryAdapter.java +14 -3
  20. package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/DataAdapter.java +5 -0
  21. package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/ProgramTypeAdapter.java +11 -0
  22. package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/VerificationConfigurationAdapter.java +9 -0
  23. package/android/src/main/java/com/fidelreactlibrary/events/BridgeLibraryEvent.java +17 -0
  24. package/android/src/main/java/com/fidelreactlibrary/events/BridgeLibraryEventEmitter.java +24 -0
  25. package/android/src/main/java/com/fidelreactlibrary/events/CardVerificationChoiceObserver.java +29 -0
  26. package/android/src/main/java/com/fidelreactlibrary/events/CardVerificationStartedObserver.java +31 -0
  27. package/android/src/main/java/com/fidelreactlibrary/events/ResultsObserver.java +72 -0
  28. package/android/src/test/java/com/fidelreactlibrary/FidelModuleTests.java +50 -31
  29. package/android/src/test/java/com/fidelreactlibrary/FidelPackageTests.java +0 -1
  30. package/android/src/test/java/com/fidelreactlibrary/{FidelCardSchemesAdapterTests.java → adapters/FidelCardSchemesAdapterTests.java} +51 -47
  31. package/android/src/test/java/com/fidelreactlibrary/adapters/FidelCardVerificationChoiceAdapterTest.java +70 -0
  32. package/android/src/test/java/com/fidelreactlibrary/adapters/FidelCountryAdapterTests.java +157 -0
  33. package/android/src/test/java/com/fidelreactlibrary/adapters/FidelProgramTypeAdapterTests.java +54 -0
  34. package/android/src/test/java/com/fidelreactlibrary/adapters/FidelSetupAdapterTests.java +900 -0
  35. package/android/src/test/java/com/fidelreactlibrary/adapters/FidelVerificationConfigurationAdapterTest.java +51 -0
  36. package/android/src/test/java/com/fidelreactlibrary/adapters/ResultsAdapterTests.java +74 -0
  37. package/android/src/test/java/com/fidelreactlibrary/{ErrorEventEmitterTests.java → events/BridgeLibraryEventEmitterTests.java} +18 -7
  38. package/android/src/test/java/com/fidelreactlibrary/events/BridgeLibraryEventTests.java +17 -0
  39. package/android/src/test/java/com/fidelreactlibrary/events/CardVerificationStartedObserverTests.java +49 -0
  40. package/android/src/test/java/com/fidelreactlibrary/events/ResultsObserverTests.java +38 -0
  41. package/android/src/test/java/com/fidelreactlibrary/fakes/CardSchemeAdapterStub.java +17 -6
  42. package/android/src/test/java/com/fidelreactlibrary/fakes/ConstantsProviderStub.java +2 -2
  43. package/android/src/test/java/com/fidelreactlibrary/fakes/CountryAdapterStub.java +25 -10
  44. package/android/src/test/java/com/fidelreactlibrary/fakes/{DataConverterStub.java → DataAdapterStub.java} +3 -3
  45. package/android/src/test/java/com/fidelreactlibrary/fakes/ProgramTypeAdapterStub.java +31 -0
  46. package/android/src/test/java/com/fidelreactlibrary/fakes/ReactContextMock.java +1 -1
  47. package/android/src/test/java/com/fidelreactlibrary/fakes/ReadableArrayStub.java +82 -0
  48. package/android/src/test/java/com/fidelreactlibrary/fakes/ReadableMapStub.java +175 -40
  49. package/android/src/test/java/com/fidelreactlibrary/fakes/VerificationConfigurationAdapterStub.java +13 -0
  50. package/fidel-react-native.podspec +1 -1
  51. package/index.js +78 -19
  52. package/ios/Adapters/CardSchemesAdapter.swift +13 -0
  53. package/ios/Adapters/ConsentDetailsAdapter.swift +19 -0
  54. package/ios/Adapters/EnrollmentResultAdapter.swift +28 -0
  55. package/ios/Adapters/ErrorResultAdapter.swift +71 -0
  56. package/ios/{FLRNImageAdapter.h → Adapters/FLRNImageFromRNAdapter.h} +2 -3
  57. package/ios/Adapters/FidelSetupAdapter.swift +89 -0
  58. package/ios/Adapters/FidelVerificationConfigurationAdapter.swift +19 -0
  59. package/ios/Adapters/VerificationResultAdapter.swift +17 -0
  60. package/ios/CardVerificationConfigurationProperties.swift +14 -0
  61. package/ios/Constants/CardSchemeConstants.swift +38 -0
  62. package/ios/Constants/CardVerificationChoiceConstants.swift +24 -0
  63. package/ios/Constants/CountryConstants.swift +47 -0
  64. package/ios/Constants/EnrollmentErrorTypeConstants.swift +25 -0
  65. package/ios/Constants/ErrorTypeConstants.swift +37 -0
  66. package/ios/Constants/ExportedConstantsProvider.swift +42 -0
  67. package/ios/Constants/ProgramTypeConstants.swift +30 -0
  68. package/ios/Constants/ResultTypeConstants.swift +35 -0
  69. package/ios/Constants/VerificationErrorTypeConstants.swift +29 -0
  70. package/ios/Events/BridgeLibraryEvent.swift +14 -0
  71. package/ios/Events/CardVerificationChoiceSelectedObserver.swift +23 -0
  72. package/ios/Events/CardVerificationStartedObserver.swift +21 -0
  73. package/ios/Events/EventObserver.swift +13 -0
  74. package/ios/Events/JSResultProperties.swift +15 -0
  75. package/ios/Events/JSResultTypes.swift +14 -0
  76. package/ios/Events/ResultsObserver.swift +37 -0
  77. package/ios/FidelSetupProperties.swift +33 -0
  78. package/ios/NativeFidelBridge.m +13 -0
  79. package/ios/NativeFidelBridge.swift +100 -0
  80. package/package.json +1 -4
  81. package/android/src/main/java/com/fidelreactlibrary/adapters/FidelOptionsAdapter.java +0 -121
  82. package/android/src/main/java/com/fidelreactlibrary/adapters/WritableMapDataConverter.java +0 -94
  83. package/android/src/main/java/com/fidelreactlibrary/adapters/abstraction/DataConverter.java +0 -5
  84. package/android/src/main/java/com/fidelreactlibrary/events/CallbackActivityEventListener.java +0 -64
  85. package/android/src/main/java/com/fidelreactlibrary/events/CallbackInput.java +0 -7
  86. package/android/src/main/java/com/fidelreactlibrary/events/ErrorEventEmitter.java +0 -22
  87. package/android/src/test/java/com/fidelreactlibrary/CallbackActivityEventListenerTests.java +0 -133
  88. package/android/src/test/java/com/fidelreactlibrary/FidelCountryAdapterTests.java +0 -74
  89. package/android/src/test/java/com/fidelreactlibrary/FidelOptionsAdapterTests.java +0 -414
  90. package/android/src/test/java/com/fidelreactlibrary/FidelSetupAdapterTests.java +0 -65
  91. package/android/src/test/java/com/fidelreactlibrary/WritableMapDataConverterTests.java +0 -186
  92. package/android/src/test/java/com/fidelreactlibrary/fakes/CallbackInputSpy.java +0 -12
  93. package/android/src/test/java/com/fidelreactlibrary/fakes/CallbackSpy.java +0 -18
  94. package/android/src/test/java/com/fidelreactlibrary/fakes/IntentMock.java +0 -20
  95. package/ios/FLRNCardSchemesAdapter.h +0 -16
  96. package/ios/FLRNCardSchemesFromJSAdapter.h +0 -14
  97. package/ios/FLRNCardSchemesFromJSAdapter.m +0 -39
  98. package/ios/FLRNConstantsProvider.h +0 -15
  99. package/ios/FLRNImageFromRNAdapter.h +0 -14
  100. package/ios/FLRNObjectToDictionaryAdapter.h +0 -15
  101. package/ios/FLRNOptionsAdapter.h +0 -24
  102. package/ios/FLRNOptionsAdapter.m +0 -133
  103. package/ios/FLRNRuntimeObjectToDictionaryAdapter.h +0 -14
  104. package/ios/FLRNRuntimeObjectToDictionaryAdapter.m +0 -36
  105. package/ios/FLRNSDKOptions.h +0 -24
  106. package/ios/FLRNSDKSetupOptions.h +0 -14
  107. package/ios/FLRNSetupAdapter.h +0 -17
  108. package/ios/FLRNSetupAdapter.m +0 -50
  109. package/ios/Fidel.h +0 -20
  110. package/ios/Fidel.m +0 -79
  111. package/ios/RCTConvert+CardScheme.h +0 -33
  112. package/ios/RCTConvert+Options.h +0 -52
  113. package/ios/RCTConvert+Options.m +0 -21
  114. /package/ios/{FLRNImageFromRNAdapter.m → Adapters/FLRNImageFromRNAdapter.m} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,53 +1,3 @@
1
1
  # Fidel React Native bridge library change log
2
2
 
3
- ## 1.6.2
4
- - Update Fidel API logo
5
-
6
- ## 1.6.1
7
- - Always provide the `scheme` field in Android, after successful card enrollments.
8
- - Provide support for `resConfigs` optimization parameter in Android.
9
-
10
- ## 1.6.0
11
- - Added the `defaultSelectedCountry` property which sets the country that will be selected by default, when opening the card enrollment screen.
12
-
13
- ## 1.5.0
14
- - Remove card scanning confirmation screen.
15
-
16
- ## 1.4.3
17
- - Add United Arab Emirates option as a country of issuance.
18
- - Country label shrinks its font size, to fit longer country names, on smaller devices.
19
-
20
- ## 1.4.2
21
- - Update Fidel Android SDK version to allow French & Swedish translations be available in more countries.
22
-
23
- ## 1.4.1
24
- - Update Fidel & Android SDK versions.
25
- - Prepare for the newest React Native versions.
26
- - Fix some unit tests.
27
- - Made it easier to automate testing this React Native bridge library.
28
-
29
- ## 1.4.0
30
-
31
- - Now the SDK allows you to select multiple allowed countries from which the user can pick. Please check the docs for information about the new `allowedCountries` option.
32
- - Removed the `country` option. To set a default country and not allow the user to pick the country, set a single country in the new `allowedCountries` option. Check the example project or the README docs to see how to do that.
33
- - If available, the linking result object now includes the `firstNumbers` field. So, if in the Fidel Dashboard, under your security settings, you allow showing the first numbers of the linked card numbers, the information will be available in the linking result object too. If you do not allow showing the first numbers in the linking result, the `firstNumbers` field will return `"******"` (just like the object which the Fidel API returns).
34
-
35
- ## 1.3.1
36
-
37
- - Fixes an Android issue in the latest React Native versions, when specifying the banner image in release environment.
38
- - Checking for `null` values, in mandatory SDK fields, to prevent unclear bugs.
39
-
40
- ## 1.3.0
41
-
42
- - Localised the SDK for French and Swedish users.
43
- - The terms & conditions text now adjusts to the card scheme name that the user inputs (Visa, MasterCard or Amex).
44
- - If you set the default country of the SDK to USA or Canada (with `country` option) or, if you do not set a default country, the terms and conditions text will adjust depending on the country you have set. For USA & Canada, the following would be an example Terms & Conditions text, for Cashback Inc (an example company):
45
-
46
- *By submitting your card information and checking this box, you authorize Visa to monitor and share transaction data with Fidel (our service provider) to participate in program. You also acknowledge and agree that Fidel may share certain details of your qualifying transactions with Cashback Inc to enable your participation in program and for other purposes in accordance with the Cashback Inc Terms and Conditions, Cashback Inc privacy policy and Fidel’s Privacy Policy. You may opt-out of transaction monitoring on the linked card at any time by contacting support.*
47
-
48
- For the rest of the world:
49
-
50
- *I authorise Visa to monitor my payment card to identify transactions that qualify for a reward and for Visa to share such information with Cashback Inc, to enable my card linked offers and target offers that may be of interest to me. For information about Cashback Inc privacy practices, please see the privacy policy. You may opt-out of transaction monitoring on the payment card you entered at any time by contacting support.*
51
-
52
- - Added the `programName` and `termsConditionsUrl` options. They are used when building the new USA / Canada specific terms and conditions text that the user must agree with, before linking a card. If you set the `country` option to a USA or Canada, it's mandatory for you to provide your terms and conditions URL via `termsConditionsUrl`. If you do not provide it, you will receive an error when you try to open Fidel's linking screen.
53
- - Fixed bug that returned an empty link result in Android, when linking is successful.
3
+ Please check our website for the latest information about our [React Native SDK releases](https://fidelapi.com/docs/select/sdks/react-native/releases).
package/README.md CHANGED
@@ -1,144 +1,12 @@
1
-
2
- # Fidel React Native bridge SDK
1
+ # Fidel React Native SDK
3
2
 
4
3
  This SDK is a bridge between React Native and Fidel's native iOS and Android SDKs. It helps you to add card linking technology to your React Native apps in minutes. It captures credit/debit card numbers securely and links them to your programs.
5
4
 
6
5
  ![Demo GIF](https://cl.ly/a47b1852f029/Screen%252520Recording%2525202018-09-18%252520at%25252004.34%252520PM.gif)
7
6
 
8
- ## Getting started
9
-
10
- `$ npm install fidel-react-native`
11
-
12
- or
13
-
14
- `$ yarn add fidel-react-native`
15
-
16
- ### iOS
17
-
18
- **1.** Please make sure that the minimum platform is set to 9.1 in your Podfile: `platform :ios, '9.1'`.
19
-
20
- **2.** Run `pod install`.
21
-
22
- ### Android
23
-
24
- **1.** Append Jitpack to `android/build.gradle`:
25
-
26
- ```java
27
- allprojects {
28
- repositories {
29
- ...
30
- maven { url "https://jitpack.io" }
31
- }
32
- }
33
- ```
34
-
35
- **2.** Make sure that the `minSdkVersion` is the same or higher than the `minSdkVersion` of our native Android SDK:
36
-
37
- ```java
38
- buildscript {
39
- ext {
40
- ...
41
- minSdkVersion = 19
42
- ...
43
- }
44
- }
45
- ```
46
-
47
- ## How to use Fidel's React Native SDK
48
-
49
- Import Fidel in your RN project:
50
-
51
- ```javascript
52
- import Fidel from 'fidel-react-native';
53
- ```
7
+ ## Documentation
54
8
 
55
- Set up Fidel with your API key and your program ID. Without them you can't open the Fidel card linking UI:
56
-
57
- ```javascript
58
- Fidel.setup({
59
- apiKey:'your api key',
60
- programId: 'your program id'
61
- })
62
- ```
63
-
64
- Set the options that create the experience of linking a card with Fidel:
65
-
66
- ```javascript
67
- const myImage = require('./images/fdl_test_banner.png');
68
- const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
69
- const resolvedImage = resolveAssetSource(myImage);
70
-
71
- //this is the default value for supported card schemes,
72
- //but you can remove the support for some of the card schemes if you want to
73
- const cardSchemes = new Set([
74
- Fidel.CardScheme.visa,
75
- Fidel.CardScheme.mastercard,
76
- Fidel.CardScheme.americanExpress
77
- ]);
78
-
79
- const countries = [Fidel.Country.ireland, Fidel.Country.unitedStates];
80
-
81
- Fidel.setOptions({
82
- bannerImage: resolvedImage,
83
- allowedCountries: countries,
84
- defaultSelectedCountry: Fidel.Country.unitedStates,
85
- supportedCardSchemes: Array.from(cardSchemes),
86
- autoScan: false,
87
- metaData: {'meta-data-1': 'value1'}, // additional data to pass with the card
88
- companyName: 'My RN Company', // the company name displayed in the checkbox text
89
- deleteInstructions: 'Your custom delete instructions!',
90
- privacyUrl: 'https://fidel.uk',
91
- termsConditionsUrl: 'https://fidel.uk/privacy', // mandatory when you include USA/Canada in the list of allowed countries or when the user can select USA/Canada from the country selection UI
92
- programName: 'My program name', // optional, is used when you include USA/Canada in the list of allowed countries or when the user can select USA/Canada from the country selection UI
93
- });
94
- ```
95
-
96
- Open the card linking view by calling:
97
-
98
- ```javascript
99
- Fidel.openForm((error, result) => {
100
- if (error) {
101
- console.error(error);
102
- } else {
103
- console.info(result);
104
- }
105
- });
106
- ```
107
-
108
- Both `result` and `error` are objects that look like in the following examples:
109
-
110
- ### Result
111
-
112
- ```javascript
113
- {
114
- accountId: "the-account-id"
115
- countryCode: "GBR" // the country selected by the user, in the Fidel SDK form
116
- created: "2019-04-22T05:26:45.611Z"
117
- expDate: "2023-12-31T23:59:59.999Z" // the card expiration date
118
- expMonth: 12 // for your convenience, this is the card expiration month
119
- expYear: 2023 // for your convenience, this is the card expiration year
120
- id: "card-id" // the card ID as registered on the Fidel platform
121
- firstNumbers: "444400" //first numbers of the card
122
- lastNumbers: "4001" //last numbers of the card
123
- live: false
124
- mapped: false
125
- metaData: {meta-data-1: "value1"} //the meta data that you specified for the Fidel SDK
126
- programId: "your program ID, as specified for the Fidel SDK"
127
- scheme: "visa"
128
- type: "visa"
129
- updated: "2019-04-22T05:26:45.611Z"
130
- }
131
- ```
132
-
133
- ### Error
134
-
135
- ```javascript
136
- {
137
- code: "item-save" // the code of the error
138
- date: "2019-04-22T05:34:04.621Z" // the date of the card link request
139
- message: "Item already exists" // the message of the error
140
- }
141
- ```
9
+ Our website includes all the [React Native SDK documentation](https://fidelapi.com/docs/select/sdks/react-native/guide-v2).
142
10
 
143
11
  ## How to run the example application
144
12
 
@@ -156,252 +24,10 @@ Both `result` and `error` are objects that look like in the following examples:
156
24
  3. Run the following command to start Metro: `npx react-native start`
157
25
  4. Run the project on your preferred emulator/device.
158
26
 
159
- ## Options documentation
160
-
161
- ### bannerImage
162
-
163
- Use this option to customize the topmost banner image with the Fidel UI. Your custom asset needs to be resolved in order to be passed to our native module:
164
-
165
- ```javascript
166
- const myImage = require('./images/fdl_test_banner.png');
167
- const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
168
- const resolvedImage = resolveAssetSource(myImage);
169
- Fidel.setOptions({
170
- bannerImage: resolvedImage
171
- }
172
- ```
173
-
174
- ### allowedCountries
175
-
176
- To set the countries that the users can select, use
177
-
178
- ```javascript
179
- const countries = [Fidel.Country.ireland, Fidel.Country.unitedStates];
180
- Fidel.setOptions({
181
- allowedCountries: countries
182
- });
183
- ```
184
-
185
- The possible options are: `.canada`, `.ireland`, `.japan`, `.sweden`, `.unitedArabEmirates`, `.unitedKingdom`, `.unitedStates`. You can set one or multiple of these countries. If you don't set any allowed countries, the user will be able to choose any of the countries above. If you set only one country, the card linking screen will not show the country picker UI. Note that, when you set multiple countries, they will be displayed in the country picker UI in the order that you set them.
186
-
187
- ### defaultSelectedCountry
188
-
189
- Use this parameter to set the country that will be selected by default when opening the card enrollment screen.
190
-
191
- ```javascript
192
- Fidel.setOptions({
193
- defaultSelectedCountry: Fidel.Country.unitedKingdom
194
- });
195
- ```
196
-
197
- The possible options are: `.canada`, `.ireland`, `.japan`, `.sweden`, `.unitedArabEmirates`, `.unitedKingdom`, `.unitedStates`. The `defaultSelectedCountry` has to be part of the `allowedCountries` list. The default value of this option is `.unitedKingdom`.
198
-
199
- ### supportedCardSchemes
200
-
201
- We currently support _Visa_, _Mastercard_ and _AmericanExpress_, but you can choose to support only one, two or all three. By default the SDK is configured to support all three.
202
-
203
- If you set this option to an empty array or to `null`, of course, you will not be able to open the Fidel UI. You must support at least one our supported card schemes.
204
-
205
- Please check the example below:
206
-
207
- ```javascript
208
- //this is the default value for supported card schemes,
209
- //but you can remove the support for some of the card schemes if you want to
210
- const cardSchemes = new Set([
211
- Fidel.CardScheme.visa,
212
- Fidel.CardScheme.mastercard,
213
- Fidel.CardScheme.americanExpress
214
- ]);
215
- Fidel.setOptions({
216
- supportedCardSchemes: Array.from(cardSchemes)
217
- });
218
- ```
219
-
220
- ### autoScan
221
-
222
- Set this property to `true`, if you want to open the card scanning UI immediately after executing `Fidel.openForm`. The default value is `false`.
223
-
224
- ```javascript
225
- Fidel.setOptions({
226
- autoScan: true
227
- });
228
- ```
229
-
230
- ### metaData
231
-
232
- Use this option to pass any other data with the card data:
233
-
234
- ```javascript
235
- Fidel.setOptions({
236
- metaData: {'meta-data-key-1': 'value1'}
237
- });
238
- ```
239
-
240
- ### companyName
241
-
242
- Set your company name as it will appear in our consent checkbox text. Please set it to a maximum of 60 characters.
243
-
244
- ```javascript
245
- Fidel.setOptions({
246
- companyName: 'Your Company Name'
247
- });
248
- ```
249
-
250
- ### deleteInstructions
251
-
252
- Write your custom opt-out instructions for your users. They will be displayed in the consent checkbox text as well.
253
-
254
- ```javascript
255
- Fidel.setOptions({
256
- deleteInstructions: 'Your custom card delete instructions!'
257
- });
258
- ```
259
-
260
- ### privacyUrl
261
-
262
- This is the privacy policy URL that you can set for the consent checkbox text.
263
-
264
- ```javascript
265
- Fidel.setOptions({
266
- privacyUrl: 'https://fidel.uk',
267
- });
268
- ```
269
-
270
- ### programName (applied to the consent text only for USA and Canada)
271
-
272
- Set your program name as it will appear in the consent text. Note that **this parameter is optional** and used when you set United States or Canada as allowed countries or don't set any allowed countries (meaning that the user is free to select United States or Canada as their country). Please set it to a maximum of 60 characters.
273
-
274
- ```javascript
275
- Fidel.setOptions({
276
- programName: 'Your Program Name'
277
- });
278
- ```
279
-
280
- ### termsConditionsUrl (applied to the consent text only for USA and Canada)
281
-
282
- This is the terms & conditions URL that you can set for the consent text. Note that **this parameter is mandatory** when you set United States or Canada as allowed countries or don't set any allowed countries (meaning that the user is free to select United States or Canada as their country).
283
-
284
- ```javascript
285
- Fidel.setOptions({
286
- termsConditionsUrl: 'https://fidel.uk',
287
- });
288
- ```
289
-
290
- ## Customizing the consent text
291
-
292
- In order to properly set the consent text, please follow these steps:
293
-
294
- 1. **Set the company name**
295
-
296
- This parameter is optional, but we recommended setting it. If you don't set a company name, we'll show the default value in the consent text: ```Your Company Name```
297
-
298
- 2. **Set the privacy policy URL**
299
-
300
- This is an optional parameter. It is added as a hyperlink to the ```privacy policy``` text. Please see the full behaviour below.
301
-
302
- 3. **Set the delete instructions**
303
-
304
- Optional parameter whose default value is ```going to your account settings```. This default value is applied for both consent texts - for the USA & Canada as well as for the rest of the world.
305
-
306
- 4. **Set the card scheme name**
307
-
308
- By default, we allow the user to input card numbers from either Visa, Mastercard or American Express, but you can control which card networks you accept. The consent text changes based on what you define or based on what the user inputs. Please see the full behaviour below.
309
-
310
- 5. **Set the program name (applied to the consent text only for USA and Canada)**
311
-
312
- This parameter is taken into account only for USA and Canada. The default value for program name is ```our```.
313
-
314
- 6. **Set the terms and conditions URL (applied to the consent text only for USA and Canada)**
315
-
316
- This parameter is mandatory for USA and Canada. Once set, it will be applied as a hyperlink on the ```Terms and Conditions``` text.
317
-
318
-
319
- Note that the consent text has a different form depending on the allowed countries you set or the country the user can select. Below you can find the specifics for each case.
320
-
321
- ### Consent text for United States and Canada
322
-
323
- When you set United States and/or Canada as allowed countries or don't set any countries (meaning that the user is free to select United States or Canada as their country), a different consent text will be applied.
324
-
325
- For USA & Canada, the following would be an example Terms & Conditions text for ```Cashback Inc``` (an example company) that uses ```Awesome Bonus``` as their program name:
326
-
327
- *By submitting your card information and checking this box, you authorize ```card_scheme_name``` to monitor and share transaction data with Fidel (our service provider) to participate in ```Awesome Bonus``` program. You also acknowledge and agree that Fidel may share certain details of your qualifying transactions with ```Cashback Inc``` to enable your participation in ```Awesome Bonus``` program and for other purposes in accordance with the ```Cashback Inc``` Terms and Conditions, ```Cashback Inc``` privacy policy and Fidel’s Privacy Policy. You may opt-out of transaction monitoring on the linked card at any time by ```deleteInstructions```.*
328
-
329
- There are two specific parameters that you can set for this consent text:
330
-
331
- #### 1. termsConditionsUrl
332
- This parameter is mandatory when you set United States and/or Canada as allowed countries or don't set any countries (meaning that the user is free to select United States or Canada as their country). When you set this parameter, the ```Terms and Conditions``` from the consent text will get a hyperlink with the URL you set.
333
-
334
- ```javascript
335
- Fidel.setOptions({
336
- termsConditionsUrl: 'https://fidel.uk',
337
- });
338
- ```
339
-
340
- If you don't set this parameter, you'll get an error when trying to open the card linking interface: ```You have included a North American country in the list of allowed countries or you allow the user to select a North American country. For North American countries it is mandatory for you to provide the Terms and Conditions URL.```
341
-
342
- #### 2. programName
343
- This parameter is optional when you set United States or Canada as allowed countries or don't set any allowed countries. If you don't set a program name, we'll use ```our``` as the default value (for example, in the text above, you would see *...to monitor and share transaction data with Fidel (our service provider) to participate in ```our``` program...*)
344
-
345
- ```javascript
346
- Fidel.setOptions({
347
- programName: 'Your Program Name',
348
- });
349
- ```
350
-
351
- #### Consent text behaviour for card scheme name
352
-
353
- If you don't set a card scheme (meaning the user can input either Visa, Mastercard or American Express cards) *OR* set 2 or 3 card scheme names, the default value used will be ```your payment card network``` (e.g. _you authorize ```your payment card network``` to monitor and share transaction data with Fidel (our service provider)_). When the user starts typing in a card number, ```your payment card network``` will be replaced with the scheme name of the card that they typed in (e.g. Visa).
354
-
355
- If you set one card scheme name, it will be displayed in the consent text (e.g. for Mastercard it would be _you authorize ```Mastercard``` to monitor and share transaction data with Fidel (our service provider)_) This value - ```Mastercard``` - will not change when the user starts typing in a card number.
356
-
357
- #### Consent text behaviour for privacy policy
358
-
359
- Notice the following excerpt from the consent text above: _in accordance with the ```Cashback Inc``` Terms and Conditions, ```Cashback Inc``` privacy policy and Fidel’s Privacy Policy_. If you set a ```privacyUrl```, this is the text that will be displayed, along with a hyperlink set on _privacy policy_.
360
- If you do not set a ```privacyUrl```, the text will become _in accordance with the ```Cashback Inc``` Terms and Conditions and Fidel’s Privacy Policy._
361
-
362
- ### Consent text for the rest of the world
363
-
364
- When you set Ireland, Japan , Sweden, United Arab Emirates or United Kingdom as allowed countries or the user selects one of these countries from the list, a consent text specific for these countries will be applied.
365
-
366
- The following would be an example Terms & Conditions text for ```Cashback Inc``` (an example company):
367
-
368
- *I authorise ```card_scheme_name``` to monitor my payment card to identify transactions that qualify for a reward and for ```card_scheme_name``` to share such information with ```Cashback Inc```, to enable my card linked offers and target offers that may be of interest to me. For information about ```Cashback Inc``` privacy practices, please see the privacy policy. You may opt-out of transaction monitoring on the payment card you entered at any time by ```deleteInstructions```.*
369
-
370
- #### Consent text behaviour for card scheme name
371
-
372
- If you don't set a card scheme (meaning the user can input either Visa, Mastercard or American Express cards) *OR* set 2 or 3 card scheme names, the default value used will be ```my card network``` (e.g. _I authorise ```my card network``` to monitor my payment card_). When the user starts typing in a card number, ```my card network``` will be replaced with the scheme name of the card that they typed in (e.g. Visa).
373
-
374
- If you set one card scheme name, it will be displayed in the consent text (e.g. for Mastercard it would be _I authorise ```Mastercard``` to monitor my payment card_) This value - ```Mastercard``` - will not change when the user starts typing in a card number.
375
-
376
- #### Consent text behaviour for privacy policy
377
-
378
- If you do not set a privacy policy URL, the privacy policy related phrase will be removed from the text.
379
-
380
- Notice the following excerpt from the consent text above: _...may be of interest to me. For information about ```Cashback Inc``` privacy practices, please see the privacy policy. You may opt-out of..._ If you set a ```privacyUrl```, this is the text that will be displayed, along with a hyperlink set on *privacy policy*.
381
-
382
- If you do not set a ```privacyUrl```, the text will become _...may be of interest to me. You may opt-out of..._
383
-
384
- ## Localisation
385
-
386
- The SDK's default language is English, but it's also localised for French and Swedish languages. When the device has either `Français (Canada)` or `Svenska (Sverige)` as its language, the appropriate texts will be displayed. Please note that developer error messages are in English only and they will not be displayed to the user.
387
-
388
- Please make sure that your project also supports localisation for the languages that you want to support.
389
-
390
- ## Test card numbers
391
-
392
- In the test environment please use our VISA, Mastercard or American Express test card numbers. You must use a test API Key for them to work.
393
-
394
- VISA: _4444000000004***_ (the last 3 numbers can be anything)
395
-
396
- Mastercard: _5555000000005***_ (the last 3 numbers can be anything)
397
-
398
- American Express: _3400000000003**_ or _3700000000003**_ (the last 2 numbers can be anything)
399
-
400
27
  ## Feedback
401
28
 
402
- The Fidel SDK is in active development, we welcome your feedback!
29
+ The Fidel API SDKs is in active development, so we welcome your feedback!
403
30
 
404
31
  Get in touch:
405
32
 
406
33
  GitHub Issues - For SDK issues and feedback
407
- Fidel Developers Forum - [https://community.fidel.uk](https://community.fidel.uk) - for personal support at any phase of integration
@@ -14,14 +14,14 @@ apply plugin: 'com.android.library'
14
14
  apply from: 'jacoco.gradle'
15
15
 
16
16
  android {
17
- compileSdkVersion 30
17
+ compileSdkVersion 33
18
18
  buildToolsVersion "30.0.3"
19
19
 
20
20
  defaultConfig {
21
21
  minSdkVersion 21
22
- targetSdkVersion 30
22
+ targetSdkVersion 32
23
23
  versionCode 1
24
- versionName "1.6.3"
24
+ versionName "2.0.0"
25
25
  }
26
26
  lintOptions {
27
27
  abortOnError false
@@ -35,15 +35,19 @@ android {
35
35
  }
36
36
 
37
37
  repositories {
38
- mavenCentral()
38
+ mavenCentral {
39
+ content {
40
+ excludeGroup("com.facebook.react")
41
+ }
42
+ }
39
43
  }
40
44
 
41
45
  dependencies {
42
46
  implementation 'com.facebook.react:react-native:+'
43
- implementation 'com.github.FidelLimited:android-sdk:1.7.5'
44
-
47
+ implementation 'com.github.FidelLimited:android-sdk:2.1.1'
48
+ implementation 'com.github.FidelLimited:kotlin-multiplatform-analytics:1.3.0'
45
49
  testImplementation 'junit:junit:4.13.2'
46
- testImplementation 'androidx.test.ext:junit:1.1.3'
50
+ testImplementation 'androidx.test.ext:junit:1.1.5'
47
51
  testImplementation 'org.assertj:assertj-core:3.13.2'
48
- testImplementation 'org.robolectric:robolectric:4.5.1'
52
+ testImplementation 'org.robolectric:robolectric:4.10'
49
53
  }
@@ -41,8 +41,8 @@ project.afterEvaluate {
41
41
  executionData.from = files("${buildDir}/jacoco/${testTaskName}.exec")
42
42
 
43
43
  reports {
44
- xml.enabled = true
45
- html.enabled = true
44
+ xml.required = true
45
+ html.required = true
46
46
  }
47
47
  }
48
48
  }
@@ -2,23 +2,26 @@
2
2
  package com.fidelreactlibrary;
3
3
 
4
4
  import android.app.Activity;
5
- import com.facebook.react.bridge.Callback;
5
+
6
+ import androidx.annotation.NonNull;
7
+
6
8
  import com.facebook.react.bridge.ReactApplicationContext;
7
9
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
10
  import com.facebook.react.bridge.ReactMethod;
9
11
  import com.facebook.react.bridge.ReadableMap;
10
- import com.facebook.react.bridge.WritableMap;
11
- import com.facebook.react.bridge.WritableNativeMap;
12
- import com.fidel.sdk.Fidel;
13
- import com.fidelreactlibrary.adapters.WritableMapDataConverter;
12
+ import com.fidelapi.Fidel;
13
+ import com.fidelapi.analytics.Analytics;
14
+ import com.fidelapi.analytics.domain.SdkDetails;
15
+ import com.fidelapi.entities.CardVerificationConfiguration;
16
+ import com.fidelapi.entities.abstraction.OnCardVerificationChoiceSelectedObserver;
17
+ import com.fidelapi.entities.abstraction.OnCardVerificationStartedObserver;
18
+ import com.fidelapi.entities.abstraction.OnResultObserver;
14
19
  import com.fidelreactlibrary.adapters.abstraction.ConstantsProvider;
15
20
  import com.fidelreactlibrary.adapters.abstraction.DataProcessor;
16
- import com.fidelreactlibrary.adapters.abstraction.ObjectFactory;
17
- import com.fidelreactlibrary.events.CallbackActivityEventListener;
18
- import com.fidelreactlibrary.events.CallbackInput;
19
- import com.fidel.sdk.data.abstraction.FidelCardLinkingObserver;
20
- import com.fidelreactlibrary.events.ErrorEventEmitter;
21
+ import com.fidelreactlibrary.adapters.abstraction.VerificationConfigurationAdapter;
22
+ import com.fidelreactlibrary.events.BridgeLibraryEvent;
21
23
 
24
+ import java.util.HashMap;
22
25
  import java.util.List;
23
26
  import java.util.Map;
24
27
 
@@ -26,25 +29,30 @@ import javax.annotation.Nullable;
26
29
 
27
30
  public class FidelModule extends ReactContextBaseJavaModule {
28
31
 
29
- private final CallbackInput callbackInput;
30
32
  private final DataProcessor<ReadableMap> setupProcessor;
31
- private final DataProcessor<ReadableMap> optionsProcessor;
33
+ private final OnCardVerificationChoiceSelectedObserver onCardVerificationChoiceSelectedObserver;
32
34
  private final List<ConstantsProvider> constantsProviderList;
33
- private final ReactApplicationContext reactContext;
35
+ private final OnResultObserver onResultObserver;
36
+ private final OnCardVerificationStartedObserver onCardVerificationStartedObserver;
37
+ private final VerificationConfigurationAdapter verificationAdapter;
34
38
 
35
39
  public FidelModule(ReactApplicationContext reactContext,
36
- DataProcessor<ReadableMap> setupProcessor,
37
- DataProcessor<ReadableMap> optionsProcessor,
38
- List<ConstantsProvider> constantsProviderList,
39
- CallbackInput callbackInput) {
40
+ DataProcessor<ReadableMap> setupProcessor,
41
+ OnResultObserver onResultObserver,
42
+ OnCardVerificationStartedObserver onCardVerificationStartedObserver,
43
+ OnCardVerificationChoiceSelectedObserver onCardVerificationChoiceSelectedObserver,
44
+ List<ConstantsProvider> constantsProviderList,
45
+ VerificationConfigurationAdapter verificationAdapter) {
40
46
  super(reactContext);
41
47
  this.setupProcessor = setupProcessor;
42
- this.optionsProcessor = optionsProcessor;
43
- this.callbackInput = callbackInput;
48
+ this.onCardVerificationChoiceSelectedObserver = onCardVerificationChoiceSelectedObserver;
44
49
  this.constantsProviderList = constantsProviderList;
45
- this.reactContext = reactContext;
50
+ this.onResultObserver = onResultObserver;
51
+ this.onCardVerificationStartedObserver = onCardVerificationStartedObserver;
52
+ this.verificationAdapter = verificationAdapter;
46
53
  }
47
54
 
55
+ @NonNull
48
56
  @Override
49
57
  public String getName() {
50
58
  return "NativeFidelBridge";
@@ -52,51 +60,60 @@ public class FidelModule extends ReactContextBaseJavaModule {
52
60
 
53
61
  @ReactMethod
54
62
  public void addListener(String eventName) {
55
- // Keep: Required for RN built in Event Emitter Calls.
63
+ if (eventName.equals(BridgeLibraryEvent.RESULT_AVAILABLE.getEventName())) {
64
+ Fidel.onResult = onResultObserver;
65
+ } else if (eventName.equals(BridgeLibraryEvent.CARD_VERIFICATION_STARTED.getEventName())) {
66
+ Fidel.onCardVerificationStarted = onCardVerificationStartedObserver;
67
+ } else if (eventName.equals(BridgeLibraryEvent.CARD_VERIFICATION_CHOICE.getEventName())) {
68
+ Fidel.onCardVerificationChoiceSelected = onCardVerificationChoiceSelectedObserver;
69
+ }
56
70
  }
57
71
 
58
72
  @ReactMethod
59
73
  public void removeListeners(Integer count) {
60
- // Keep: Required for RN built in Event Emitter Calls.
74
+ Fidel.onResult = null;
61
75
  }
62
76
 
63
77
  @ReactMethod
64
- public void openForm(Callback callback) {
78
+ public void start() {
65
79
  final Activity activity = getCurrentActivity();
66
- final FidelCardLinkingObserver cardLinkingObserver = getCardLinkingObserver();
67
80
  if (activity != null) {
68
- Fidel.setCardLinkingObserver(cardLinkingObserver);
69
- Fidel.present(activity);
81
+ Fidel.start(activity);
70
82
  }
71
- callbackInput.callbackIsReady(callback);
72
83
  }
73
84
 
74
85
  @ReactMethod
75
86
  public void setup(ReadableMap map) {
76
87
  setupProcessor.process(map);
88
+ final Activity activity = getCurrentActivity();
89
+ if (activity != null) {
90
+ Fidel.onMainActivityCreate(activity);
91
+ }
77
92
  }
78
93
 
79
94
  @ReactMethod
80
- public void setOptions(ReadableMap map) {
81
- optionsProcessor.process(map);
95
+ public void verifyCard(ReadableMap data) {
96
+ final Activity activity = getCurrentActivity();
97
+ if (activity != null) {
98
+ CardVerificationConfiguration cardVerificationConfig = verificationAdapter.adapt(data);
99
+ Fidel.verifyCard(activity, cardVerificationConfig);
100
+ }
82
101
  }
83
102
 
103
+ @ReactMethod
104
+ public void identifyMetricsDataSource(String name, String version) {
105
+ SdkDetails reactNativeSdkDetails = new SdkDetails(name, version);
106
+ Analytics analytics = new Analytics();
107
+ analytics.identifyMultiplatformDataSource(reactNativeSdkDetails);
108
+ }
109
+
84
110
  @Nullable
85
111
  @Override
86
112
  public Map<String, Object> getConstants() {
87
- return constantsProviderList.get(0).getConstants();
88
- }
89
-
90
- private CallbackActivityEventListener getCardLinkingObserver() {
91
- WritableMapDataConverter linkResultConverter =
92
- new WritableMapDataConverter(new ObjectFactory<WritableMap>() {
93
- @Override
94
- public WritableMap create() {
95
- return new WritableNativeMap();
96
- }
97
- });
98
- ErrorEventEmitter errorEventEmitter =
99
- new ErrorEventEmitter(reactContext);
100
- return new CallbackActivityEventListener(linkResultConverter, errorEventEmitter);
113
+ Map<String, Object> constants = new HashMap<>();
114
+ for (ConstantsProvider provider : constantsProviderList) {
115
+ constants.putAll(provider.getConstants());
116
+ }
117
+ return constants;
101
118
  }
102
- }
119
+ }