#prattprattpratt_error

1 messages ยท Page 1 of 1 (latest)

tacit mapleBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1221933601474740315

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

near tendonBOT
umbral haven
#

Maybe I should say "I assume submitting a payment via the card/address elements throws this error because express checkout is in the elements instance."

#

Although the error only occurs if I'm in a browser that doesn't have any available payment methods (e.g., Google Pay, Apple Pay), so maybe not ๐Ÿค” the express checkout element is in there either way

lime hinge
#

Hi there, sorry for the delay!

umbral haven
#

No stress!

lime hinge
#

I'm pretty sure you'll need to unmount the element that's not being used in your confirm call

umbral haven
#

How do I unmount an element that I am rendering with React Stripe.js? i.e., I don't have an instance of the element floating around that I can .unmount like I'm assuming I would have if I was just using stripe JS. I'm just rendering <ExpressCheckout />

#

I couldn't find anything in the React Stripe.js docs, just the Unmount an Element section in the normal Stripe JS docs.

lime hinge
#

Give me a few minutes, I'll need to loop in a teammate who's more experiened with React

umbral haven
#

Sounds good, thanks

hollow jungle
#

Hello! Can you share the code that's throwing this error?

#

Also, can you confirm you're using the Card Element and not the Payment Element?

#

I think you mean the Payment Element, as the Card Element is legacy and won't work with stripe.confirmSetup, but want to be sure.

umbral haven
#

I do mean the Card Element

#

It seems to be going through as long as I'm in a browser that has an available payment method in the express checkout element ๐Ÿค”

hollow jungle
#

That's very unusual. Why are you using the Card Element instead of the Payment Element?

umbral haven
#

The Payment Element is too opinionated from a design perspective. I needed something more bare bones to match the designs I was given.

#

Is there a different element to collect card info that has less Stripe UI?

hollow jungle
#

Using the Card Element + the Address Element isn't a supported configuration and likely won't work as expected. I stronly recommend you switch to the Payment Element if possible.

#

No.

umbral haven
#

Thanks for the info!

hollow jungle
tacit mapleBOT
umbral haven
#

Can I just use the Card element and not the Address element? Or is the Card element obsolete?

hollow jungle
#

The Card Element is legacy and is not recommended. It still works standalone, but you should use the Payment Element when building a new integration.

#

If you do use the Card Element you can add your own fields for address info and pass that info in when you call the various Stripe.js APIs to confirm an Intent.

umbral haven
#

Ok. Any thoughts on the initial question of the possibility of unmounting specific elements that aren't being used?

hollow jungle
#

You shouldn't have to unmount them, it should just work, but I've never tried it with the Card Element in the mix like that.

#

What options are you passing to the Elements instance?

umbral haven
#
{
      mode: 'setup',
      currency: 'usd',
      paymentMethodTypes: ['card'],
      appearance: {
        theme: 'stripe',
        variables: {
          borderRadius: '8px',
          colorDanger: colors.red[70],
          colorIconCardError: colors.red[70],
          colorIconCardCvcError: colors.red[70],
          colorText: colors.gray[90],
          colorTextPlaceholder: colors.gray[60],
          fontLineHeight: '24px',
          fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
          fontSmooth: 'always',
          fontSizeBase: isMobile ? '16px' : '18px',
        },
        rules: {
          '.Input': {
            boxShadow: 'none',
          },
        },
      },
    }
  }
hollow jungle
#

And the error happens if you never interact with the Express Checkout Element?

#

Oh, wait.

#

I know what's happening.

umbral haven
hollow jungle
#

stripe.confirmSetup() is only designed to work with newer Elements, like the Express Checkout Element and Payment Element. Normally when you have both a Payment Element and Express Checkout Element stripe.confirmSetup() will use whichever of those has payment info it in, basically. However, you're using the Card Element, which stripe.confirmSetup() is not compatible with, so it can't "see" the Card Element at all. It only sees the Express Checkout Element, thinks it's the only way to possibly pay, and thus throws an error because you're not using it correctly for Express Checkout Element.

#

If you stick with the Card Element (which, again, I do not recommend) you should still use stripe.confirmSetup for the Express Checkout Element.

umbral haven
#

Makes sense. I just confirmed that I don't get the error when I'm in a browser with ExpressCheckout available payment methods because it's just always using ExpressCheckout ๐Ÿคฆโ€โ™‚๏ธ looks like I have my smoking gun (the Card element)

hollow jungle
#

Yep. You can make it work with the Card Element, I think, but the code will be more complex, it will be prone to unusual gotchas because it's not a recommended configuration, and will be more likely to break because you're mixing legacy and modern approaches in a single implementation.

umbral haven
#

Last question, if I do a dual setup with Payment+Address (or just Payment) and ExpressCheckout, how do I specify which element is being used in confirmSetup? Or should it know not to use ExpressCheckout if the other has user input?

hollow jungle
#

It should just know and work without you doing anything special.

umbral haven
#

Great, thanks. Appreciate all the help!