#blagi.connecto

1 messages ยท Page 1 of 1 (latest)

merry sirenBOT
cerulean owl
#

Hello @subtle tangle , let's keep your details all in this thread

#

Is it possible to remove Google Pay popup window after clicking pay so an error can be displayed after confirmPayment?

#

I am not sure I understand your question, can you send me a screenshot of the popup? And what is the error that you are trying to display?

subtle tangle
#

I'm getting error on confirmPayment and I'd like to display it without Google Pay pop-up window.

cerulean owl
#

Interesting. I am surprised that the window is not disappearing before then. Are you using the Payment Request Button here? Or is google pay getting launched from our Payment Element?

subtle tangle
#

Hi Pompey, thanks for helping me.
It's launched from Payment Element.

cerulean owl
#

Can you show me your payment method code for confirming your intent?

#

And what is the error message that you are getting back?

subtle tangle
#

` async function confirmPayment(clientSecret, returnUrl, countryCode) {
const { error } = await stripe.confirmPayment({
elements,
clientSecret,
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.");
            if (typeof log_message_to_server === "function") {
                log_message_to_server('response for potvrda_initialize_transaction error');
            }
        }
    }

`
ShowMessage is from some of your's example samples.

cerulean owl
#

Interesting, and when you get this error, the confirmPayment function has returned but the google pay sheet it still up?

subtle tangle
#

Yap.

#

User has to click somewhere to close it. If everything is ok it's just another url.

cerulean owl
#

And what is the error that you are getting?

#

Can you paste the full text of the error here?

#

Can you reproduce this on your website in test mode?

subtle tangle
#

I solved that error, but want to used is as a test case for error displaying. It's:

The provided capture_method (manual) does not match the expected capture_method (automatic). Try confirming with a Payment Intent that is configured to use the same parameters as Stripe Elements

cerulean owl
#

Gotcha, will try to reproduce that error and will get back to you

subtle tangle
#

Ok.

cerulean owl
#

For me, the google pay sheet is closed before the confirm call is called so I am not getting that error

#

Can you send me your client side code for setting up the payment element and confirming your intent?

subtle tangle
#

I'm calling this method on submit:
` paymentOnSubmit: async function (type, transfer_json, callback) {
let stripeResponse = null;
const {error: submitError} = await elements.submit();
if (submitError) {
handleError(submitError);
return;
}
if (type === 'transfer_confirmation') {
stripeResponse = await transferConfirmationPaymentOnSubmit(transfer_json);
} else if (type === 'transfer_booking') {
stripeResponse = await transferBookingPaymentOnSubmit(callback);
}

            if(stripeResponse.hasOwnProperty('return_url') && stripeResponse.return_url.length > 0) {
                await confirmPayment(stripeResponse.stripe_client_secret, stripeResponse.return_url, stripeResponse.country_code);
            } else {
                console.log('response for potvrda_initialize_transaction error');
                if (typeof log_message_to_server === "function") {
                    log_message_to_server('response for potvrda_initialize_transaction error');
                }  
            }           
        },`
#

After elements.submit() I'm calling our code for submitting data to server and is' returning return_url and creates payment intent/client secret for confirmPayment

#

It's ajax call to server.

merry sirenBOT
subtle tangle
#

...

inland bluff
#

๐Ÿ‘‹ Give me a moment to take a look
Server is a bit busy

subtle tangle
#

Ok. Thanks hanzo for dive in.

inland bluff
#

Is this a livemode PaymentIntent you're working with?

#

In the screenshot?

subtle tangle
#

No it's a paymentElement. Tabs with a Card and Google pay tabs, clicked on Google Pay button. PaymentIntent is creating just before confirmPayment.

inland bluff
#

I get that but is the PaymentIntent getting created with live mode API keys or test mode?

subtle tangle
#

It's in Croatian language, I can provide to you an English version

inland bluff
#

Can you share the PaymentIntent ID?
It should look something like pi_xxx

subtle tangle
#

test mode.

inland bluff
#

Can you share the PaymentIntent ID?

subtle tangle
#

Thin it's this one: pi_3NIAcjHyMHmjD7NO0LIoI75S

#

It was created more than an hour ago.

#

Request: req_ibzwghyPnynsIo

inland bluff
#

Can you share the code you're using to initialize PaymentElement?

subtle tangle
#

async function initialize(amount) { if (amount == 0) { return false; } const options = { mode: 'payment', amount: amount, //capture_method: 'manual', currency: 'eur', }; elements = stripe.elements(options); const paymentElementOptions = { layout: "tabs", fields: { billingDetails: { address: { country: 'never', } } } }; const paymentElement = elements.create("payment", paymentElementOptions); paymentElement.mount(config.payment_element_id); paymentElement.on('change', function(event) { document.getElementById(config.payment_element_complete_id).value = event.complete ? 1 : 0; }); }

#

Comment capture_method to test error displaying.

inland bluff
#

If you take out the capture_method, does the flow work as expected?

subtle tangle
#

Yes, payment confirmed and redirected to return_url

#

I'd like to have some kind of method for closing Google Pay pop-up. ๐Ÿ™‚

inland bluff
#

Hmm we don't have a specific method to override Google Pay modal behaviour as it's mostly controlled by Google once the modal is shown

#

Is this page live?

#

If so, would you mind sharing a URL?

subtle tangle
#

Not yet. Should go live in a couple of days, probably at Monday. Red line with Stripe payment is working just have to test handling errors and unusual situations.

#

Looks like you are out of suggestions while in test. I can finish all other parts, test and will contact support when everything goes live.

inland bluff
#

yeah this is quite unusual. After confirmPayment call, the modal should dismiss automatically as Pompey mentioned earlier.
They weren't able to reproduce this behaviour either so looking at an example would help

subtle tangle
#

Ok. Thanks guys for now