#blagi.connecto

1 messages · Page 1 of 1 (latest)

molten foxBOT
gaunt gust
#

You need to add a button to your UI that calls confirmPayment from Stripe.js, like in step 3 of that guide

#

Then then you call that, and the Google Pay tab is selcted, then the dialog will appear

dry jungle
#

I have that button. When the card is chosen and card details are entered the validation started with that button should passed if everything is ok, but for a Google Pay chosen I had to know that is a Google pay is chosen to pass validation. Is there such an information available?

gaunt gust
#

I'm sorry I don't understand what you're asking me

dry jungle
#

after pressing that button a validation is started. Including checking of card data. But when a Google Pay button is pressed I should know that Google Pay is chosen payment method and to pass without validating.

gaunt gust
#

Correct yes, we wouldn't validate any of the form fields we'd just open the Google Pay dialog

dry jungle
#

Is there some methos or property of Stripe object that has info about google pay buton state?

gaunt gust
#

Specifically what state are you trying to check? What are you trying to do?

dry jungle
#

Just to know that Google Pay is chosen payment method.

gaunt gust
dry jungle
#

I started confirmPayment but this appears n cosole:
Uncaught DOMException: Failed to execute 'postMessage' on 'Window': Delegation is not allowed without transient user activation.
at l (https://js.stripe.com/v3/?202305251330:1:102286)
at t.value (https://js.stripe.com/v3/?202305251330:1:33250)
at t.value (https://js.stripe.com/v3/?202305251330:1:32685)
at e.show (https://js.stripe.com/v3/?202305251330:1:152893)
at t.<anonymous> (https://js.stripe.com/v3/?202305251330:1:190131)
at t.show (https://js.stripe.com/v3/?202305251330:1:59377)
at https://js.stripe.com/v3/?202305251330:1:241595
at https://js.stripe.com/v3/?202305251330:1:54934
at Array.forEach (<anonymous>)
at t._emit (https://js.stripe.com/v3/?202305251330:1:54677)

gaunt gust
#

What is the code you used?

molten foxBOT
dry jungle
#

` confirmPayment: async function(returnUrl, countryCode) {
const { error } = await stripe.confirmPayment({
elements,
confirmParams: {
return_url: returnUrl,
payment_method_data: {
billing_details: {
address: {
country: countryCode,
}
},
},
},
});

            // This point will only be reached if there is an immediate error when
            // confirming the payment. Otherwise, your customer will be redirected to
            // your `return_url`. For some payment methods like iDEAL, your customer will
            // be redirected to an intermediate site first to authorize the payment, then
            // redirected to the `return_url`.
            if (error.type === "card_error" || error.type === "validation_error") {
                showMessage(error.message);
            } else {
                showMessage("An unexpected error occurred.");
            }
        }`
storm sail
#

we need to see the context that confirmPayment is called from

#

that error means that you're not calling the function in response to an event like button press or a form submit, which is required

dry jungle
#

$.ajax({ async: false, type: 'POST', url: url, data: jsonData, dataType: 'JSON', success: function(rezervacija) { if (rezervacija.hasOwnProperty('return_url') && rezervacija.return_url.length > 0) { stripePaymentElements.confirmPayment(rezervacija.return_url, rezervacija.country_code); } }, error: function(err) { console.log('error'); } });

storm sail
#

yes, that's the problem, you can't call this from a callback of an Ajax request like this. It has to be done directly from a button press event handler/form submit action.

dry jungle
#

Um, I had to retrieve return_url and country_code. 😦
If I eliminate ajax call it should work?

storm sail
#

the idea is you would call the backend and create the PaymentIntent before you show the PaymentIntent and then you can call confirmPayment immediately when the button is pressed).

#

(that's why in the sample code it's done in an initialize function at the start)

dry jungle
#

Ok thanks! I had to change a flow.