use-shopping-cart
use-shopping-cart copied to clipboard
Not possible to specify payment_method_types
Hi there! I wanted to specify other payment methods like stated in docs; https://stripe.com/docs/payments/p24/accept-a-payment?platform=checkout
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card', 'p24'],
line_items: [{
...
but it seems not possible. I tried to look into the source code. It seems that in stripe.js https://github.com/dayhaysoos/use-shopping-cart/blob/6fd480cdc8264a609efaf6ea879178ea8a4e2769/use-shopping-cart/core/middleware/stripe.js#L9 we would need to add extra parameter (getCheckoutData function)
const options = {
mode: cart.mode,
paymentMethodTypes: cart.paymentMethodTypes, // THIS IS MISSING ?
lineItems,
successUrl: cart.successUrl,
cancelUrl: cart.cancelUrl,
billingAddressCollection: cart.billingAddressCollection
? 'required'
: 'auto',
submitType: 'auto'
}
and extend the CartState thing here; https://github.com/dayhaysoos/use-shopping-cart/blob/6fd480cdc8264a609efaf6ea879178ea8a4e2769/use-shopping-cart/core/index.d.ts#L117
Seems like a quick win, but probably I am missing something.
Hey! Thanks for bringing my attention to this, I'm gonna take a deeper look at this later tonight, just wanted to let you know that I saw this!
@marcingolenia Which checkout mode are you using? I'm assuming you're not using any serverless functions or anything, yeah?
client-only, so In my gatsby site I am using this like this;
<CartProvider
mode="client-only"
stripe={getStripe()}
successUrl={`${isBrowser() && window.location.origin}/thanks/`}
cancelUrl={`${isBrowser() && window.location}`}
currency="PLN"
allowedCountries={['PL']}
billingAddressCollection={true}
>
I use "2.4.3" version of the library.
@marcingolenia Yeah I should def add a way support what you're doing in client-only mode, but why are you using version 2.43?
If we were to update this, it would have to happen on version 3 >
The app I've built is not that new, I am going to update it soon. For now it just works :) It is absolutely clear that I will have to update.
:(