#cho_ece-setup

1 messages ยท Page 1 of 1 (latest)

long vesselBOT
weak heartBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

long vesselBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1254867414462632041

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

hidden estuary
#

The other code I use is :

stripe
        .confirmCardSetup(clientSecret, {
            payment_method: {
                card: elements.getElement(CardElement)!,
                billing_details: {
                    address: {
                        line1: addressLineOne,
                        line2: addressLineTwo,
                        city: city,
                        state: stateAddress,
                        postal_code: zip,
                        country: 'US',
                    },
                    name: name,
                },
            },
        })
        .then(async function (result) { ... }
tall crater
hidden estuary
#

okay, thank you. let me inspect this and see ๐Ÿ‘

tall crater
#

cho_ece-setup

hidden estuary
#

general quesiton, what does the

#

const {error: submitError} = await elements.submit();
if (submitError) {
setErrorMessage(submitError.message);
return;
}

code "do" exactly? Beacuse it doesn't seem to complete the payment intent

tall crater
hidden estuary
#

oh I see

long vesselBOT
hidden estuary
#

as you can see from my other code instance, I need to NOT redirect the customer after the setup intent is complete or delay the redirect until other async functions have resolved. In this code block from your example:

// Confirm the PaymentIntent using the details collected by the Express Checkout Element
const {error} = await stripe.confirmPayment({
  // `elements` instance used to create the Express Checkout Element
  elements,
  // `clientSecret` from the created PaymentIntent
  clientSecret,
  confirmParams: {
    return_url: 'https://example.com/order/123/complete',
  },
});

if (error) {
  // This point is only reached if there's an immediate error when
  // confirming the payment. Show the error to your customer (for example, payment details incomplete)
  setErrorMessage(error.message);
} else {
  // The payment UI automatically closes with a success animation.
  // Your customer is redirected to your `return_url`.
}

};

it redirects after the else block, will I be able to trigger other functions or prevent the action?

foggy bloom
#

HI ๐Ÿ‘‹

My colleaguea needed to step away so I'm taking over.

The code in the else block doesn't do anything here. Sorry but it's hard to understand what you are trying to do here

hidden estuary
#

Okay, I'll sum it up in a quick sentence

#

I want to implement apple pay into my app. I have a system already set up to accept cards and complete setup intents.

#

I am using express checkout element to try and complete setup intents, but the function 'stripe.confirmCardSetup' and 'stripe.confirmSetup' have totally different behaviors

#

Specific question:
Am I able to do in the same way that I do :

stripe
.confirmCardSetup(clientSecret, {
payment_method: {
card: elements.getElement(CardElement)!,
billing_details: {
address: {
line1: addressLineOne,
line2: addressLineTwo,
city: city,
state: stateAddress,
postal_code: zip,
country: 'US',
},
name: name,
},
},
})
.then(async function (result) { ...

==============

For the express checkout element's confirmSetup?

Speficially doing the .then(async function (result) { ...

foggy bloom
#

Yeah, one is specific to Card payment methods and the other isn't

hidden estuary
#

I don't just need to complete the setup intent, I need to save that wallet as their default payment method, and then on success trigger some API calls to my own api

#

The issue for me here is that the function confirmCardSetup has a returned result, but confirmSetup doesn't

#

oh, here, correct me if im wrong...
I can achieve the same result by setting if_required = false in which case this function then returns a setupIntent object

QQ is apple_pay one of these if_required possible values? Or is that something I set myself entirely?

foggy bloom
#

Sorry, what if_required parameter are you referring to here?

#

Oh you mean the redirect='if_required'

hidden estuary
#

oh, yes I misread it and realized that too my bad

foggy bloom
#

Apple Pay renders a modal over the top of the web page where the ECE is mounted. It's not a full redirect.

As for setting the payment method as the default, I recommend listening to the webhook event setup_intent.succeeded https://docs.stripe.com/api/events/types#event_types-setup_intent.succeeded. That will contain the ID of the Customer and the newly created Payment Method so you can use both to update Customer and specify the new payment method as the default:
https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-default_payment_method

hidden estuary
#

ty ty

#

The code was identical for me so long as I had access to the setupIntent object from the Promise

#

Tysm

#

could you help me with one last thing

#

What would be the consequences if I forgot to do the elements.submit before confirmCardSetup?

#

Because I don't do that right now, and it's been working just fine

foggy bloom
#

It may catch errors that would otherwise be hard to track down

hidden estuary
#

ohhh I see now

#

yeah I was doing that wrong ๐Ÿ˜‚

#

Hopefully we'll have less payment failures now

foggy bloom
#

Great. I hope it helps your integration run more smoothly ๐Ÿ™‚

hidden estuary
#

ty ty

#

So I'm trying to convince my boss

#

that we need to do the elements.submit

#

but it isn't enough for me to say it's just validation

#

So can you help me with what it does and the implications ๐Ÿ˜ญ

foggy bloom
#

Sorry but the info I have is in our docs. It seems really lightweight in terms of adding new code so I don't get the resistance:

Before confirming a payment, call elements.submit() to validate the form fields and collect any data required for wallets.

This method returns a Promise which resolves with a result object. If this method succeeds, the result object will be empty. If this method fails, the result object will contain a localized error message in the error.message field.

I would think getting a localized error message you could display to your customers would be helpful in this case.

hidden estuary
#

ohh okay, I see

#

thank you

foggy bloom
#

I hope they see the utility of catching errors sooner rather than later!