#ganesh-gawali_ttp-confirm-error
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1467896894687805501
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- ganesh-gawali_error, 6 days ago, 7 messages
Hi there. It sounds like there may be an issue in fetching your connection token. Have you traced the code to make sure that's being fetched properly?
Recommend using the quickstart app as a starting point and modifying to your needs
our backend server is fetching the connection token and as per stripes document we have implemented the connection token code using backend API.
this is the response of that API - {"data":{"status":1,"token":"pst_test_YWNjdF8xUXMxQldFeFlDT1B4R0F6LHhLYVU2akVKam5XR2h3eTY0eWduUkdTVkRNMkhuRHU_00acw9V0VV","message":"Success"}}
This is out code for connectionToken - const fetchTokenProvider = async () => {
try {
const response = await fetch(
'API-URL',
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}
);
const data = await response.json();
return data?.data?.token;
} catch (error) {
console.error('๐จ Fetch error:', error);
return null;
}
};
export default function Navigation() {
return (
<StripeTerminalProvider
logLevel="verbose"
tokenProvider={fetchTokenProvider}>
<NavigationContainer
ref={ref => NavigationService.setTopLevelNavigator(ref)}
onReady={NavigationService.onNavigationContainerReady}
>
<MainStack.Navigator initialRouteName={NavigationStack.APP_STACK}>
<MainStack.Screen
name={NavigationStack.APP_STACK}
component={AppNavigator}
options={{ headerShown: false }}
/>
</MainStack.Navigator>
</NavigationContainer>
</StripeTerminalProvider >
);
}
Hm not sure then
Can you share the rest of the code?
And are you working off of our quickstart?
Curious what guide you followed
yes can
share the code
TERMINAL INITILISATION :
const requestPermissions = async () => {
try {
const granted = await requestNeededAndroidPermissions({
accessFineLocation: {
title: t('locationPermission'),
message: t('thePaymentProcessorRequiresAccessToYourLocationPleaseClickTheAcceptButtonToContinue'),
buttonPositive: t('accept'),
},
});
if (granted) {
initStripeSDK();
} else {
console.error(
'Location and BT services are required to connect to a reader.'
);
}
} catch (e) {
console.error("error", e);
}
}
async function initStripeSDK() {
const res = await initialize();
const response = await getLocationId();
// var finalLocationId = locationId?.current ? locationId?.current : response?.id;
var finalLocationId = persistedLocationId || locationId?.current || response?.id;
locationId.current = response?.id;
dispatch(setLocationId(finalLocationId));
}
useEffect(() => {
if (Platform.OS == 'android') {
// enable when work on tap to pay
requestPermissions();
} else {
initStripeSDK();
}
}, [NavigationService]);
Can you also share the bit around collecting payment method and confirming
Hey there, also looking at this with my teammate. What step is this failing on, exactly? At initialization or confirm time?
Have you inspected to verify that your fetchTokenProvider is exiting on the happy happy with the token returned, or if its being invoked multiple times?
yes fetchTokenProvider is being invoke multiple times
1st it gets initialize before the terminal gets initialized
and after during connting state
Hmm I don't think it should be calling multiple times, right?
It seems like your React component tree might be re-rendering/remounting and losing the provider state, possibly
the fetchTokenProvider code is as per this doc https://docs.stripe.com/terminal/payments/setup-integration?terminal-sdk-platform=react-native
is there something that we are missing
?
I don;'t know what your Navigation and MainStack components are doing, but I see the initialize call that I assume from from useStripeTerminal inside the provider.
Can you speak to this? When is the failure happening?
And, can you share an exact timestamp of one of these examples, and the source IP address it would be coming from?
and IP address?
yea thats private, i need the public external address that our API would see the request coming from when it leaves your network
Hi ๐
I'm stepping in as my colleagues had to go
I'm sorry to report that you will not be able to test and validate Stripe Tap to Pay from the IP address you provided. It is geolocatd in India and that is not a supported country per our docs
I'm double checking but I think the geolocation of the IP address is used to determine if the action is happening in a region we support
So the location used when creating the Location object would not matter
I think that would not be the case because we also have another app which is implemented in Android native code and that is working fine
We also checked out to 2 weeks old commit of our React Native code and surprisingly, tap to pay in that code is working
That seems to imply there was a code change that broke the confirmation flow.
Was there a version change in the Stripe RN SDK?
no version change
So what exactly changed between the working commit and the current broken app?
Okay but let's ignore whether it's Stripe related or not
the code I shared here is the same one we have
It seems pretty clear that something happened between that commit and the current state
Also it appears that the Stripe logic is wrapped up in your component tree/navigation logic and that could still be impacting what is going on
what is the solution that you suggest?
That you carefully review the code changes between the working commit and the current state. Implement each change carefully and test whether Tap to Pay works after each one. Once it stops working you will need to review the code changes that caused it to break.
I do understand what you are saying cause we did the same thing over and over again since last 4 days
there was no change on stripe code
Ignore whether or not it's "Stripe code"
It's clear that
- if it worked 2 weeks ago
- And it's not working now
- And the SDK wasn't changed
then a code change that "seems" unrelated caused the issue.
tell me one thing
fetchTokenProvider is getting called multiple times
is that the root cause
Not from what I can tell. The payment intent confirm calls appear to be missing the API key
okay.
this the confirmPaymentIntent code - async function confirmThePaymentFromStripe(updatedPaymentIntent) {
const { paymentIntent, error } = await confirmPaymentIntent({
paymentIntent: updatedPaymentIntent,
});
console.log("5. paymentIntent : ", paymentIntent)
if (error) {
console.log("5. Error : ", error)
setIsLoading(false);
return;
}
setError(null);
const donationDetails = {
amount: selectedDonationAmt,
currency: donationData?.currencyData?.currencySymbol,
donationTypeName: donationPayload?.donationTypeName,
}
}
this is calling the internal method of stripe right?
Yes that is calling the Stripe internal method but that depends on your Terminal instance having the correct API key loaded. There is nothing in that code specifically about the API key (which is missing for your requests)