diff options
| author | Wes Bos <wesbos@gmail.com> | 2017-08-11 14:56:13 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2017-08-11 14:56:13 -0400 |
| commit | 416c2cbae0e69b724876d232bf813eefd7550174 (patch) | |
| tree | ce7109c0f61dbeee7077164cb48a4681214e0464 /components/TakeMyMoney.js | |
| parent | 222ab374d53a206332b1ab51c7c43f6d5dc7a31e (diff) | |
getting there
Diffstat (limited to 'components/TakeMyMoney.js')
| -rw-r--r-- | components/TakeMyMoney.js | 31 |
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); |
