@jimrising/easymerchantsdk-react-native 1.7.0 → 1.7.1
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/README.md +191 -116
- package/android/build.gradle +1 -1
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ To add the path of sdk in your project. Open your `package.json` file and inside
|
|
|
7
7
|
|
|
8
8
|
```json
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@jimrising/easymerchantsdk-react-native": "^1.7.
|
|
10
|
+
"@jimrising/easymerchantsdk-react-native": "^1.7.1"
|
|
11
11
|
},
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -134,8 +134,12 @@ const { RNEasymerchantsdk, EasyMerchantSdk } = NativeModules;
|
|
|
134
134
|
|
|
135
135
|
const App = () => {
|
|
136
136
|
const [amount, setAmount] = useState('');
|
|
137
|
+
const [email, setEmail] = useState('');
|
|
138
|
+
const [environment, setEnvironment] = useState('sandbox');
|
|
139
|
+
const [isRecurring, setIsRecurring] = useState(false);
|
|
140
|
+
const [emailEditable, setEmailEditable] = useState(true); // Android only
|
|
141
|
+
const [isEmail, setIsEmail] = useState(true); // iOS only
|
|
137
142
|
const [result, setResult] = useState('');
|
|
138
|
-
const [version, setVersion] = useState('');
|
|
139
143
|
const [referenceToken, setReferenceToken] = useState('');
|
|
140
144
|
const [loading, setLoading] = useState(false);
|
|
141
145
|
|
|
@@ -145,7 +149,7 @@ const App = () => {
|
|
|
145
149
|
try {
|
|
146
150
|
await EasyMerchantSdk.setViewController();
|
|
147
151
|
await EasyMerchantSdk.configureEnvironment(
|
|
148
|
-
|
|
152
|
+
environment,
|
|
149
153
|
'apiKey',
|
|
150
154
|
'secretKey'
|
|
151
155
|
);
|
|
@@ -155,74 +159,67 @@ const App = () => {
|
|
|
155
159
|
}
|
|
156
160
|
};
|
|
157
161
|
setupIOS();
|
|
158
|
-
}, []);
|
|
159
|
-
|
|
160
|
-
const getPlatformVersion = async () => {
|
|
161
|
-
try {
|
|
162
|
-
const ver =
|
|
163
|
-
Platform.OS === 'android'
|
|
164
|
-
? await RNEasymerchantsdk.platformVersion()
|
|
165
|
-
: await EasyMerchantSdk.getPlatformVersion();
|
|
166
|
-
setVersion(ver);
|
|
167
|
-
} catch (err) {
|
|
168
|
-
setVersion('Error: Could not fetch version');
|
|
169
|
-
console.error('Platform version error:', err);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
162
|
+
}, [environment]);
|
|
172
163
|
|
|
173
164
|
const handlePayment = async () => {
|
|
174
165
|
if (!amount || isNaN(parseFloat(amount)) || parseFloat(amount) <= 0) {
|
|
175
166
|
return Alert.alert('Error', 'Please enter a valid amount');
|
|
176
167
|
}
|
|
168
|
+
if (!email) {
|
|
169
|
+
return Alert.alert('Error', 'Please enter an email address');
|
|
170
|
+
}
|
|
177
171
|
|
|
178
172
|
setLoading(true);
|
|
179
173
|
|
|
180
174
|
if (Platform.OS === 'android') {
|
|
181
|
-
|
|
175
|
+
const config = {
|
|
182
176
|
amount,
|
|
183
|
-
apiKey: 'apiKey',
|
|
184
|
-
secretKey: 'secretKey',
|
|
177
|
+
apiKey: 'apiKey',
|
|
178
|
+
secretKey: 'secretKey',
|
|
185
179
|
jsonConfig: {
|
|
186
|
-
environment
|
|
180
|
+
environment,
|
|
187
181
|
amount,
|
|
188
182
|
tokenOnly: false,
|
|
189
183
|
currency: 'usd',
|
|
190
184
|
saveCard: true,
|
|
191
185
|
saveAccount: true,
|
|
192
186
|
authenticatedACH: true,
|
|
193
|
-
secureAuthentication:
|
|
187
|
+
secureAuthentication: false,
|
|
194
188
|
showReceipt: true,
|
|
195
189
|
showDonate: false,
|
|
196
190
|
showTotal: true,
|
|
197
191
|
showSubmitButton: true,
|
|
198
|
-
paymentMethod: ['card','ach'],
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
paymentMethod: ['card', 'ach'],
|
|
193
|
+
emailEditable,
|
|
194
|
+
email,
|
|
195
|
+
name: 'Pavan',
|
|
201
196
|
fields: {
|
|
202
|
-
visibility: { billing:
|
|
197
|
+
visibility: { billing: true, additional: false },
|
|
203
198
|
billing: [
|
|
204
|
-
{ name: 'address', required: true, value: '' },
|
|
205
|
-
{ name: 'country', required:
|
|
206
|
-
{ name: 'state', required: true, value: '' },
|
|
207
|
-
{ name: 'city', required: true, value: '' },
|
|
208
|
-
{ name: 'postal_code', required: true, value: '' },
|
|
199
|
+
{ name: 'address', required: true, value: 'New Address' },
|
|
200
|
+
{ name: 'country', required: true, value: 'USA' },
|
|
201
|
+
{ name: 'state', required: true, value: 'California' },
|
|
202
|
+
{ name: 'city', required: true, value: 'California' },
|
|
203
|
+
{ name: 'postal_code', required: true, value: '1432456' },
|
|
209
204
|
],
|
|
210
205
|
additional: [
|
|
211
|
-
{ name: 'name', required: true, value: '' },
|
|
212
|
-
{ name: 'email_address', required: true, value: '' },
|
|
213
|
-
{ name: 'phone_number', required: false, value: '' },
|
|
214
|
-
{ name: 'description', required: true, value: '' },
|
|
206
|
+
{ name: 'name', required: true, value: 'Test User 7' },
|
|
207
|
+
{ name: 'email_address', required: true, value: 'usertest@gmail.com' },
|
|
208
|
+
{ name: 'phone_number', required: false, value: '8978967895' },
|
|
209
|
+
{ name: 'description', required: true, value: 'Hi This is description' },
|
|
215
210
|
],
|
|
216
211
|
},
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
212
|
+
...(isRecurring && {
|
|
213
|
+
recurring: {
|
|
214
|
+
enableRecurring: true,
|
|
215
|
+
recurringData: {
|
|
216
|
+
allowCycles: 2,
|
|
217
|
+
intervals: ['Weekly', 'Monthly'],
|
|
218
|
+
recurringStartType: 'Custom',
|
|
219
|
+
recurringStartDate: '31/12/2026',
|
|
220
|
+
},
|
|
224
221
|
},
|
|
225
|
-
},
|
|
222
|
+
}),
|
|
226
223
|
grailPayParams: {
|
|
227
224
|
role: 'business',
|
|
228
225
|
timeout: 10,
|
|
@@ -231,28 +228,29 @@ const App = () => {
|
|
|
231
228
|
finderSubtitle: 'Search for your bank',
|
|
232
229
|
searchPlaceholder: 'Enter bank name',
|
|
233
230
|
},
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
231
|
+
appearanceSettings: {
|
|
232
|
+
theme: 'dark',
|
|
233
|
+
bodyBackgroundColor: '#121212',
|
|
234
|
+
containerBackgroundColor: '#1E1E1E',
|
|
235
|
+
primaryFontColor: '#FFFFFF',
|
|
236
|
+
secondaryFontColor: '#B0B0B0',
|
|
237
|
+
primaryButtonBackgroundColor: '#2563EB',
|
|
238
|
+
primaryButtonHoverColor: '#1D4ED8',
|
|
239
|
+
primaryButtonFontColor: '#FFFFFF',
|
|
240
|
+
secondaryButtonBackgroundColor: '#374151',
|
|
241
|
+
secondaryButtonHoverColor: '#4B5563',
|
|
242
|
+
secondaryButtonFontColor: '#E5E7EB',
|
|
243
|
+
borderRadius: '8',
|
|
244
|
+
fontSize: '14',
|
|
245
|
+
fontWeight: '500',
|
|
246
|
+
fontFamily: 'Inter, sans-serif'
|
|
247
|
+
}
|
|
251
248
|
},
|
|
252
249
|
};
|
|
253
250
|
|
|
254
251
|
try {
|
|
255
252
|
const response = await RNEasymerchantsdk.makePayment(config);
|
|
253
|
+
console.log('Full payment response:', response);
|
|
256
254
|
setResult(response.response || JSON.stringify(response, null, 2));
|
|
257
255
|
} catch (error) {
|
|
258
256
|
setResult(`Error: ${error.message}`);
|
|
@@ -260,8 +258,7 @@ const App = () => {
|
|
|
260
258
|
} finally {
|
|
261
259
|
setLoading(false);
|
|
262
260
|
}
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
261
|
+
} else {
|
|
265
262
|
handleBilling();
|
|
266
263
|
}
|
|
267
264
|
};
|
|
@@ -270,7 +267,7 @@ const App = () => {
|
|
|
270
267
|
const billingInfo = {
|
|
271
268
|
visibility: { billing: false, additional: false },
|
|
272
269
|
billing: {
|
|
273
|
-
address: 'San Fran
|
|
270
|
+
address: 'San Fran',
|
|
274
271
|
country: 'USA',
|
|
275
272
|
state: 'California',
|
|
276
273
|
city: 'Paris',
|
|
@@ -298,20 +295,20 @@ const App = () => {
|
|
|
298
295
|
};
|
|
299
296
|
|
|
300
297
|
const themeConfiguration = {
|
|
301
|
-
bodyBackgroundColor:
|
|
302
|
-
containerBackgroundColor:
|
|
303
|
-
primaryFontColor:
|
|
304
|
-
secondaryFontColor:
|
|
305
|
-
primaryButtonBackgroundColor:
|
|
306
|
-
primaryButtonHoverColor:
|
|
307
|
-
primaryButtonFontColor:
|
|
308
|
-
secondaryButtonBackgroundColor:
|
|
309
|
-
secondaryButtonHoverColor:
|
|
310
|
-
secondaryButtonFontColor:
|
|
311
|
-
borderRadius:
|
|
312
|
-
fontSize:
|
|
298
|
+
bodyBackgroundColor: "#121212",
|
|
299
|
+
containerBackgroundColor: "#1E1E1E",
|
|
300
|
+
primaryFontColor: "#FFFFFF",
|
|
301
|
+
secondaryFontColor: "#B0B0B0",
|
|
302
|
+
primaryButtonBackgroundColor: "#2563EB",
|
|
303
|
+
primaryButtonHoverColor: "#1D4ED8",
|
|
304
|
+
primaryButtonFontColor: "#FFFFFF",
|
|
305
|
+
secondaryButtonBackgroundColor: "#374151",
|
|
306
|
+
secondaryButtonHoverColor: "#4B5563",
|
|
307
|
+
secondaryButtonFontColor: "#E5E7EB",
|
|
308
|
+
borderRadius: "8",
|
|
309
|
+
fontSize: "14",
|
|
313
310
|
fontWeight: 500,
|
|
314
|
-
fontFamily:
|
|
311
|
+
fontFamily: "\"Inter\", sans-serif"
|
|
315
312
|
};
|
|
316
313
|
|
|
317
314
|
const authConfig = {
|
|
@@ -330,28 +327,28 @@ const App = () => {
|
|
|
330
327
|
billingInfo,
|
|
331
328
|
['card', 'bank'],
|
|
332
329
|
themeConfiguration,
|
|
333
|
-
false,
|
|
334
|
-
true,
|
|
335
|
-
true,
|
|
336
|
-
true,
|
|
337
|
-
authConfig,
|
|
330
|
+
false, // tokenOnly
|
|
331
|
+
true, // saveCard
|
|
332
|
+
true, // saveAccount
|
|
333
|
+
true, // authenticatedACH
|
|
334
|
+
authConfig, // grailPayParams
|
|
338
335
|
'Submit',
|
|
339
|
-
|
|
340
|
-
2,
|
|
341
|
-
['weekly', 'monthly'],
|
|
342
|
-
'custom',
|
|
343
|
-
'07/
|
|
344
|
-
true,
|
|
345
|
-
true,
|
|
346
|
-
true,
|
|
347
|
-
true
|
|
348
|
-
|
|
349
|
-
|
|
336
|
+
isRecurring, // isRecurring
|
|
337
|
+
isRecurring ? 2 : 0, // if isRecurring == true then numOfCycle required
|
|
338
|
+
isRecurring ? ['weekly', 'monthly'] : [], // if isRecurring == true then it is required
|
|
339
|
+
isRecurring ? 'custom' : '', // if isRecurring == true then it is required
|
|
340
|
+
isRecurring ? '07/08/2025' : '', // if isRecurring == true then it is required
|
|
341
|
+
true, // secureAuthentication
|
|
342
|
+
true, // showReceipt
|
|
343
|
+
true, // showTotal
|
|
344
|
+
true, // showSubmitButton
|
|
345
|
+
isEmail,
|
|
346
|
+
email,
|
|
347
|
+
"Pavan"
|
|
350
348
|
);
|
|
351
349
|
|
|
352
350
|
const refToken = result?.additionalInfo?.threeDSecureStatus?.data?.ref_token;
|
|
353
351
|
if (refToken) setReferenceToken(refToken);
|
|
354
|
-
|
|
355
352
|
setResult(JSON.stringify(result, null, 2));
|
|
356
353
|
} catch (error) {
|
|
357
354
|
console.error('Billing Error:', error);
|
|
@@ -359,19 +356,6 @@ const App = () => {
|
|
|
359
356
|
}
|
|
360
357
|
};
|
|
361
358
|
|
|
362
|
-
const handleCheckStatus = async () => {
|
|
363
|
-
setLoading(true);
|
|
364
|
-
try {
|
|
365
|
-
const response = await RNEasymerchantsdk.checkPaymentStatus();
|
|
366
|
-
setResult(response.response || JSON.stringify(response, null, 2));
|
|
367
|
-
} catch (error) {
|
|
368
|
-
setResult(`Error: ${error.message}`);
|
|
369
|
-
Alert.alert('Status Check Error', error.message);
|
|
370
|
-
} finally {
|
|
371
|
-
setLoading(false);
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
|
|
375
359
|
const handlePaymentReference = async () => {
|
|
376
360
|
if (Platform.OS === 'android') {
|
|
377
361
|
setResult('❌ Payment Reference not supported on Android');
|
|
@@ -383,8 +367,7 @@ const App = () => {
|
|
|
383
367
|
}
|
|
384
368
|
try {
|
|
385
369
|
const result = await EasyMerchantSdk.paymentReference(referenceToken);
|
|
386
|
-
setResult(`✅ Payment Reference
|
|
387
|
-
${JSON.stringify(result, null, 2)}`);
|
|
370
|
+
setResult(`✅ Payment Reference:\n${JSON.stringify(result, null, 2)}`);
|
|
388
371
|
} catch (error) {
|
|
389
372
|
setResult(`❌ Payment Reference Error: ${error.message || JSON.stringify(error)}`);
|
|
390
373
|
}
|
|
@@ -394,8 +377,7 @@ ${JSON.stringify(result, null, 2)}`);
|
|
|
394
377
|
<View style={styles.container}>
|
|
395
378
|
<ScrollView contentContainerStyle={styles.scrollContent}>
|
|
396
379
|
<Text style={styles.title}>EasyMerchant SDK</Text>
|
|
397
|
-
|
|
398
|
-
<Button title="Get Platform Version" onPress={getPlatformVersion} disabled={loading} />
|
|
380
|
+
|
|
399
381
|
<TextInput
|
|
400
382
|
style={styles.input}
|
|
401
383
|
placeholder="Enter amount (e.g., 10.00)"
|
|
@@ -403,11 +385,86 @@ ${JSON.stringify(result, null, 2)}`);
|
|
|
403
385
|
value={amount}
|
|
404
386
|
onChangeText={setAmount}
|
|
405
387
|
/>
|
|
388
|
+
|
|
389
|
+
<TextInput
|
|
390
|
+
style={styles.input}
|
|
391
|
+
placeholder="Enter email"
|
|
392
|
+
keyboardType="email-address"
|
|
393
|
+
value={email}
|
|
394
|
+
onChangeText={setEmail}
|
|
395
|
+
/>
|
|
396
|
+
|
|
397
|
+
<View style={styles.pickerContainer}>
|
|
398
|
+
<Text style={styles.label}>Environment:</Text>
|
|
399
|
+
<View style={styles.buttonGroup}>
|
|
400
|
+
<Button
|
|
401
|
+
title="Sandbox"
|
|
402
|
+
onPress={() => setEnvironment('sandbox')}
|
|
403
|
+
color={environment === 'sandbox' ? '#2563EB' : '#ccc'}
|
|
404
|
+
/>
|
|
405
|
+
<Button
|
|
406
|
+
title="Staging"
|
|
407
|
+
onPress={() => setEnvironment('staging')}
|
|
408
|
+
color={environment === 'staging' ? '#2563EB' : '#ccc'}
|
|
409
|
+
/>
|
|
410
|
+
</View>
|
|
411
|
+
</View>
|
|
412
|
+
|
|
413
|
+
<View style={styles.pickerContainer}>
|
|
414
|
+
<Text style={styles.label}>Recurring Payment:</Text>
|
|
415
|
+
<View style={styles.buttonGroup}>
|
|
416
|
+
<Button
|
|
417
|
+
title="Yes"
|
|
418
|
+
onPress={() => setIsRecurring(true)}
|
|
419
|
+
color={isRecurring ? '#2563EB' : '#ccc'}
|
|
420
|
+
/>
|
|
421
|
+
<Button
|
|
422
|
+
title="No"
|
|
423
|
+
onPress={() => setIsRecurring(false)}
|
|
424
|
+
color={!isRecurring ? '#2563EB' : '#ccc'}
|
|
425
|
+
/>
|
|
426
|
+
</View>
|
|
427
|
+
</View>
|
|
428
|
+
|
|
429
|
+
{Platform.OS === 'android' ? (
|
|
430
|
+
<View style={styles.pickerContainer}>
|
|
431
|
+
<Text style={styles.label}>Email Editable (Android):</Text>
|
|
432
|
+
<View style={styles.buttonGroup}>
|
|
433
|
+
<Button
|
|
434
|
+
title="True"
|
|
435
|
+
onPress={() => setEmailEditable(true)}
|
|
436
|
+
color={emailEditable ? '#2563EB' : '#ccc'}
|
|
437
|
+
/>
|
|
438
|
+
<Button
|
|
439
|
+
title="False"
|
|
440
|
+
onPress={() => setEmailEditable(false)}
|
|
441
|
+
color={!emailEditable ? '#2563EB' : '#ccc'}
|
|
442
|
+
/>
|
|
443
|
+
</View>
|
|
444
|
+
</View>
|
|
445
|
+
) : (
|
|
446
|
+
<View style={styles.pickerContainer}>
|
|
447
|
+
<Text style={styles.label}>Allow Email (iOS):</Text>
|
|
448
|
+
<View style={styles.buttonGroup}>
|
|
449
|
+
<Button
|
|
450
|
+
title="Yes"
|
|
451
|
+
onPress={() => setIsEmail(true)}
|
|
452
|
+
color={isEmail ? '#2563EB' : '#ccc'}
|
|
453
|
+
/>
|
|
454
|
+
<Button
|
|
455
|
+
title="No"
|
|
456
|
+
onPress={() => setIsEmail(false)}
|
|
457
|
+
color={!isEmail ? '#2563EB' : '#ccc'}
|
|
458
|
+
/>
|
|
459
|
+
</View>
|
|
460
|
+
</View>
|
|
461
|
+
)}
|
|
462
|
+
|
|
406
463
|
<View style={styles.buttonGroup}>
|
|
407
|
-
<Button title="Pay" onPress={handlePayment}
|
|
408
|
-
<Button title="
|
|
409
|
-
<Button title="Payment Ref" onPress={handlePaymentReference} disabled={loading} />
|
|
464
|
+
<Button title="Pay" onPress={handlePayment} />
|
|
465
|
+
<Button title="Payment Ref" onPress={handlePaymentReference} />
|
|
410
466
|
</View>
|
|
467
|
+
|
|
411
468
|
<Text selectable style={styles.result}>{result}</Text>
|
|
412
469
|
</ScrollView>
|
|
413
470
|
</View>
|
|
@@ -419,8 +476,13 @@ export default App;
|
|
|
419
476
|
const styles = StyleSheet.create({
|
|
420
477
|
container: { flex: 1, backgroundColor: '#F9FAFB' },
|
|
421
478
|
scrollContent: { flexGrow: 1, padding: 20 },
|
|
422
|
-
title: {
|
|
423
|
-
|
|
479
|
+
title: {
|
|
480
|
+
fontSize: 24,
|
|
481
|
+
fontWeight: 'bold',
|
|
482
|
+
marginBottom: 16,
|
|
483
|
+
marginTop: 50,
|
|
484
|
+
textAlign: 'center',
|
|
485
|
+
},
|
|
424
486
|
input: {
|
|
425
487
|
height: 40,
|
|
426
488
|
borderColor: '#ccc',
|
|
@@ -429,7 +491,20 @@ const styles = StyleSheet.create({
|
|
|
429
491
|
paddingHorizontal: 10,
|
|
430
492
|
marginBottom: 20,
|
|
431
493
|
},
|
|
432
|
-
|
|
494
|
+
pickerContainer: {
|
|
495
|
+
marginBottom: 20,
|
|
496
|
+
},
|
|
497
|
+
label: {
|
|
498
|
+
fontSize: 16,
|
|
499
|
+
marginBottom: 8,
|
|
500
|
+
fontWeight: '500',
|
|
501
|
+
},
|
|
502
|
+
buttonGroup: {
|
|
503
|
+
flexDirection: 'row',
|
|
504
|
+
justifyContent: 'space-between',
|
|
505
|
+
marginBottom: 20,
|
|
506
|
+
gap: 10,
|
|
507
|
+
},
|
|
433
508
|
result: { fontSize: 14, fontFamily: 'monospace', color: '#333' },
|
|
434
509
|
});
|
|
435
510
|
|
package/android/build.gradle
CHANGED
|
@@ -39,7 +39,7 @@ repositories {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
dependencies {
|
|
42
|
-
implementation 'com.app:paysdk:1.3.
|
|
42
|
+
implementation 'com.app:paysdk:1.3.4'
|
|
43
43
|
implementation 'com.hbb20:ccp:2.7.3'
|
|
44
44
|
implementation 'com.github.bumptech.glide:glide:4.16.0'
|
|
45
45
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1"
|