Skip to content

Commit bbab822

Browse files
committed
chore: updated usage example
1 parent 8f8e59b commit bbab822

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

example/src/App.tsx

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { useRef, useState } from 'react';
22
import { View, StyleSheet, Text, TouchableOpacity, Alert } from 'react-native';
3-
import { IswPaymentWebView } from 'react-native-interswitch-pay';
4-
import type { IswWebViewRefMethods } from '../../src/types';
3+
import {
4+
IswPaymentWebView,
5+
type IswWebViewRefMethods,
6+
} from 'react-native-interswitch-pay';
57

68
export default function App() {
79
const webRef = useRef<IswWebViewRefMethods>(null);
@@ -12,6 +14,7 @@ export default function App() {
1214
const newTxnRef = `txn_${Date.now()}`;
1315
setTxnRef(newTxnRef);
1416

17+
// Added this delay for Test purposes, so you can test multiple times
1518
setTimeout(() => {
1619
webRef.current?.start();
1720
}, 100);
@@ -21,33 +24,17 @@ export default function App() {
2124
};
2225

2326
const isw = {
24-
merchantCode: 'MX189360',
25-
payItemId: 'Default_Payable_MX189360',
27+
merchantCode: 'MX6072',
28+
payItemId: '9405967',
2629
transactionRef: txnRef,
2730
amount: 100000,
2831
currency: '566',
2932
mode: 'TEST',
30-
customerName: 'Interswitch Energy Platform',
31-
customerId: '40375312338625',
32-
splitAccounts: [
33-
{
34-
alias: 'Merchant Account',
35-
amount: 50000,
36-
description: 'Meter top up',
37-
isPrimary: true,
38-
},
39-
{
40-
alias: 'Indeco Convenience Account 1',
41-
amount: 50000,
42-
description: 'Meter top up convenience fee',
43-
isPrimary: false,
44-
},
45-
],
46-
customerEmail: 'innovation@interswitchng.com',
4733
};
4834

4935
return (
5036
<View style={styles.container}>
37+
<Text style={styles.text}>Interswitch Payment Gateway</Text>
5138
<TouchableOpacity style={styles.button} onPress={handleStartPayment}>
5239
<Text style={styles.buttonText}>Start Payment</Text>
5340
</TouchableOpacity>
@@ -61,14 +48,15 @@ export default function App() {
6148
ref={webRef}
6249
amount={isw.amount}
6350
autoStart={false}
51+
trnxRef={txnRef}
52+
showBackdrop={false}
6453
mode={isw.mode as any}
6554
merchantCode={isw.merchantCode}
66-
trnxRef={txnRef}
6755
payItem={{ id: isw.payItemId }}
56+
style={styles.webViewStyle}
6857
onCompleted={(response) => {
6958
console.log('AcceptPaymentScreen', response);
7059
}}
71-
splitAccounts={isw.splitAccounts}
7260
/>
7361
</View>
7462
);
@@ -78,6 +66,12 @@ const styles = StyleSheet.create({
7866
container: {
7967
flex: 1,
8068
paddingTop: 40,
69+
paddingHorizontal: 24,
70+
},
71+
text: {
72+
textAlign: 'center',
73+
marginTop: 40,
74+
fontSize: 20,
8175
},
8276
title: {
8377
fontSize: 18,
@@ -87,9 +81,9 @@ const styles = StyleSheet.create({
8781
button: {
8882
marginTop: '20%',
8983
backgroundColor: '#007bff',
90-
paddingVertical: 10,
84+
paddingVertical: 16,
9185
paddingHorizontal: 20,
92-
borderRadius: 6,
86+
borderRadius: 8,
9387
},
9488
stopButton: {
9589
backgroundColor: '#dc3545',
@@ -98,4 +92,7 @@ const styles = StyleSheet.create({
9892
color: '#fff',
9993
fontSize: 16,
10094
},
95+
webViewStyle: {
96+
marginTop: '10%',
97+
},
10198
});

0 commit comments

Comments
 (0)