#ucjonathan_api
1 messages ยท Page 1 of 1 (latest)
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.
- ucjonathan_api, 1 hour ago, 30 messages
๐ 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.
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
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.
What do you need the client secret for then?
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]);
}
});
Right, have you been following this guide to get setup with that?
https://docs.stripe.com/elements/express-checkout-element/accept-a-payment
If so, can elaborate on why Payment Intents don't work for your use-case?
OK, that is a whole additional level of back and forth with the server I don't have. I'll code that up.
๐ stepping in here. You would call your backend to create the PaymentIntent and then return its client secret just before confirmPayment()
Yep that
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.
Sure, let me know if you run into any issues
You are saying we should include in our code snippet an indicator that you can pass the selected payment type there?
yes, that would be my recommendation or at least a comment that it's a good idea to pass that up to the server.
Thanks for the feedback! I'll relay it internally
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.
Hmm
So only thing you are changing is the paymentMethodTypes array?
Is there somewhere I can visit to reproduce this?
Ah wait wait
You control Link via the wallet property: https://docs.stripe.com/js/elements_object/create_express_checkout_element#express_checkout_element_create-options-wallets
Not as a PaymentMethodType
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.
Yeah the above is correct. Did you turn on Link in your Dashboard?
Do I need to do that at my master account or in the individual merchant's account that is connected to mine?
Are you initializing as the Connected Account here?
Like passing their account ID when you initialize Stripe.JS?
correct, connect scenario
Then you want to check in your Dashboard at: https://dashboard.stripe.com/test/settings/payment_methods/connected_accounts
OK, changing to Link on by Default for connected accounts.
Yep try that and test again
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.
Sounds like it is working then ๐
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.
Yep if you are on a newer API version you can just remove payment_method_types. Otherwise you set automatic_payment_methods.enabled: true
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.
โค๏ธ