#bwurtz999
1 messages · Page 1 of 1 (latest)
Hi
Could you please five more details ? what you want to achieve exactly and/or what part of your code is generating this ?
I'm trying to generate a connection token with the JS SDK
async function fetchConnectionToken() {
// Your backend should call /v1/terminal/connection_tokens and return the JSON response from Stripe
const response = await fetch("{{ route('location-stripe-connection') }}?useCaseId={{ $useCaseId }}&organizationId={{ $organization_id }}&locationId={{ $location_id }}", { method: "POST" });
console.log(response);
try {
const data = await response.json();
} catch(error) {
console.log(error);
handleCardReaderError();
}
return data.secret;
}
I'm using the fecthConnectionToken syntax provided by the docs
Thanks for these details, I assume you are following this guide so ?
https://stripe.com/docs/terminal/payments/setup-integration?terminal-sdk-platform=js#connection-token-client-side
Yes
I haven't changed this since I initially got it working. And now it's throwing an error
This call is made in your frontend right?
Yes
you have a backend endpoint that call /v1/terminal/connection_tokens API ?
Yes
that is working fine
both locally and in production
I've verified that
But for some reason on my checkout page the request fails
onFetchConnectionToken failure. Please make sure your function creates a new connection token via your backend
Is this a response from Stripe API or your frontend is formatting this ?
do you have a failing API request Id?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
That's from Stripe
No I don't have a failed request ID. The request is never even reaching my API. But when I copy the request URL and run it externally using Insomnia it works as expected and creates the token
The request is never even reaching my API
You mean the call from your frontend to your own backend is not sent ?
It attempts to send... but it generates an error
That's from Stripe
No I don't have a failed request ID
I'm a bit confused, if it's a response from an API Stripe call, you should have an API call
But you can see in the screenshot the actual API endpoint is working fine
could you make a screenshot where you are seeing the error message please ?
Ok so your function fetchConnectionToken isn't reaching to your backend in order to fetch the token
Correct
try calling/debugging your js function fetchConnectionToken outside of StripeTerminal.create and see if it calls your backend correctly or not from your frontend
Make sure there is no middleware between your frontend and backend that is causing the redirection somhow
It looks like you changed something in your integration that breaks the calls from your frontend to your backend... it has no link with Stripe as far as I can see
because the function fetchConnectionToken can't reachout to you own backend not to Stripe APIs... and when you call the endpoint using Insomnia it works... it must be something between your frontend and backend which is causing
are you having this in the same machine? e.g. your local environment where you run your both backend and frontend on the same machine ?
The middleware... wow
Yeah I did change that. I completely missed that
That's definitely the problem
I think so too
Thank you thank you
It's always so helpful to chat with someone about what's going on
You're welcome!