#ucjonathan_api

1 messages ยท Page 1 of 1 (latest)

opaque vineBOT
coral burrowBOT
#

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.

opaque vineBOT
#

๐Ÿ‘‹ 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/1240373643993809049

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

languid citrus
#

The client secret comes from either the Payment Intent or Setup Intent that you're initializing the Element with

#

It's an attribute on one of those objects

crude birch
#

I was told in the previous chat not to use a payment intent because then i wouldn't be able to update the total.

#

So right now I'm initializing the element using the optiosn object shown above.

languid citrus
#

What do you need the client secret for then?

crude birch
#

The JS API is kicking me for not passing it.

#

I'm insider of: expressCheckoutElement.on('confirm', function (event) {

#

Trying to confirm the payment with:
// call Stripe function to initiate payment confirmation
that.stripe.confirmPayment({
elements: that.elements,
confirmParams: {
return_url: handoffResponse.redirectToUrl,
},
}).then(function (result) {
if (result.error) {
// Inform the customer that there's an error.
window.widgetRuntimes.checkoutform.showErrors($checkoutForm, [result.error]);
}
});

coral burrowBOT
languid citrus
crude birch
#

OK, that is a whole additional level of back and forth with the server I don't have. I'll code that up.

tropic prairie
#

๐Ÿ‘‹ stepping in here. You would call your backend to create the PaymentIntent and then return its client secret just before confirmPayment()

#

Yep that

crude birch
#

I'm specifically working with Amazon Pay in this scenario

#

"Creating a ConfirmationToken isnโ€™t yet supported with PayPal or Amazon Pay."

#

What is the recommendation on how to do this with Amazon Pay?

#

Nevermind, I see it in the next section.

#

Thanks guys, I'll work on this now.

tropic prairie
#

Sure, let me know if you run into any issues

crude birch
tropic prairie
#

You are saying we should include in our code snippet an indicator that you can pass the selected payment type there?

crude birch
#

yes, that would be my recommendation or at least a comment that it's a good idea to pass that up to the server.

tropic prairie
#

Thanks for the feedback! I'll relay it internally

crude birch
#

When I initialize the element with this:

        const options = {
            mode: 'payment',
            paymentMethodTypes: ["amazon_pay"],
            amount: Math.round(window.cart.total * 100),
            currency: 'usd',
            // Customizable with appearance API.
            appearance: {/*...*/}
        };

That works. If I add link to that array so that it looks like:

        const options = {
            mode: 'payment',
            paymentMethodTypes: ["amazon_pay", "link"],
            amount: Math.round(window.cart.total * 100),
            currency: 'usd',
            // Customizable with appearance API.
            appearance: {/*...*/}
        };

Then the browser is showing the following error in the console:

#

If I omit the paymentMethodTypes property entirely, nothing initializes.

tropic prairie
#

Hmm

#

So only thing you are changing is the paymentMethodTypes array?

#

Is there somewhere I can visit to reproduce this?

#

Ah wait wait

#

Not as a PaymentMethodType

crude birch
#

So if I want the express checkout element to show amazon pay and link, waht would the options look like?

#

const options = {
mode: 'payment',
paymentMethodTypes: ["amazon_pay", "card"],
amount: Math.round(window.cart.total * 100),
currency: 'usd',
// Customizable with appearance API.
appearance: {/.../}
};
console.log("init stripe elements with options", options);
that.elements = that.stripe.elements(options);

        let expressCheckoutOptions = {
            paymentMethods: {
                amazonPay: 'auto',
                googlePay: 'never',
                applePay: 'never',
                link: 'auto',
                paypal: 'never'
            }
        }
        const expressCheckoutElement = that.elements.create('expressCheckout', expressCheckoutOptions);
#

@tropic prairie That code still doesn't get Link showing up. Not getting any type of console error, but also only getting the Amazon Pay button.

tropic prairie
#

Yeah the above is correct. Did you turn on Link in your Dashboard?

crude birch
#

Do I need to do that at my master account or in the individual merchant's account that is connected to mine?

tropic prairie
#

Are you initializing as the Connected Account here?

#

Like passing their account ID when you initialize Stripe.JS?

crude birch
#

correct, connect scenario

tropic prairie
crude birch
#

OK, changing to Link on by Default for connected accounts.

tropic prairie
#

Yep try that and test again

crude birch
#

OK so I made the change to enable Amazon Pay and Link by default on all accounts. I then removed the paymentmethods array so that it's just auto and relying on the suppression in the express checkout element options. That is now causing both buttons to appear.

tropic prairie
#

Sounds like it is working then ๐Ÿ™‚

crude birch
#

well I need to adjust so that I don't specify the payment_method_types on the payment intent now because that creates an error when automatic methods are being used. I'm very close.

tropic prairie
#

Yep if you are on a newer API version you can just remove payment_method_types. Otherwise you set automatic_payment_methods.enabled: true

crude birch
#

Let me just say this, I have 25 years of e-commerce development experience under my belt. I've probably implemented 50 different payment gateways and methods over the years. The way that Stripe does their developer support on Discord with knowledge and talented people like yourself is such a game changer compared to the rest of the industry.

tropic prairie
#

โค๏ธ