#krs_api

1 messages ¡ Page 1 of 1 (latest)

sinful yewBOT
#

👋 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/1263751371702931476

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

rigid lichen
#

hello! Maybe can you share why you are looking to use confirmation tokens with SetupIntents?

ripe horizon
#

When the user inputs the card details, we need to find the funding type of the card (like credit or debit card), when we use confirmation token api, the response has the funding information of the payment method.

#

And we use the SetupIntent to create the payment method and save the payment method id in our platform.

#

Since the elements is pased in confirmSetup api, and also confirmation token API, we are exploaring if we can pass the elements via confirmation token and use the token with confirmSetup, instead of passing elements on both instances.

rigid lichen
#

Sorry, I'm quite confused here - generally, you need to find the funding of the card before you accept payment. In the case of a SetupIntent, you're saving the card for future use, not accepting payment yet. Once the SetupIntent is confirmed, you would have the PaymentMethod and can examine it to know the funding type

ripe horizon
#

We have a screen to show the processing fees at the time of card input, so we wanted to show processing fees based on cards, before we proceed further.

#

if we are able to get the fudding directly from the stripe JS, then it would reduce the number of API calls and makes the processing faster.

#

Is there a option to examine the PaymentMethod via StripeJS itself (with public stripe API key)?

rigid lichen
#

hrm, i see. To answer your question, the SetupIntent does accept a confirmation token : https://docs.stripe.com/api/setup_intents/create#create_setup_intent-confirmation_token

If you want to examine the PaymentMethod from the frontend, I suggest that you also look into the deferred flow :

Build an integration where you can render the Payment Element prior to creating a PaymentIntent or SetupIntent.

Build an integration where you can render the Payment Element prior to creating a PaymentIntent or SetupIntent.

ripe horizon
rigid lichen
#

in the confirmation token, i don't see you defining the data to be prefetched?

ripe horizon
#

do you have an example on how i should pass that?

#
        payment_method_types=["card", "us_bank_account"],
        payment_method_options={
            "us_bank_account": {
                "financial_connections": {
                    "permissions": ["payment_method", "balances"],
                    "prefetch": ["balances"],
                },
                "verification_method": "instant",
            },
        },
        confirm=False
    )
rigid lichen
#

i'm guessing that you're initializing elements with an options object right?

ripe horizon
#

this is how we create the setup intent and pass the client secret to frontend

rigid lichen
#

so generally, on the frontend, you should have something like

const options = {
    mode: 'setup',
    paymentMethodCreation: 'manual',
    ...
  };
#

right?

you should include the prefetch parameter in there too

ripe horizon
#
      clientSecret: clientSecret,
      redirect: 'if_required',
      confirmParams: {
        confirmation_token: id,
      },
    });
  };```
#

this is how our confirm setup in the frontend is..

rigid lichen
#

well, the id for the confirmation_token has to come from somewhere - look for something like stripe.createConfirmationToken in your code

ripe horizon
#
      elements,
      params: {
        payment_method_data: {
          billing_details: {
            address: {
              country: 'US',
            },
          },
        },
      },
    });
const { id = '' } = confirmationToken || {}
#

this is how the confirmation token id is created

rigid lichen
#

can you find that?

ripe horizon
#

checking..

#

found that options and it is mssing prefetch, after adding that, it worked fine. Thanks a lot for your expertise.