-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
121 lines (101 loc) · 2.81 KB
/
App.js
File metadata and controls
121 lines (101 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* Sample React Native App
*
* adapted from App.js generated by the following command:
*
* react-native init example
*
* https://github.com/facebook/react-native
*/
import React, { useState } from 'react';
import IswMobileSdk, { IswPaymentInfo, Environment } from 'react-native-isw-mobile-sdk'
import config from './credentials.js'
import {
SafeAreaView,
StyleSheet,
View,
StatusBar,
Button,
TextInput,
} from 'react-native';
let print = (value) => {
}
let onSdkInitialized = (isSuccessful) => {
print(`sdk initialized: ${isSuccessful}`)
}
let userDidComplete = (result) => {
print(result)
}
let userDidCancel = () => {
print("user cancelled")
}
let handleSubmit = (amount) => {
amount = (amount || 2500) * 100;
const customerId = "<customer-id>",
customerName = "<customer-name>",
customerEmail = "<customer.email@domain.com>",
customerMobile = "<customer-phone>",
// generate a unique random
// reference for each transaction
reference = "<your-unique-ref>";
const paymentInfo = new IswPaymentInfo(
customerId,
customerName,
customerEmail,
customerMobile,
reference,
amount,
)
IswMobileSdk.pay(paymentInfo, userDidComplete, userDidCancel);
}
const App = () => {
// initialize mobile sdk
IswMobileSdk.initialize(config, Environment.TEST, onSdkInitialized);
const [state, setState] = useState({ amount: undefined })
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<View style={styles.body}>
<View style={styles.sectionContainer}>
<TextInput
style={styles.input}
textContentType="creditCardNumber"
placeholder="Amount"
onChangeText={amount => setState({ amount })}
value={state.amount}
/>
</View>
<View style={styles.sectionContainer}>
<Button
style={styles.button}
onPress={() => handleSubmit(state.amount)}
title="Pay"
/>
</View>
</View>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
body: {
backgroundColor: "#fff",
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
input: {
paddingLeft: 15,
paddingRight: 15,
paddingTop: 10,
paddingBottom: 10,
borderRadius: 5,
borderWidth: 2
},
button: {
height: 60
}
});
export default App;