#mathersdis

1 messages · Page 1 of 1 (latest)

native canyonBOT
clever veldt
#

Hello, do you have the request ID from the time that you got that error? I don't see it in the request logs for that intent. I do see an attempt to confirm the intent after it was already confirmed but that would be a different error

finite blade
#

request ID on the log

#
        <script type="text/javascript">
            const options = {
                clientSecret: '{{$client_secret}}',
                // Fully customizable with appearance API.
                appearance: {/*...*/},
            };

            // Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in a previous step
            const elements = stripe.elements(options);

            // Create and mount the Payment Element
            const paymentElement = elements.create('payment');
            paymentElement.mount('#payment-element');


            const form = document.getElementById('payment-form');

            form.addEventListener('submit', async (event) => {
                event.preventDefault();

                const {error} = await stripe.confirmPayment({
                    //`Elements` instance that was used to create the Payment Element
                    elements,
                    redirect: "if_required",
                    confirmParams: {
                        return_url: 'http://174.138.34.46/fan-tip-redirect/'.{{$client_secret}},
                    },
                });

                if (error) {
                    // This point will only be reached if there is an immediate error when
                    // confirming the payment. Show error to your customer (for example, payment
                    // details incomplete)
                    const messageContainer = document.querySelector('#error-message');
                    messageContainer.textContent = error.message;
                } else {
                    window.location.href = paymentIntent.next_action.redirect_to_url.url;
                }
            });
        </script>
#

this is the code

clever veldt
#

Request IDs have the form of req_123, don't see one in that log unfortunately

finite blade
#

it keeps returning this error on the consoleUncaught (in promise) FetchError: Error fetching https://r.stripe.com/0: Failed to fetch at shared-b4712083e4ada6035c906f177adc5ed6.js:1:164692 (anonymous) @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 Promise.catch (async) (anonymous) @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 e @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 l @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 request @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 value @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 (anonymous) @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 value @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 value @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 (anonymous) @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 Promise.then (async) value @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 e @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 (anonymous) @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 (anonymous) @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 352 @ shared-b4712083e4ada6035c906f177adc5ed6.js:1 e @ controller-57a8934a237c98a8a7b360d194ee58f4.js:1 92495 @ controller-57a8934a237c98a8a7b360d194ee58f4.js:1 e @ controller-57a8934a237c98a8a7b360d194ee58f4.js:1 (anonymous) @ controller-57a8934a237c98a8a7b360d194ee58f4.js:1 e.O @ controller-57a8934a237c98a8a7b360d194ee58f4.js:1 (anonymous) @ controller-57a8934a237c98a8a7b360d194ee58f4.js:1 (anonymous) @ controller-57a8934a237c98a8a7b360d194ee58f4.js:1 q.stripe.com/csp-report:1 POST https://q.stripe.com/csp-report net::ERR_CONNECTION_TIMED_OUT

clever veldt
#

r.stripe.com is the URL for our telemetry, that error can be ignored though we make sure to catch and fix those so that we don't pollute your dev console

#

Similar story for q.stripe.com

#

I'd like to know more about the processing error Does it happen every time? Can you consistently reproduce it with certain steps otherwise?

finite blade
clever veldt
#

Are there steps other than that?

finite blade
#

then the js script above there

#

this is the first reponse i get when i click submit fan-tip-member-stripe:357 Uncaught (in promise) ReferenceError: paymentIntent is not defined at HTMLFormElement.<anonymous> (fan-tip-member-stripe:357:44)

clever veldt
#

I am a bit confused because we seem to be seeing three separate errors here:

  1. paymentIntent is not defined
  2. processing error occurred
  3. Double confirming an intent
    As well as successful confirmations seemingly also from stripe.js. So I'm not clear on what might be happening that is different between each error scenario and the success
finite blade
#

its when i click the submit button again that i get the logs i sent the first time

#

payment intent is not defined is the first error i get

#

its when i click the button for it to persist

clever veldt
#

gotcha, thanks for the info. Looking in to what causes these errors and will get back to you

finite blade
#

i tested the payment intent client secret and it is passing it so its valid

clever veldt
#

It looks like "paymentIntent is not defined" is an error from your code trying to say that the paymentIntent object does not exist. I am guessing that that is for the paymentIntent.next_action.redirect_to_url.url line as I don't see the paymentIntent object being set before that

#

One sec, looking up how to get the intent back from that confirm call

finite blade
#

alright thanks

clever veldt
#

I think you want to do const {error, paymentIntent} = await stripe.confirmPayment....

#

that call should be what is returning the paymentIntent object but unless you create the variable it doesn't know to extract that from what the confirm call returns

finite blade
#

ok sure let me do that and test

native canyonBOT
finite blade
#

didnt work regardless

clever veldt
#

Interesting. I get a PaymentIntent back when I run very similar code

      elements,
      redirect: 'if_required',
      confirmParams: {
        return_url: 'https://example.com/order/123/complete',
      },
    });
    const messageContainer = document.querySelector('#error-message');
    if (error) {
      console.log(error);
    } else {
      console.log(JSON.stringify(paymentIntent));
    }```
#

Did you double check that the client-side code updated to reflect the new code changes that you made?

finite blade
#

sure

#

let me do that

#

i am not getting the payment form anymore

clever veldt
#

Is there an error in the console? It sounds like there may be a javascript compilation error that is preventing js across the whole page from running properly

native canyonBOT
finite blade
#

maybe the ip lacking https

#

alright some progress

#

it seems to log the json of the payment intent to the console

#

ideally it is meant to redirect to the return url

clever veldt
#

Your original code has redirect: "if_required",, you can set it to redirect: "always", if you always want it to redirect

finite blade
finite blade
clever veldt
#

This redirect is to the URL that you specify as the return_url, should be fine as long as you are directing to a URL that you trust.

finite blade
#

let me test it

finite blade
#

it has worked

#

but returns missing client secret required when trying to retrieve the payment intent

#

$paymentIntent = $stripe->paymentIntents->retrieve($clientSecret);

#

$stripe = new \Stripe\StripeClient(env('STRIPE_PUBLISHABLE_KEY'));

#

i reviewed and made sure the client secret variable is pulling from the db

stone bone
#

Hi 👋