#unechtemoritz
1 messages · Page 1 of 1 (latest)
I mean, I use google pay as a method, for example, how should I specify it separately?
how should I specify it separately
Can you clarify what you mean by that?
The error says, "You cannot confirm this PaymentIntent because it is missing a payment method"
But how do I pass it?
I use Googlepay as a method, so I don't have an ID?
Have you implemented the confirm event handler on the express checkout element, or how are you calling confirmPayment?
https://docs.stripe.com/elements/express-checkout-element/accept-a-payment#submit-the-payment
expressCheckoutElement.on('confirm', ...)
I have the code,
"createFastOrder" creates a paymentintent,
const stripeElements = stripe.elements({
mode: 'payment',
amount: 1049,
currency: 'eur',
});
var expressCheckoutElement = stripeElements.create('expressCheckout', {
layout: {
maxRows: 0,
overflow: 'never',
}
});
expressCheckoutElement.mount('#payment-request-button')
expressCheckoutElement.on('confirm', function(event) {
createFastOrder(event)
});```
when this is created, it is passed here:
```js
stripe.confirmPayment({
stripeElements,
clientSecret,
confirmParams: {
return_url: return_url,
},
})
.then(function(result) {
if (result.error) {
console.log(result.error);
}
});
Are you missing the call to elements.submit();? I don't see that anywhere and is necessary for the wallet UI completion
Ok cool, give that a try and see if it works once added
expressCheckoutElement.on('confirm', async function (event) {
const {error: submitError} = await stripeElements.submit();
if (submitError) {
console.log(submitError);
return;
}
createFastOrder(event)
});
Is that right? the same error still occurs
i dont know, how many access you have:
req_9Q2XUC6wIDBMdJ
pi_3OkBlrJrlBOQbHzo0XleJnno
:/
Are you able to try putting the await stripe.confirmPayment() call directly in the confirm event handler?
I wonder if there's an async/await issue where your calls are letting the confirm event complete before you call confirmPayment
(instead of blocking with await)
yea, i can try it, but then i have to rebuild it so that it only gives me a payment intent secret without all the other logic.
gimme a minute
const stripe = Stripe(stripePublicKey, {
apiVersion: "2023-10-16",
});
const stripeElements = stripe.elements({
mode: 'payment',
amount: 100,
currency: 'eur',
});
var expressCheckoutElement = stripeElements.create('expressCheckout', {
layout: {
maxRows: 0,
overflow: 'never',
}
});
expressCheckoutElement.mount('#payment-request-button')
const handleError = (error) => {
console.error(error);
}
expressCheckoutElement.on('confirm', async (event) => {
const {error: submitError} = await stripeElements.submit();
if (submitError) {
handleError(submitError);
return;
}
// Create the PaymentIntent and obtain clientSecret
const res = await fetch("/stripe-test", {
method: 'POST',
});
const {client_secret: clientSecret} = await res.json();
const {error} = await stripe.confirmPayment({
// `elements` instance used to create the Express Checkout Element
stripeElements,
// `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)
handleError(error);
} else {
// The payment UI automatically closes with a success animation.
// Your customer is redirected to your `return_url`.
}
});```
still same error.
req_qe3xyu7C7AIiap
found this in the console, maybe, because that?
WORKS! Thanks :)
🙌