#ganesh-gawali_ttp-confirm-error

1 messages ยท Page 1 of 1 (latest)

coarse wigeonBOT
#

๐Ÿ‘‹ 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.

fervent orchid
#

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

hallow musk
#

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 >
);

}

fervent orchid
#

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

hallow musk
#

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]);
fervent orchid
#

Can you also share the bit around collecting payment method and confirming

hallow musk
#

yes

#

Here is the rest of the code

velvet beacon
#

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?

hallow musk
#

yes fetchTokenProvider is being invoke multiple times

#

1st it gets initialize before the terminal gets initialized

#

and after during connting state

velvet beacon
#

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

hallow musk
#

is there something that we are missing

#

?

velvet beacon
#

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.

velvet beacon
hallow musk
#

on PaymentIntentConfirm the failure is happenign

#

after card tapped

velvet beacon
#

And, can you share an exact timestamp of one of these examples, and the source IP address it would be coming from?

hallow musk
#

yes

#

time stamp - 1770049159

velvet beacon
#

and IP address?

hallow musk
#

10.127.160.177

#

it is private IP address

velvet beacon
#

yea thats private, i need the public external address that our API would see the request coming from when it leaves your network

hallow musk
#

okay

#

182.70.146.124

coarse wigeonBOT
tall arrow
#

Hi ๐Ÿ‘‹

I'm stepping in as my colleagues had to go

hallow musk
#

Hi

#

thanks for jumping in

tall arrow
#

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

hallow musk
#

no. we are creating the location id of Malaysia

#

this app is for Malaysia

tall arrow
#

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

hallow musk
#

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

tall arrow
#

That seems to imply there was a code change that broke the confirmation flow.

#

Was there a version change in the Stripe RN SDK?

hallow musk
#

no version change

tall arrow
#

So what exactly changed between the working commit and the current broken app?

hallow musk
#

and we triple checked the code

#

no change in the code.

#

for stripe

tall arrow
#

Okay but let's ignore whether it's Stripe related or not

hallow musk
#

the code I shared here is the same one we have

tall arrow
#

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

hallow musk
#

what is the solution that you suggest?

tall arrow
#

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.

hallow musk
#

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

tall arrow
#

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.

hallow musk
#

tell me one thing

#

fetchTokenProvider is getting called multiple times

#

is that the root cause

tall arrow
#

Not from what I can tell. The payment intent confirm calls appear to be missing the API key

hallow musk
#

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?

tall arrow
#

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)