-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.jsx
More file actions
48 lines (43 loc) · 1.2 KB
/
.jsx
File metadata and controls
48 lines (43 loc) · 1.2 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
// ============================================================================
// Example React Component - Modeled after PiButton
// Extends PiSdkComponent for Pi Network flows and UI.
// ============================================================================
import React from 'react';
import PiSdkBase from "./pi_network_base";
import PiSdkComponent from "./PiSdkComponent";
export default class extends PiSdkComponent {
constructor(props) {
super(props);
this.state = {
connected: this.is_connected_to_pi()
};
}
componentDidMount() {
super.componentDidMount();
}
onConnection() {
this.setState({ connected: this.is_connected_to_pi() });
}
buy() {
PiSdkBase.log("Buy Initiated");
// Demo purposes, random order id
const demoOrderId = Math.floor(10000 + Math.random() * 90000);
const paymentData = {
amount: 0.01,
memo: "ConnecTo-Pi Admission",
metadata: {
description: "ConnecTo Admission",
order_id: demoOrderId
}
};
this.createPayment(paymentData);
}
render() {
return (
<button
disabled={!this.state.connected}
onClick={() => this.buy()}
>Buy</button>
);
}
}