judokit-react-native 3.3.9 → 3.4.2
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/JudoPay.tsx +13 -3
- package/RNJudopay.podspec +1 -1
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/reactlibrary/Extensions.kt +198 -34
- package/android/src/main/java/com/reactlibrary/Helpers.kt +97 -56
- package/android/src/main/java/com/reactlibrary/JudoReactNativeModule.kt +55 -77
- package/ios/Classes/RNJudo.m +33 -47
- package/ios/Classes/Wrappers/RNWrappers.h +10 -0
- package/ios/Classes/Wrappers/RNWrappers.m +115 -39
- package/ios/Podfile +2 -2
- package/ios/Podfile.lock +16 -8
- package/ios/RNJudo.xcodeproj/project.pbxproj +73 -92
- package/ios/RNJudo.xcodeproj/xcshareddata/xcschemes/RNJudo.xcscheme +1 -1
- package/package.json +1 -1
- package/types/JudoTypes.tsx +29 -0
|
@@ -15,9 +15,9 @@ import com.judopay.judokit.android.api.model.response.Receipt
|
|
|
15
15
|
import com.judopay.judokit.android.api.model.response.toCardVerificationModel
|
|
16
16
|
import com.judopay.judokit.android.api.model.response.toJudoPaymentResult
|
|
17
17
|
import com.judopay.judokit.android.api.model.response.toJudoResult
|
|
18
|
-
import com.judopay.judokit.android.model
|
|
19
|
-
import com.judopay.judokit.android.
|
|
20
|
-
import com.judopay.judokit.android.
|
|
18
|
+
import com.judopay.judokit.android.model.*
|
|
19
|
+
import com.judopay.judokit.android.service.CardTransactionManager
|
|
20
|
+
import com.judopay.judokit.android.service.CardTransactionManagerResultListener
|
|
21
21
|
import com.judopay.judokit.android.toTokenRequest
|
|
22
22
|
import com.judopay.judokit.android.ui.cardverification.THREE_DS_ONE_DIALOG_FRAGMENT_TAG
|
|
23
23
|
import com.judopay.judokit.android.ui.cardverification.ThreeDSOneCardVerificationDialogFragment
|
|
@@ -33,9 +33,10 @@ const val JUDO_PAYMENT_WIDGET_REQUEST_CODE = 65520
|
|
|
33
33
|
const val JUDO_PROMISE_REJECTION_CODE = "JUDO_ERROR"
|
|
34
34
|
|
|
35
35
|
class JudoReactNativeModule internal constructor(val context: ReactApplicationContext) :
|
|
36
|
-
ReactContextBaseJavaModule(context) {
|
|
36
|
+
ReactContextBaseJavaModule(context), CardTransactionManagerResultListener {
|
|
37
37
|
|
|
38
38
|
private val listener = JudoReactNativeActivityEventListener()
|
|
39
|
+
internal var transactionPromise: Promise? = null
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* A broadcast receiver to catch Pay by Bank app /order/bank/sale response event.
|
|
@@ -106,62 +107,75 @@ class JudoReactNativeModule internal constructor(val context: ReactApplicationCo
|
|
|
106
107
|
@ReactMethod
|
|
107
108
|
fun performTokenTransaction(options: ReadableMap, promise: Promise) {
|
|
108
109
|
try {
|
|
110
|
+
val activity = context.currentActivity as FragmentActivity
|
|
111
|
+
val manager = CardTransactionManager.getInstance(activity)
|
|
109
112
|
|
|
110
113
|
val judo = getTokenTransactionConfiguration(options)
|
|
111
114
|
|
|
112
|
-
val service = JudoApiServiceFactory.createApiService(context, judo)
|
|
113
|
-
|
|
114
115
|
val cardToken = options.cardToken
|
|
115
|
-
val securityCode = options.securityCode
|
|
116
116
|
|
|
117
117
|
if (cardToken == null) {
|
|
118
118
|
promise.reject(JUDO_PROMISE_REJECTION_CODE, "No card token found")
|
|
119
119
|
return
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
val
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
handleThreeDSAuthentication(promise, service, receipt)
|
|
140
|
-
} else {
|
|
141
|
-
promise.resolve(getMappedResult(receipt?.toJudoResult()))
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
is JudoPaymentResult.Error -> {
|
|
145
|
-
promise.reject(JUDO_PROMISE_REJECTION_CODE, data.error.message)
|
|
146
|
-
}
|
|
147
|
-
else -> {
|
|
148
|
-
// noop
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
122
|
+
val details = TransactionDetails.Builder()
|
|
123
|
+
.setCardHolderName(options.cardholderName)
|
|
124
|
+
.setSecurityNumber(options.securityCode)
|
|
125
|
+
.setCardType(options.cardType)
|
|
126
|
+
.setCardToken(cardToken)
|
|
127
|
+
.setEmail(judo.emailAddress)
|
|
128
|
+
.setCountryCode(judo.address?.countryCode.toString())
|
|
129
|
+
.setPhoneCountryCode(judo.phoneCountryCode)
|
|
130
|
+
.setMobileNumber(judo.mobileNumber)
|
|
131
|
+
.setAddressLine1(judo.address?.line1)
|
|
132
|
+
.setAddressLine2(judo.address?.line2)
|
|
133
|
+
.setAddressLine3(judo.address?.line3)
|
|
134
|
+
.setCity(judo.address?.town)
|
|
135
|
+
.setPostalCode(judo.address?.postCode)
|
|
136
|
+
.build()
|
|
137
|
+
|
|
138
|
+
transactionPromise = promise
|
|
153
139
|
|
|
154
140
|
when (judo.paymentWidgetType) {
|
|
155
|
-
PaymentWidgetType.CARD_PAYMENT ->
|
|
156
|
-
PaymentWidgetType.PRE_AUTH ->
|
|
141
|
+
PaymentWidgetType.CARD_PAYMENT -> manager.paymentWithToken(details, JudoReactNativeModule::class.java.name)
|
|
142
|
+
PaymentWidgetType.PRE_AUTH -> manager.preAuthWithToken(details, JudoReactNativeModule::class.java.name)
|
|
157
143
|
else -> promise.reject(JUDO_PROMISE_REJECTION_CODE, "${judo.paymentWidgetType.name} payment widget type is not valid for token transactions")
|
|
158
144
|
}
|
|
159
|
-
|
|
160
145
|
} catch (exception: Exception) {
|
|
161
146
|
promise.reject(exception)
|
|
162
147
|
}
|
|
163
148
|
}
|
|
164
149
|
|
|
150
|
+
override fun initialize() {
|
|
151
|
+
super.initialize()
|
|
152
|
+
|
|
153
|
+
val activity = context.currentActivity as FragmentActivity
|
|
154
|
+
CardTransactionManager.getInstance(activity).registerResultListener(this)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
override fun invalidate() {
|
|
158
|
+
super.invalidate()
|
|
159
|
+
|
|
160
|
+
val activity = context.currentActivity as FragmentActivity
|
|
161
|
+
CardTransactionManager.getInstance(activity).unRegisterResultListener(this)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
override fun onCardTransactionResult(result: JudoPaymentResult) {
|
|
165
|
+
transactionPromise?.let {
|
|
166
|
+
if (result is JudoPaymentResult.Success) {
|
|
167
|
+
it.resolve(getMappedResult(result.result))
|
|
168
|
+
} else {
|
|
169
|
+
val message = when (result) {
|
|
170
|
+
is JudoPaymentResult.Error -> result.error.message
|
|
171
|
+
is JudoPaymentResult.UserCancelled -> result.error.message
|
|
172
|
+
else -> "The transaction was unsuccessful"
|
|
173
|
+
}
|
|
174
|
+
it.reject(JUDO_PROMISE_REJECTION_CODE, message)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
165
179
|
@ReactMethod
|
|
166
180
|
fun isBankingAppAvailable(promise: Promise) {
|
|
167
181
|
try {
|
|
@@ -176,40 +190,4 @@ class JudoReactNativeModule internal constructor(val context: ReactApplicationCo
|
|
|
176
190
|
val intent = configuration.toJudoActivityIntent(it)
|
|
177
191
|
it.startActivityForResult(intent, JUDO_PAYMENT_WIDGET_REQUEST_CODE)
|
|
178
192
|
}
|
|
179
|
-
|
|
180
|
-
private fun handleThreeDSAuthentication(promise: Promise, service: JudoApiService, receipt: Receipt) {
|
|
181
|
-
val callback = object : ThreeDSOneCompletionCallback {
|
|
182
|
-
override fun onSuccess(success: JudoPaymentResult) {
|
|
183
|
-
handleSuccessfulThreeDSTransaction(success, promise)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
override fun onFailure(error: JudoPaymentResult) {
|
|
187
|
-
handleFailedThreeDSTransaction(error, promise)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
val fragment = ThreeDSOneCardVerificationDialogFragment(
|
|
192
|
-
service,
|
|
193
|
-
receipt.toCardVerificationModel(),
|
|
194
|
-
callback
|
|
195
|
-
)
|
|
196
|
-
fragment.show((context.currentActivity as FragmentActivity).supportFragmentManager, THREE_DS_ONE_DIALOG_FRAGMENT_TAG)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private fun handleFailedThreeDSTransaction(error: JudoPaymentResult, promise: Promise) {
|
|
200
|
-
val message = when (error) {
|
|
201
|
-
is JudoPaymentResult.Error -> error.error.message
|
|
202
|
-
is JudoPaymentResult.UserCancelled -> error.error.message
|
|
203
|
-
else -> "The transaction was unsuccessful"
|
|
204
|
-
}
|
|
205
|
-
promise.reject(JUDO_PROMISE_REJECTION_CODE, message)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
private fun handleSuccessfulThreeDSTransaction(success: JudoPaymentResult, promise: Promise) {
|
|
209
|
-
if (success is JudoPaymentResult.Success) {
|
|
210
|
-
promise.resolve(getMappedResult(success.result))
|
|
211
|
-
} else {
|
|
212
|
-
promise.reject(JUDO_PROMISE_REJECTION_CODE, "Unknown error occured")
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
193
|
}
|
package/ios/Classes/RNJudo.m
CHANGED
|
@@ -42,7 +42,7 @@ typedef NS_ENUM(NSUInteger, JudoSDKInvocationType) {
|
|
|
42
42
|
|
|
43
43
|
@property (nonatomic, strong) JudoKit *judoKit;
|
|
44
44
|
@property (nonatomic, strong) JPApiService *apiService;
|
|
45
|
-
@property (nonatomic, strong)
|
|
45
|
+
@property (nonatomic, strong) JPCardTransactionService *transactionService;
|
|
46
46
|
@property (nonatomic, strong) JPCompletionBlock completionBlock;
|
|
47
47
|
|
|
48
48
|
@end
|
|
@@ -104,31 +104,24 @@ RCT_REMAP_METHOD(performTokenTransaction,
|
|
|
104
104
|
performTokenTransactionWithResolver:(RCTPromiseResolveBlock)resolve
|
|
105
105
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
106
106
|
|
|
107
|
-
self.
|
|
108
|
-
self.threeDSService = [[JP3DSService alloc] initWithApiService:self.apiService];
|
|
107
|
+
self.transactionService = [RNWrappers cardTransactionServiceFromProperties:properties];
|
|
109
108
|
self.completionBlock = [self completionBlockWithResolve:resolve andReject:reject];
|
|
110
109
|
|
|
111
110
|
JPTransactionMode transactionMode = [RNWrappers transactionModeFromProperties:properties];
|
|
112
111
|
JPConfiguration *configuration = [RNWrappers configurationFromProperties:properties];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
|
|
113
|
+
JPCardTransactionDetails *details = [[JPCardTransactionDetails new] initWithConfiguration:configuration];
|
|
114
|
+
details.cardToken = [RNWrappers cardTokenFromProperties:properties];
|
|
115
|
+
details.secureCode = [RNWrappers securityCodeFromProperties:properties];
|
|
116
|
+
details.cardholderName = [RNWrappers cardholderNameFromProperties:properties];
|
|
117
|
+
details.cardType = [RNWrappers cardTypeFromProperties:properties];
|
|
118
|
+
|
|
120
119
|
if (transactionMode == JPTransactionModePreAuth) {
|
|
121
|
-
[self.
|
|
122
|
-
andCompletion:^(JPResponse *response, JPError *error) {
|
|
123
|
-
[weakSelf handleResponse:response andError:error];
|
|
124
|
-
}];
|
|
120
|
+
[self.transactionService invokePreAuthTokenPaymentWithDetails:details andCompletion:self.completionBlock];
|
|
125
121
|
return;
|
|
126
122
|
}
|
|
127
123
|
|
|
128
|
-
[self.
|
|
129
|
-
andCompletion:^(JPResponse *response, JPError *error) {
|
|
130
|
-
[weakSelf handleResponse:response andError:error];
|
|
131
|
-
}];
|
|
124
|
+
[self.transactionService invokeTokenPaymentWithDetails:details andCompletion:self.completionBlock];
|
|
132
125
|
}
|
|
133
126
|
|
|
134
127
|
RCT_REMAP_METHOD(fetchTransactionDetails,
|
|
@@ -191,46 +184,27 @@ RCT_REMAP_METHOD(fetchTransactionDetails,
|
|
|
191
184
|
NSError *error = [[NSError alloc] initWithDomain:RNJudoErrorDomain
|
|
192
185
|
code:0
|
|
193
186
|
userInfo:exception.userInfo];
|
|
194
|
-
|
|
195
187
|
reject(kJudoPromiseRejectionCode, exception.reason, error);
|
|
196
188
|
}
|
|
197
189
|
}
|
|
198
190
|
|
|
199
|
-
- (void)handleResponse:(JPResponse *)response andError:(JPError *)error {
|
|
200
|
-
|
|
201
|
-
if (error.code != Judo3DSRequestError) {
|
|
202
|
-
self.completionBlock(response, error);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
JP3DSConfiguration *configuration = [JP3DSConfiguration configurationWithError:error];
|
|
207
|
-
[self.threeDSService invoke3DSecureWithConfiguration:configuration completion:self.completionBlock];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
//----------------------------------------------
|
|
211
|
-
// MARK: - React Native methods
|
|
212
|
-
//----------------------------------------------
|
|
213
|
-
|
|
214
|
-
- (dispatch_queue_t)methodQueue {
|
|
215
|
-
return dispatch_get_main_queue();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
219
|
-
return YES;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
191
|
- (JPCompletionBlock)completionBlockWithResolve:(RCTPromiseResolveBlock)resolve
|
|
223
192
|
andReject:(RCTPromiseRejectBlock)reject {
|
|
224
|
-
|
|
225
193
|
return ^(JPResponse *response, NSError *error) {
|
|
226
194
|
if (error) {
|
|
227
|
-
|
|
228
|
-
if (error.code == JPError.judoUserDidCancelError.code) {
|
|
195
|
+
if (error.code == JPError.userDidCancelError.code) {
|
|
229
196
|
reject(kJudoPromiseRejectionCode, @"Transaction cancelled", error);
|
|
230
197
|
return;
|
|
231
198
|
}
|
|
232
|
-
|
|
233
|
-
|
|
199
|
+
|
|
200
|
+
NSString *description = error.userInfo[NSLocalizedDescriptionKey];
|
|
201
|
+
NSString *message = @"Transaction failed";
|
|
202
|
+
|
|
203
|
+
if (description && description.length > 0) {
|
|
204
|
+
message = description;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
reject(kJudoPromiseRejectionCode, message, error);
|
|
234
208
|
} else {
|
|
235
209
|
NSDictionary *mappedResponse = [RNWrappers dictionaryFromResponse:response];
|
|
236
210
|
resolve(mappedResponse);
|
|
@@ -238,4 +212,16 @@ RCT_REMAP_METHOD(fetchTransactionDetails,
|
|
|
238
212
|
};
|
|
239
213
|
}
|
|
240
214
|
|
|
215
|
+
//----------------------------------------------
|
|
216
|
+
// MARK: - React Native methods
|
|
217
|
+
//----------------------------------------------
|
|
218
|
+
|
|
219
|
+
- (dispatch_queue_t)methodQueue {
|
|
220
|
+
return dispatch_get_main_queue();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
224
|
+
return YES;
|
|
225
|
+
}
|
|
226
|
+
|
|
241
227
|
@end
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
*/
|
|
47
47
|
+ (JPApiService *)apiServiceFromProperties:(NSDictionary *)properties;
|
|
48
48
|
|
|
49
|
+
+ (JPCardTransactionService *)cardTransactionServiceFromProperties:(NSDictionary *)properties;
|
|
50
|
+
|
|
51
|
+
+ (id<JPAuthorization>)authorizationFromProperties:(NSDictionary *)properties;
|
|
52
|
+
|
|
49
53
|
/**
|
|
50
54
|
* A method that returns the correct TransactionType value based on the passed dictionary parameters
|
|
51
55
|
* TransactionType is set to switch between Payment, PreAuth, Register Card, Check Card and Save Card transactions
|
|
@@ -96,6 +100,12 @@
|
|
|
96
100
|
*/
|
|
97
101
|
+ (NSString *)cardTokenFromProperties:(NSDictionary *)properties;
|
|
98
102
|
|
|
103
|
+
+ (NSString *)securityCodeFromProperties:(NSDictionary *)properties;
|
|
104
|
+
|
|
105
|
+
+ (NSString *)cardholderNameFromProperties:(NSDictionary *)properties;
|
|
106
|
+
|
|
107
|
+
+ (JPCardNetworkType)cardTypeFromProperties:(NSDictionary *)properties;
|
|
108
|
+
|
|
99
109
|
/**
|
|
100
110
|
* A method that returns the receipt ID contained in the properties dictionary
|
|
101
111
|
*
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
#import "NSDictionary+JudoConvert.h"
|
|
30
30
|
#import "UIColor+RNAdditions.h"
|
|
31
31
|
|
|
32
|
+
static NSString *const kCardSchemeVISA = @"visa";
|
|
33
|
+
static NSString *const kCardSchemeMasterCard = @"mastercard";
|
|
34
|
+
static NSString *const kCardSchemeAMEX = @"amex";
|
|
35
|
+
|
|
32
36
|
@implementation RNWrappers
|
|
33
37
|
|
|
34
38
|
//---------------------------------------------------
|
|
@@ -36,50 +40,46 @@
|
|
|
36
40
|
//---------------------------------------------------
|
|
37
41
|
|
|
38
42
|
+ (JudoKit *)judoSessionFromProperties:(NSDictionary *)properties {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
NSString *token = [authorizationDict stringForKey:@"token"];
|
|
43
|
-
NSString *secret = [authorizationDict optionalStringForKey:@"secret"];
|
|
44
|
-
NSString *paymentSession = [authorizationDict optionalStringForKey:@"paymentSession"];
|
|
45
|
-
|
|
46
|
-
JudoKit *judoKit;
|
|
47
|
-
|
|
48
|
-
if (secret) {
|
|
49
|
-
JPBasicAuthorization *authorization = [JPBasicAuthorization authorizationWithToken:token
|
|
50
|
-
andSecret:secret];
|
|
51
|
-
judoKit = [[JudoKit alloc] initWithAuthorization:authorization];
|
|
52
|
-
} else {
|
|
53
|
-
JPSessionAuthorization *authorization = [JPSessionAuthorization authorizationWithToken:token
|
|
54
|
-
andPaymentSession:paymentSession];
|
|
55
|
-
judoKit = [[JudoKit alloc] initWithAuthorization:authorization];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
NSNumber *isSandboxed = [properties boolForKey:@"sandboxed"];
|
|
59
|
-
judoKit.isSandboxed = isSandboxed.boolValue;
|
|
60
|
-
|
|
43
|
+
id<JPAuthorization> authorization = [RNWrappers authorizationFromProperties:properties];
|
|
44
|
+
JudoKit *judoKit = [[JudoKit alloc] initWithAuthorization:authorization];
|
|
45
|
+
judoKit.isSandboxed = [RNWrappers isSandboxedFromProperties:properties];
|
|
61
46
|
return judoKit;
|
|
62
47
|
}
|
|
63
48
|
|
|
64
49
|
+ (JPApiService *)apiServiceFromProperties:(NSDictionary *)properties {
|
|
50
|
+
BOOL isSandboxed = [RNWrappers isSandboxedFromProperties:properties];
|
|
51
|
+
id<JPAuthorization> authorization = [RNWrappers authorizationFromProperties:properties];
|
|
52
|
+
|
|
53
|
+
return [[JPApiService alloc] initWithAuthorization:authorization isSandboxed:isSandboxed];
|
|
54
|
+
}
|
|
65
55
|
|
|
56
|
+
+ (id<JPAuthorization>)authorizationFromProperties:(NSDictionary *)properties {
|
|
66
57
|
NSDictionary *authorizationDict = [properties dictionaryForKey:@"authorization"];
|
|
67
58
|
|
|
68
59
|
NSString *token = [authorizationDict stringForKey:@"token"];
|
|
69
60
|
NSString *secret = [authorizationDict optionalStringForKey:@"secret"];
|
|
70
61
|
NSString *paymentSession = [authorizationDict optionalStringForKey:@"paymentSession"];
|
|
62
|
+
|
|
63
|
+
if (secret) {
|
|
64
|
+
return [JPBasicAuthorization authorizationWithToken:token andSecret:secret];
|
|
65
|
+
}
|
|
71
66
|
|
|
67
|
+
return [JPSessionAuthorization authorizationWithToken:token andPaymentSession:paymentSession];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
+ (BOOL)isSandboxedFromProperties:(NSDictionary *)properties {
|
|
72
71
|
NSNumber *isSandboxed = [properties boolForKey:@"sandboxed"];
|
|
72
|
+
return isSandboxed.boolValue;
|
|
73
|
+
}
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
75
|
+
+ (JPCardTransactionService *)cardTransactionServiceFromProperties:(NSDictionary *)properties {
|
|
76
|
+
BOOL isSandboxed = [RNWrappers isSandboxedFromProperties:properties];
|
|
77
|
+
id<JPAuthorization> authorization = [RNWrappers authorizationFromProperties:properties];
|
|
78
|
+
JPConfiguration *configuration = [RNWrappers configurationFromProperties:properties];
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
return [[JPCardTransactionService alloc] initWithAuthorization:authorization
|
|
81
|
+
isSandboxed:isSandboxed
|
|
82
|
+
andConfiguration:configuration];
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
+ (JPTransactionType)transactionTypeFromProperties:(NSDictionary *)properties {
|
|
@@ -107,6 +107,22 @@
|
|
|
107
107
|
return availableModes[intType].intValue;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
+ (JPNetworkTimeout *)networkTimeoutFromProperties:(NSDictionary *)properties {
|
|
111
|
+
NSDictionary *networkTimeout = [properties optionalDictionaryForKey:@"networkTimeout"];
|
|
112
|
+
|
|
113
|
+
if (!networkTimeout) {
|
|
114
|
+
return nil;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
NSTimeInterval connectTimeout = [networkTimeout numberForKey:@"connectTimeout"].doubleValue;
|
|
118
|
+
NSTimeInterval readTimeout = [networkTimeout numberForKey:@"readTimeout"].doubleValue;
|
|
119
|
+
NSTimeInterval writeTimeout = [networkTimeout numberForKey:@"writeTimeout"].doubleValue;
|
|
120
|
+
|
|
121
|
+
return [[JPNetworkTimeout alloc] initWithConnectTimeout:connectTimeout
|
|
122
|
+
andReadTimeout:readTimeout
|
|
123
|
+
andWriteTimeout:writeTimeout];
|
|
124
|
+
}
|
|
125
|
+
|
|
110
126
|
+ (JPConfiguration *)configurationFromProperties:(NSDictionary *)properties {
|
|
111
127
|
|
|
112
128
|
NSDictionary *configurationDict = [properties dictionaryForKey:@"configuration"];
|
|
@@ -129,7 +145,36 @@
|
|
|
129
145
|
configuration.paymentMethods = [RNWrappers paymentMethodsFromConfiguration:configurationDict];
|
|
130
146
|
configuration.applePayConfiguration = [RNApplePayWrappers applePayConfigurationFromConfiguration:configurationDict];
|
|
131
147
|
configuration.pbbaConfiguration = [RNPBBAWrappers pbbaConfigurationFromConfiguration:configurationDict];
|
|
148
|
+
configuration.networkTimeout = [RNWrappers networkTimeoutFromProperties:configurationDict];
|
|
149
|
+
|
|
150
|
+
NSString *scaExemption = [configurationDict optionalStringForKey:@"scaExemption"];
|
|
151
|
+
NSString *challengeRequestIndicator = [configurationDict optionalStringForKey:@"challengeRequestIndicator"];
|
|
152
|
+
NSString *mobileNumber = [configurationDict optionalStringForKey:@"mobileNumber"];
|
|
153
|
+
NSString *emailAddress = [configurationDict optionalStringForKey:@"emailAddress"];
|
|
154
|
+
NSString *threeDSTwoMessageVersion = [configurationDict optionalStringForKey:@"threeDSTwoMessageVersion"];
|
|
155
|
+
NSNumber *threeDSTwoMaxTimeout = [configurationDict optionalNumberForKey:@"threeDSTwoMaxTimeout"];
|
|
156
|
+
NSString *phoneCountryCode = [configurationDict optionalStringForKey:@"phoneCountryCode"];
|
|
157
|
+
|
|
158
|
+
configuration.mobileNumber = mobileNumber;
|
|
159
|
+
configuration.emailAddress = emailAddress;
|
|
160
|
+
configuration.phoneCountryCode = phoneCountryCode;
|
|
161
|
+
|
|
162
|
+
if (scaExemption) {
|
|
163
|
+
configuration.scaExemption = scaExemption;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (challengeRequestIndicator) {
|
|
167
|
+
configuration.challengeRequestIndicator = challengeRequestIndicator;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (threeDSTwoMessageVersion) {
|
|
171
|
+
configuration.threeDSTwoMessageVersion = threeDSTwoMessageVersion;
|
|
172
|
+
}
|
|
132
173
|
|
|
174
|
+
if (threeDSTwoMaxTimeout) {
|
|
175
|
+
configuration.threeDSTwoMaxTimeout = threeDSTwoMaxTimeout.intValue;
|
|
176
|
+
}
|
|
177
|
+
|
|
133
178
|
return configuration;
|
|
134
179
|
}
|
|
135
180
|
|
|
@@ -186,10 +231,36 @@
|
|
|
186
231
|
return [properties optionalStringForKey:@"cardToken"];
|
|
187
232
|
}
|
|
188
233
|
|
|
234
|
+
+ (NSString *)securityCodeFromProperties:(NSDictionary *)properties {
|
|
235
|
+
return [properties optionalStringForKey:@"securityCode"];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
+ (NSString *)cardholderNameFromProperties:(NSDictionary *)properties {
|
|
239
|
+
return [properties optionalStringForKey:@"cardholderName"];
|
|
240
|
+
}
|
|
241
|
+
|
|
189
242
|
+ (NSString *)receiptIdFromProperties:(NSDictionary *)properties {
|
|
190
243
|
return [properties optionalStringForKey:@"receiptId"];
|
|
191
244
|
}
|
|
192
245
|
|
|
246
|
+
+ (JPCardNetworkType)cardTypeFromProperties:(NSDictionary *)properties {
|
|
247
|
+
NSString *cardScheme = [properties optionalStringForKey:@"cardScheme"].lowercaseString;
|
|
248
|
+
|
|
249
|
+
if ([kCardSchemeVISA isEqualToString:cardScheme]) {
|
|
250
|
+
return JPCardNetworkTypeVisa;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if ([kCardSchemeMasterCard isEqualToString:cardScheme]) {
|
|
254
|
+
return JPCardNetworkTypeMasterCard;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if ([kCardSchemeAMEX isEqualToString:cardScheme]) {
|
|
258
|
+
return JPCardNetworkTypeAMEX;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return JPCardNetworkTypeUnknown;
|
|
262
|
+
}
|
|
263
|
+
|
|
193
264
|
//---------------------------------------------------
|
|
194
265
|
// MARK: - Helper methods
|
|
195
266
|
//---------------------------------------------------
|
|
@@ -251,13 +322,13 @@
|
|
|
251
322
|
if (!addressDictionary) {
|
|
252
323
|
return nil;
|
|
253
324
|
}
|
|
254
|
-
|
|
255
|
-
return [[JPAddress alloc]
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
325
|
+
|
|
326
|
+
return [[JPAddress alloc] initWithAddress1:[addressDictionary optionalStringForKey:@"line1"]
|
|
327
|
+
address2:[addressDictionary optionalStringForKey:@"line2"]
|
|
328
|
+
address3:[addressDictionary optionalStringForKey:@"line3"]
|
|
329
|
+
town:[addressDictionary optionalStringForKey:@"town"]
|
|
330
|
+
postCode:[addressDictionary optionalStringForKey:@"postCode"]
|
|
331
|
+
countryCode:[addressDictionary optionalNumberForKey:@"countryCode"]];
|
|
261
332
|
}
|
|
262
333
|
|
|
263
334
|
+ (JPUIConfiguration *)uiConfigurationFromConfiguration:(NSDictionary *)configuration {
|
|
@@ -274,12 +345,17 @@
|
|
|
274
345
|
NSNumber *shouldDisplayAmount = [dictionary boolForKey:@"shouldPaymentMethodsDisplayAmount"];
|
|
275
346
|
NSNumber *isPayButtonAmountVisible = [dictionary boolForKey:@"shouldPaymentButtonDisplayAmount"];
|
|
276
347
|
NSNumber *isSecureCodeCheckEnabled = [dictionary boolForKey:@"shouldPaymentMethodsVerifySecurityCode"];
|
|
277
|
-
|
|
348
|
+
NSNumber *shouldAskForBillingInformation = [dictionary optionalBoolForKey:@"shouldAskForBillingInformation"];
|
|
349
|
+
|
|
278
350
|
uiConfiguration.isAVSEnabled = isAVSEnabled.boolValue;
|
|
279
351
|
uiConfiguration.shouldPaymentMethodsDisplayAmount = shouldDisplayAmount.boolValue;
|
|
280
352
|
uiConfiguration.shouldPaymentButtonDisplayAmount = isPayButtonAmountVisible.boolValue;
|
|
281
353
|
uiConfiguration.shouldPaymentMethodsVerifySecurityCode = isSecureCodeCheckEnabled.boolValue;
|
|
282
|
-
|
|
354
|
+
|
|
355
|
+
if (shouldAskForBillingInformation) {
|
|
356
|
+
uiConfiguration.shouldAskForBillingInformation = shouldAskForBillingInformation.boolValue;
|
|
357
|
+
}
|
|
358
|
+
|
|
283
359
|
uiConfiguration.theme = [self themeFromUIConfiguration:dictionary];
|
|
284
360
|
|
|
285
361
|
return uiConfiguration;
|
package/ios/Podfile
CHANGED
|
@@ -16,10 +16,10 @@ pre_install do |installer|
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
target 'RNJudo' do
|
|
19
|
-
use_frameworks!
|
|
19
|
+
# use_frameworks!
|
|
20
20
|
|
|
21
21
|
# Pods for RNJudo
|
|
22
|
-
pod "JudoKit-iOS", "
|
|
22
|
+
pod "JudoKit-iOS", "3.1.0"
|
|
23
23
|
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
|
|
24
24
|
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
|
|
25
25
|
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
|
package/ios/Podfile.lock
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
PODS:
|
|
2
2
|
- boost-for-react-native (1.63.0)
|
|
3
|
-
- DeviceDNA (
|
|
3
|
+
- DeviceDNA (2.0.0):
|
|
4
|
+
- OpenSSL-Universal (~> 1.1.180)
|
|
4
5
|
- DoubleConversion (1.1.6)
|
|
5
6
|
- FBLazyVector (0.61.5)
|
|
6
7
|
- FBReactNativeSpec (0.61.5):
|
|
@@ -20,10 +21,13 @@ PODS:
|
|
|
20
21
|
- DoubleConversion
|
|
21
22
|
- glog
|
|
22
23
|
- glog (0.3.5)
|
|
23
|
-
-
|
|
24
|
-
|
|
24
|
+
- Judo3DS2_iOS (1.0.1)
|
|
25
|
+
- JudoKit-iOS (3.0.2):
|
|
26
|
+
- DeviceDNA (~> 2.0.0)
|
|
27
|
+
- Judo3DS2_iOS (~> 1.0.1)
|
|
25
28
|
- TrustKit
|
|
26
29
|
- ZappMerchantLib
|
|
30
|
+
- OpenSSL-Universal (1.1.1700)
|
|
27
31
|
- RCTRequired (0.61.5)
|
|
28
32
|
- RCTTypeSafety (0.61.5):
|
|
29
33
|
- FBLazyVector (= 0.61.5)
|
|
@@ -232,7 +236,7 @@ DEPENDENCIES:
|
|
|
232
236
|
- FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`)
|
|
233
237
|
- Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
|
|
234
238
|
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
|
|
235
|
-
- JudoKit-iOS (=
|
|
239
|
+
- JudoKit-iOS (= 3.0.2)
|
|
236
240
|
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
|
|
237
241
|
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
|
|
238
242
|
- React (from `../node_modules/react-native/`)
|
|
@@ -261,7 +265,9 @@ SPEC REPOS:
|
|
|
261
265
|
trunk:
|
|
262
266
|
- boost-for-react-native
|
|
263
267
|
- DeviceDNA
|
|
268
|
+
- Judo3DS2_iOS
|
|
264
269
|
- JudoKit-iOS
|
|
270
|
+
- OpenSSL-Universal
|
|
265
271
|
- TrustKit
|
|
266
272
|
- ZappMerchantLib
|
|
267
273
|
|
|
@@ -319,13 +325,15 @@ EXTERNAL SOURCES:
|
|
|
319
325
|
|
|
320
326
|
SPEC CHECKSUMS:
|
|
321
327
|
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
|
|
322
|
-
DeviceDNA:
|
|
328
|
+
DeviceDNA: 9ff289d1fb983937754b324fa0adade2081210c4
|
|
323
329
|
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
|
|
324
330
|
FBLazyVector: aaeaf388755e4f29cd74acbc9e3b8da6d807c37f
|
|
325
331
|
FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75
|
|
326
332
|
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
|
|
327
333
|
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
|
|
328
|
-
|
|
334
|
+
Judo3DS2_iOS: c1ccf49ecacddb4559a73fb7eae6e680e2355b21
|
|
335
|
+
JudoKit-iOS: 4a96c63d4cfb45bb1a68a1891b2ebaeaa8a46be1
|
|
336
|
+
OpenSSL-Universal: ee0a7a25f2042782e2df405e66db3e429198e392
|
|
329
337
|
RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1
|
|
330
338
|
RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320
|
|
331
339
|
React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78
|
|
@@ -349,6 +357,6 @@ SPEC CHECKSUMS:
|
|
|
349
357
|
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
|
|
350
358
|
ZappMerchantLib: b14bc5814840426d351190309250347ca9b0983d
|
|
351
359
|
|
|
352
|
-
PODFILE CHECKSUM:
|
|
360
|
+
PODFILE CHECKSUM: bd8176c4a34cb7668ac5120fb4a4145962a52c2c
|
|
353
361
|
|
|
354
|
-
COCOAPODS: 1.
|
|
362
|
+
COCOAPODS: 1.11.3
|