#mathersdis
1 messages · Page 1 of 1 (latest)
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
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
Request IDs have the form of req_123, don't see one in that log unfortunately
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
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?
yes i can reproduce it, so i create a payment intent then getting the client secret and passing it to the payment element form
Are there steps other than that?
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)
I am a bit confused because we seem to be seeing three separate errors here:
- paymentIntent is not defined
- processing error occurred
- 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
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
gotcha, thanks for the info. Looking in to what causes these errors and will get back to you
awesome thanks
i tested the payment intent client secret and it is passing it so its valid
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
alright thanks
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
ok sure let me do that and test
didnt work regardless
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?
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
yes i think so as well
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
Your original code has redirect: "if_required",, you can set it to redirect: "always", if you always want it to redirect
And then on the new page you can retrieve the intent if you want to display info from it https://stripe.com/docs/js/payment_intents/retrieve_payment_intent
is setting it to always advisable security wise?
yes i have written the code for handling it thats where the return url led to
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.
awesome thanks mate
let me test it
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
Hi 👋