-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redirectToCheckout expects an optional string, some examples outdated #323
Comments
Hey @ciruz, I'ma be honest, Stripe has deprecated https://stripe.com/docs/payments/checkout/how-checkout-works. I think I should work towards removing redirectToCheckout from the library or at least warning people that it's deprecated and providing more updated examples. Thank you for flagging this, going to try and make an effort for this in about 2 weeks. |
Hey @dayhaysoos, thank you for the information. Yeah this sounds like a very good idea. |
@ciruz sweet! Yeah I'm going to make an issue for this and after 2 weeks I'll work towards getting it done and providing more updated examples |
Error: PropertyTypeError: Invalid value with type "undefined" was received for stripe. Valid type for stripe is "string". Just to confirm, when using redirectToCheckout in the latest version of useShoppingCart, it will give this error? |
@milindgoel15 can you show me how you have your CartProvider set up? |
let stripeKey: string = process.env.STRIPE_PUBLISHABLE_KEY as string; <CartProvider
stripe={stripeKey}
cartMode="checkout-session"
currency="USD"
shouldPersist
>
<style jsx global>{`
html {
font-family: ${inter.style.fontFamily};
}
`}</style>
<Header />
<Component {...pageProps} />
<Toaster />
<Footer />
</CartProvider> |
@milindgoel15 How are you using redirectToCheckout? If you're doing it with an API function, you won't have access to it since the Provider isn't wrapped around the server functions. I think this week I can spend time on updating to remove redirect to checkout altogether tbh, since it seems to be deprecated |
It is inside a custom component here which is imported in the main cart page. |
Yeah it could be possible that it doesn't get returned from the Stripe object anymore. USC uses your Stripe API key to initialize stripe and you get back redirectToCheckout from there. https://stripe.com/docs/js/deprecated/redirect_to_checkout I didn't know that it stopped being returned at this point. You're going to have to use a server function of some sort to handle this. I need to update use-shopping-cart docs to reflect these changes, I'm sorry! |
Worked using nextjs router.
|
Hello. Do you have any updates on this issue? As it seems to be in the docs |
Hey,
redirectToCheckout
expects an optional stringuse-shopping-cart/use-shopping-cart/react/index.d.ts
Line 65 in 275cb65
But some examples calls the function with an object:
use-shopping-cart/examples/vite-react/src/components/price-product.jsx
Line 24 in 275cb65
The text was updated successfully, but these errors were encountered: