You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stripe.js 595B

1234567891011121314151617181920212223
  1. import { loadStripe } from '@stripe/stripe-js';
  2. export async function stripe({ lineItems }) {
  3. let stripePromise = null;
  4. const getStripe = () => {
  5. if (!stripePromise) {
  6. stripePromise = loadStripe(
  7. 'pk_test_51Lg3phDY7dvAcw2fNi1ACbS7S0SrEQs7SQUwA9YfKrLvjRH1jyV4nwM8fg32Adfxzn5uXitNGqsyPPtavpdR8UU800rxDPajp8'
  8. );
  9. }
  10. return stripePromise;
  11. };
  12. const stripe = await getStripe();
  13. await stripe.redirectToCheckout({
  14. mode: 'payment',
  15. lineItems,
  16. successUrl: `${window.location.origin}/review`,
  17. cancelUrl: `${window.location.origin}/cart`,
  18. });
  19. }