-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeeplink.js
77 lines (69 loc) · 2.14 KB
/
Deeplink.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
import React, {useState} from 'react';
import {StyleSheet, Linking, Text, TouchableOpacity, View} from "react-native";
import {COLOURS} from "./components/database/Database";
function Deeplink({amount})
{
const [paymentUrl, setPaymentUrl] = useState("");
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
"amount": amount,
"merchantId": 597,
"paymentReference": "qwerty",
"timestamp": "Wed Oct 19 2022 15:41:40 GMT+0300"
});
const requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
const handlePress = () => {
console.log("handlePress")
fetch("https://greetings-halocall-xbuls6ziyq-uc.a.run.app", requestOptions)
.then(response => response.json())
.then(result => {
const url = result.qrCode.url;
console.log(JSON.stringify(result.qrCode.url))
Linking.openURL(url);
})
.catch(error => console.log('error', error));
};
return (
<View style={styles.addToCartButton}>
<TouchableOpacity
onPress={handlePress}
style={styles.addToCartButtonContainer}>
<Text style={styles.addToCartButtonText}>
Pay With Halo.Link {amount}
</Text>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
addToCartButton: {
position: 'absolute',
bottom: 10,
height: '8%',
width: '100%',
justifyContent: 'center',
alignItems: 'center',
},
addToCartButtonContainer: {
width: '86%',
height: '90%',
backgroundColor: COLOURS.black,
borderRadius: 20,
justifyContent: 'center',
alignItems: 'center',
},
addToCartButtonText: {
fontSize: 12,
fontWeight: '500',
letterSpacing: 1,
color: COLOURS.white,
textTransform: 'uppercase',
},
})
export default Deeplink;