Skip to content

Instantly share code, notes, and snippets.

@bietkul
Created February 15, 2019 02:08
Show Gist options
  • Save bietkul/d993429ce51e91ff344c1bb8211bf748 to your computer and use it in GitHub Desktop.
Save bietkul/d993429ce51e91ff344c1bb8211bf748 to your computer and use it in GitHub Desktop.
Purchase button component
import React from 'react';
import PropTypes from 'prop-types';
import StripeCheckout from 'react-stripe-checkout';
const onToken = (token) => {
console.log('Stripe Token', token);
};
const Purchase = ({
price, title, children, ...props
}) => (
<StripeCheckout
name="MoviesStore@appbase.io"
description={title}
token={onToken}
amount={price * 100}
stripeKey={'<YOUR_STRIPE_KEY>'}
>
{children || <span {...props}>PURCHASE</span>}
</StripeCheckout>
);
Purchase.propTypes = {
price: PropTypes.number,
title: PropTypes.string,
children: PropTypes.node,
};
export default Purchase;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment