summaryrefslogtreecommitdiffstats
path: root/components/TakeMyMoney.js
diff options
context:
space:
mode:
Diffstat (limited to 'components/TakeMyMoney.js')
-rw-r--r--components/TakeMyMoney.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/components/TakeMyMoney.js b/components/TakeMyMoney.js
new file mode 100644
index 0000000..143f990
--- /dev/null
+++ b/components/TakeMyMoney.js
@@ -0,0 +1,31 @@
+import { Component } from 'react';
+import StripeCheckout from 'react-stripe-checkout';
+import { CREATE_ORDER_MUTATION } from '../queries';
+import { graphql } from 'react-apollo';
+
+
+class TakeMyMoney extends Component {
+ onToken = async (res) => {
+ const token = res.id;
+ console.log(`Going to make a purchase with ${token}`);
+ const charge = await this.props.createOrder({ variables: { token }});
+ alert(`Back from the charge! ${charge.id}`);
+ console.log(charge);
+
+ }
+ render() {
+ return (
+ // ...
+ <StripeCheckout
+ {...this.props}
+ token={this.onToken}
+ stripeKey="pk_lclTtThFp8CnO3QtEZSd8HA9mFUps"
+ currency="USD"
+ >
+ {this.props.children}
+ </StripeCheckout>
+ )
+ }
+}
+
+export default graphql(CREATE_ORDER_MUTATION, { name: 'createOrder' })(TakeMyMoney);