diff --git a/public/index.html b/public/index.html index 2f64503..d2bf47a 100644 --- a/public/index.html +++ b/public/index.html @@ -15,6 +15,7 @@ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> + <script src="https://js.stripe.com/v3/"></script> <!-- Notice the use of %PUBLIC_URL% in the tags above. It will be replaced with the URL of the `public` folder during the build. diff --git a/src/pages/Checkout.js b/src/pages/Checkout.js index dd144f0..f8210a3 100644 --- a/src/pages/Checkout.js +++ b/src/pages/Checkout.js @@ -99,7 +99,7 @@ const CardForm = injectStripe(Checkout); const StripeWrapper = () => { return ( - <StripeProvider apiKey="pk_test_RmWPHoQAmlEf6RiOlsMRkEeJ00XzgNQe2k"> + <StripeProvider apiKey="pk_test_y4RqvASvCbSkcpFMaE473erl00OluYWr6n"> <Elements> <CardForm></CardForm> </Elements> diff --git a/src/strapi/submitOrder.js b/src/strapi/submitOrder.js index c5c68b6..cfb49df 100644 --- a/src/strapi/submitOrder.js +++ b/src/strapi/submitOrder.js @@ -1 +1,25 @@ // submit order +import axios from "axios"; +import url from "../utils/URL"; + +async function submitOrder({ name, total, items, stripeTokenId, userToken }) { + const response = await axios + .post( + `${url}/orders`, + { + name, + total, + items, + stripeTokenId, + }, + { + headers: { + Authorization: `Bearer ${userToken}`, + }, + } + ) + .catch((error) => console.log(error)); + return response; +} + +export default submitOrder;