-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPayment.js
185 lines (169 loc) · 5.6 KB
/
Payment.js
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import React, { Component } from 'react';
import { Image, TouchableHighlight, Modal, AsyncStorage, Dimensions, StyleSheet, StatusBar, TouchableOpacity } from 'react-native';
import { Container, Text, Spinner, Textarea, Header, View, Button, Icon, Fab, Tab, Tabs, ScrollableTab, Left, Right, Body, Title, Subtitle, Thumbnail, Content } from 'native-base';
import { WebView } from 'react-native-webview';
import * as Font from 'expo-font';
import { Ionicons } from '@expo/vector-icons';
import api from './DbConfig';
StatusBar.setBackgroundColor('#0099ff',true);
const {width, height} = Dimensions.get("window");
export default class Payment extends Component {
constructor(props) {
super(props)
this.state = {
btnsnipper:0,
useruid:0,
username:'',
email:'',
contact:'',
purpose:'Club Membership',
amount: 200,
apilink:'',
modalVisible:false,
};
}
_retrieveData = async () => {
try{
const useruid = await AsyncStorage.getItem('userid').then((value) => {
this.decision();
});
}
catch(err){
console.log('Profile Page store error: '+err);
}
};
decision=async ()=>{
try{
const useruid = await AsyncStorage.getItem('userid');
if (useruid!==null) {
const nameuser = await AsyncStorage.getItem('name');
const usermail = await AsyncStorage.getItem('mail');
const usercontact = await AsyncStorage.getItem('contact');
const purpose_get = this.props.route.params.purpose;
const amount_get = this.props.route.params.amount;
this.setState({useruid:useruid});
this.setState({username:nameuser});
this.setState({email:usermail});
this.setState({contact:usercontact});
this.setState({purpose:purpose_get});
this.setState({amount:amount_get});
this.setState({apilink:api+'common_payment/pay.php?purpose='+purpose_get+'&name='+nameuser+'&email='+usermail+'&amount='+amount_get+'&id='+useruid+'&phone='+usercontact});
}
else{
this.props.navigation.replace("Login");
}
}
catch(err){
console.log('Profile Page store error: '+err);
}
}
verifyyy=()=>{
var InsertAPI = api+'payverify.php';
var Data={cat:this.state.useruid};
var headers={
'Accept':'application/json',
'Content-Type':'application.json'
}
fetch(InsertAPI,{
method:'POST',
headers:headers,
body:JSON.stringify(Data),
}).then((response)=>response.json()).then((response)=>{
if(response==='True'){
this.setState({btnsnipper:0});
}
else{
alert('You have already membership.');
this.props.navigation.goBack();
this.setState({btnsnipper:0});
}
})
.catch(err=>{
console.log(err);
this.setState({btnsnipper:0});
alert('Something went wrong!!!');
})
}
async componentDidMount() {
this._retrieveData();
await Font.loadAsync({
'Roboto': require('native-base/Fonts/Roboto.ttf'),
'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
...Ionicons.font,
})
this.setState({ loading: false })
}
render() {
return (
<Container>
<Header style={{backgroundColor:'#0099ff'}} androidStatusBarColor='#0099ff'>
<Left>
<Button transparent onPress={()=>{this.props.navigation.goBack()}}>
<Icon name='arrow-back' />
</Button>
</Left>
<Body>
<Title>PAYMENT</Title>
</Body>
<Right />
</Header>
<Content>
<View style={{height:height}}>
{this.state.btnsnipper==1?
<Spinner color='#0099ff' style={{marginTop:height/3}} />:<WebView source={{ uri: this.state.apilink }} onLoadStart={() => this.setState({modalVisible:true})}
onLoad={() => this.setState({modalVisible:false})}/>}
</View>
<View style={styles.centeredView}>
<Modal
animationType="slide"
transparent={true}
visible={this.state.modalVisible}
>
<View style={styles.centeredView}>
<View style={styles.modalView}>
<Thumbnail source={require('./assets/payload.gif')}
style={{height:height/4,width:width, resizeMode:'contain'}}
/>
<Text note style={{fontSize:20}}>Loading</Text>
</View>
</View>
</Modal>
</View>
</Content>
</Container>
);
}
}
const styles = StyleSheet.create({
centeredView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
modalView: {
margin: 20,
backgroundColor: 'white',
borderRadius: 10,
width:(width/2)+50,
justifyContent:'center',
height:height/3,
alignItems: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
},
textStyle: {
color: 'white',
fontWeight: 'bold',
textAlign: 'center',
},
modalText: {
marginBottom: 15,
textAlign: 'center',
},
});