blob: e3037fbabe7dee10b543966a52f9a189c5fdbd2e (
plain)
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
|
import { Component } from 'react';
import withData from '../lib/withData';
import StripeCheckout from 'react-stripe-checkout';
class TakeMoney extends React.Component {
onToken = async (token) => {
console.log(token);
// now that we have the token, create an "order"
// const res = await fetch('/save-stripe-token', {
// method: 'POST',
// body: JSON.stringify(token),
// })
// const data = await res.json();
// console.log(data);
}
// ...
render() {
return (
// ...
<StripeCheckout
token={this.onToken}
stripeKey="pk_lclTtThFp8CnO3QtEZSd8HA9mFUps"
amount={1000000} // cents
currency="USD"
/>
)
}
}
class Buy extends Component {
render() {
return (
<div>
<p>Buy</p>
<TakeMoney></TakeMoney>
</div>
)
}
}
export default withData(Buy);
|