Last active
May 3, 2020 20:07
-
-
Save ryanbelke/6089be1c66d67261ec1d4eb0273d72cf to your computer and use it in GitHub Desktop.
/pages/checkout.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* pages/checkout.js */ | |
| import React, { useContext } from "react"; | |
| import { Row, Col } from "reactstrap"; | |
| import { loadStripe } from "@stripe/stripe-js"; | |
| import { Elements } from "@stripe/react-stripe-js"; | |
| import InjectedCheckoutForm from "../components/Checkout/CheckoutForm"; | |
| import AppContext from "../context/appContext"; | |
| import Cart from "../components/Cart/Cart"; | |
| function Checkout() { | |
| // get app context | |
| const appContext = useContext(AppContext); | |
| // isAuthenticated is passed to the cart component to display order button | |
| const { isAuthenticated } = appContext; | |
| // load stripe to inject into elements components | |
| const stripePromise = loadStripe("pk_test_5yOGF65rhzZjobGYiOoYJoj0"); | |
| return ( | |
| <Row> | |
| <Col style={{ paddingRight: 0 }} sm={{ size: 3, order: 1, offset: 2 }}> | |
| <h1 style={{ margin: 20 }}>Checkout</h1> | |
| <Cart isAuthenticated={isAuthenticated} /> | |
| </Col> | |
| <Col style={{ paddingLeft: 5 }} sm={{ size: 6, order: 2 }}> | |
| <Elements stripe={stripePromise}> | |
| <InjectedCheckoutForm /> | |
| </Elements> | |
| </Col> | |
| </Row> | |
| ); | |
| // } | |
| } | |
| export default Checkout; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment