use-shopping-cart icon indicating copy to clipboard operation
use-shopping-cart copied to clipboard

Not possible to specify payment_method_types

Open marcingolenia opened this issue 3 years ago • 6 comments

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.

marcingolenia avatar Nov 18 '21 13:11 marcingolenia

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!

dayhaysoos avatar Nov 18 '21 13:11 dayhaysoos

@marcingolenia Which checkout mode are you using? I'm assuming you're not using any serverless functions or anything, yeah?

dayhaysoos avatar Nov 18 '21 14:11 dayhaysoos

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 avatar Nov 18 '21 15:11 marcingolenia

@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 >

dayhaysoos avatar Nov 23 '21 21:11 dayhaysoos

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.

marcingolenia avatar Nov 24 '21 10:11 marcingolenia

:(

marcingolenia avatar Jan 07 '22 21:01 marcingolenia