@jimrising/easymerchantsdk-react-native 2.3.2 → 2.3.3
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 +5 -59
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Add the EasyMerchant SDK to your `package.json` under `dependencies`:
|
|
|
19
19
|
|
|
20
20
|
```json
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@jimrising/easymerchantsdk-react-native": "^2.3.
|
|
22
|
+
"@jimrising/easymerchantsdk-react-native": "^2.3.3"
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -319,61 +319,7 @@ const initializeEnvironment = async () => {
|
|
|
319
319
|
|
|
320
320
|
**Note**: This step is required only for `makePayment` on iOS. Android and `makePaymentV2` do not require environment initialization.
|
|
321
321
|
|
|
322
|
-
### 4.
|
|
323
|
-
|
|
324
|
-
For `makePaymentV2`, obtain a client token from the EasyMerchant payment intent API:
|
|
325
|
-
|
|
326
|
-
```javascript
|
|
327
|
-
const apiUrls = {
|
|
328
|
-
sandbox: 'sandbox-url-here',
|
|
329
|
-
production: 'production-url-here'
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
const handleGetClientToken = async () => {
|
|
333
|
-
try {
|
|
334
|
-
const { apiKey, secretKey } = configMakePayment; // Use credentials from makePayment config
|
|
335
|
-
const apiUrl = apiUrls[configMakePaymentV2.environment];
|
|
336
|
-
const params = {
|
|
337
|
-
amount: 13.53,
|
|
338
|
-
intervals: [ "weekly","monthly"],
|
|
339
|
-
is_recurring: true,
|
|
340
|
-
recurring_start_date: "MM/DD/YYYY",
|
|
341
|
-
allowed_cycles: 2,
|
|
342
|
-
recurring_start_date_type: "fixed"
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
const response = await fetch(apiUrl, {
|
|
346
|
-
method: 'POST',
|
|
347
|
-
headers: {
|
|
348
|
-
'Content-Type': 'application/json',
|
|
349
|
-
'X-Api-Key': apiKey,
|
|
350
|
-
'X-Api-Secret': secretKey
|
|
351
|
-
},
|
|
352
|
-
body: JSON.stringify(params)
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
const data = await response.json();
|
|
356
|
-
if (data.status === true && data.client_token) {
|
|
357
|
-
configMakePaymentV2.clientToken = data.client_token;
|
|
358
|
-
console.log('Client Token:', data.client_token);
|
|
359
|
-
Alert.alert('Success', 'Client token retrieved successfully');
|
|
360
|
-
} else {
|
|
361
|
-
throw new Error(data.message || 'No client_token in response');
|
|
362
|
-
}
|
|
363
|
-
} catch (error) {
|
|
364
|
-
console.error('Get Client Token Error:', error);
|
|
365
|
-
Alert.alert('Error', `Failed to retrieve client token: ${error.message}`);
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
**Notes**:
|
|
371
|
-
- Call `handleGetClientToken` before `makePaymentV2`.
|
|
372
|
-
- The API endpoint varies by environment (`sandbox` or `production`).
|
|
373
|
-
- Use `apiKey` and `secretKey` from `configMakePayment` to authenticate the API request.
|
|
374
|
-
- Include recurring payment parameters if `is_recurring` is `true`.
|
|
375
|
-
|
|
376
|
-
### 5. Process Payments
|
|
322
|
+
### 4. Process Payments
|
|
377
323
|
|
|
378
324
|
#### Using `makePayment` (Direct Payment)
|
|
379
325
|
|
|
@@ -470,7 +416,7 @@ const handlePaymentV2 = async () => {
|
|
|
470
416
|
- **Validation**: Ensures `amount` is positive, at least one payment method is selected, and a `clientToken` is provided for `makePaymentV2`.
|
|
471
417
|
- **Error Handling**: Displays user-friendly alerts for errors.
|
|
472
418
|
|
|
473
|
-
###
|
|
419
|
+
### 5. Android Event Listeners
|
|
474
420
|
|
|
475
421
|
Set up event listeners for Android to handle payment success, status, and errors:
|
|
476
422
|
|
|
@@ -518,7 +464,7 @@ const setupAndroidEventListeners = () => {
|
|
|
518
464
|
|
|
519
465
|
**Note**: Call `setupAndroidEventListeners()` during app initialization and clean up listeners when done (returned function).
|
|
520
466
|
|
|
521
|
-
###
|
|
467
|
+
### 6. Check Payment Status (Android Only)
|
|
522
468
|
|
|
523
469
|
Check the status of a payment on Android:
|
|
524
470
|
|
|
@@ -539,7 +485,7 @@ const checkPaymentStatus = async () => {
|
|
|
539
485
|
};
|
|
540
486
|
```
|
|
541
487
|
|
|
542
|
-
###
|
|
488
|
+
### 7. Payment Reference (iOS Only)
|
|
543
489
|
|
|
544
490
|
Retrieve payment reference details on iOS using a `ref_token`:
|
|
545
491
|
|