-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHaloCall.js
54 lines (46 loc) · 1.44 KB
/
HaloCall.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
import {StyleSheet, Text, View} from 'react-native';
import {useEffect, useState} from "react";
import Deeplink from "./Deeplink";
export default function HaloCall() {
var myHeaders = new Headers();
const [intentResponse, setIntentResponse] = useState(null);
myHeaders.append("x-api-key", "KzI3Njc5NzY1NTY0LjVhN2I3NmIyLTBkNTgtNGY4Mi1hODk2LWM4MzhjYWFjMTJmYg==");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"amount": 13,
"merchantId": 597,
"paymentReference": "qwerty",
"currencyCode": "ZAR",
"timestamp": "Wed Oct 19 2022 15:41:40 GMT+0300"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
useEffect(() => {
fetch("https://kernelserver.qa.haloplus.io/consumer/intentTransaction", requestOptions)
.then(response => response.text())
.then((result) => {
const parsedResponse = JSON.parse(result);
setIntentResponse(parsedResponse);
})
.catch(error => console.log('error', error));
}, []);
return (
<View style={styles.container}>
<Text>[Remove] This is where the intent call is made</Text>
{intentResponse && <Text>{intentResponse.id}</Text>}
<Deeplink amount={20}/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#c8ffb3',
alignItems: 'center',
justifyContent: 'center',
},
});