#nahoor_api

1 messages ยท Page 1 of 1 (latest)

nimble orchidBOT
#

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

๐Ÿ“ 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.

mint perch
#

const confirmHandler = async (paymentMethod: any, shouldSavePaymentMethod: any, intentCreationCallback: any) => {

    try {
        const response = await axios.post(
            `${API_URL}/Stripe/confirm-payment-intent`,
            {
                paymentMethodId: paymentMethod.id,
                currency: 'gbp',
                amount: bookingPrices.totalPrice,
                orderReference,
                description: `${bookingLoadData?.from?.postcode} - ${bookingLoadData?.to?.postcode} / ${bookingLoadData?.minVehicleSize}`,
                isMobile: true,
                // should_save_payment_method: shouldSavePaymentMethod,
            },
            {
                headers: {
                    'Content-Type': 'application/json',
                    Authorization: `Bearer ${token}`,
                },
            }
        );


        console.log('โœ… confirmHandler API Response:', response.data);


        const responseData = response.data?.data;
        if (responseData?.clientSecret) {
            intentCreationCallback({ clientSecret: responseData?.clientSecret });

        } else if (responseData?.error) {
            console.log('Error', responseData.error);
            intentCreationCallback({ error: responseData.error });
        } else {
            console.warn('โš ๏ธ Unexpected response structure:', responseData);
            intentCreationCallback({ error: 'Unexpected response from server' });
        }
    } catch (error: any) {
        const errorMsg2 = error.response || error.message || 'Unknown error occurred';
        console.error('โŒ Error in confirmHandler:', errorMsg2);
        intentCreationCallback({ error: errorMsg }); // Pass error to Stripe to reject flow

    } finally {
        setLoading(false);
    }
};
daring beacon
#

hey there taking a look, thanks for the example request

#

Are you sure that was the request you meant to send?

#

What are you passing into intentCreationCallback?

mint perch
# daring beacon What are you passing into `intentCreationCallback`?

I am passing error from backend my console.log is as follow :
confirmHandler API Response: {"data": {"error": "Your card has insufficient funds."}, "message": "Error processing payment", "status": false}
(NOBRIDGE) LOG Error Your card has insufficient funds.
but it is causing a crash as it is in error state or call intentCreationCallback({ error: responseData.error });

daring beacon
#

I don't understand what you're expecting, this seems to be hitting this path:

 } else if (responseData?.error) {
                console.log('Error', responseData.error);
                intentCreationCallback({ error: responseData.error });
            } 
mint perch
#

as it hit this my app crashes

daring beacon
#

Ok, what causes it to crash?

mint perch
#

as soon as it goes into this response?.error in intentCreationCallback

#

i want to show error but it is crashing

#

so i am unable if i don't do intentCreationCallback it keep on processing

#

now did u get it ?

daring beacon
#

I get that you're exercising an error path here, and passing an {error: 'Some error message.' to intentCreationCallback, but its not clear what is actually failing.

#

Do you have device logs with more information about the crash/error?

#

I should say explicitly to confirm: i am assuming from your JS snippets that you're using react native here in your app (not android or ios native)

mint perch
#

yes i am using react native

daring beacon
nimble orchidBOT
daring beacon
#

That's all fine, and the pattern seems to be valid based on the documented structure and what you've shown, so where exactly does the error originate?

#

Can you confirm which version of stripe-react-native you're using?

#

The device logs should hopefully provide a pointer to the actual error

#

What do they say when this happens?

mint perch
#

i am trying but it is not showing

heady charm
#

Hmm, do the logs just cut off at that point?

mint perch
#

yes

heady charm
#

If you run through that with a debugger, is the intentCreationCallback variable properly populated? And I assume the console.log is properly logging out the error just before you are passing it to that callback?

mint perch
#

In my log as soon as it calls intentCreationCallback({ error: responseData.error }); it crashes

#

confirmHandler called. Payment Method ID: {"AuBecsDebit": {"bsbNumber": null, "fingerprint": null, "last4": null}, "BacsDebit": {"fingerprint": null, "last4": null, "sortCode": null}, "Card": {"availableNetworks": null, "brand": "Visa", "country": "US", "expMonth": 2, "expYear": 2027, "fingerprint": null, "funding": "credit", "last4": "9995", "preferredNetwork": null, "threeDSecureUsage": {"isSupported": true}}, "Fpx": {"accountHolderType": null, "bank": null}, "Ideal": {"bankIdentifierCode": null, "bankName": null}, "SepaDebit": {"bankCode": null, "country": null, "fingerprint": null, "last4": null}, "Sofort": {"country": null}, "USBankAccount": {"accountHolderType": "Unknown", "accountType": "Unknown", "bankName": null, "fingerprint": null, "last4": null, "linkedAccount": null, "preferredNetworks": null, "routingNumber": null, "supportedNetworks": null}, "Upi": {"vpa": null}, "billingDetails": {"address": {"city": null, "country": "GB", "line1": null, "line2": null, "postalCode": "MK92AH", "state": null}, "email": null, "name": null, "phone": null}, "customerId": null, "id": "pm_1RBd8J00IFw5OXLObmDAAC2S", "livemode": false, "paymentMethodType": "Card"}
(NOBRIDGE) LOG ๐Ÿ”„ confirmHandler called. intentCreationCallback: [Function intentCreationCallback] my console for payment and intentCreationCallback

heady charm
#

Oh actually it looks like it is crashing before then, because that output doesn't have the "Error" string from your "console.log('Error', responseData.error);" call. Even if you passed an empty string via responseData.error that should still log a line that says "Error"

#

I recommend stepping through your code with a debugger to get a clearer view of what is happening. If intentCreationCallback is what is crashing things, it could be helpful to try to step in to that method to see if you can see the specific line that is crashing things.

mint perch
#

in my responData.error it is string actually

heady charm
#

Correct, but your call also passes the string literal "Error"

#

And that string literal isn't in the output that you just pasted here

#

It is like if you had a console.log call that had "Nahoor" in it and that string wasn't in your output. That indicates that the log statement isn't being executed

mint perch
#

const confirmHandler = async (paymentMethod: any, shouldSavePaymentMethod: any, intentCreationCallback: any) => {
console.log('๐Ÿ”„ confirmHandler called. Payment Method ID:', paymentMethod);
console.log('๐Ÿ”„ confirmHandler called. intentCreationCallback:', intentCreationCallback);
const orderReference = ${bookingLoadData?.loadId};
try {
const response = await axios.post(
${API_URL}/Stripe/confirm-payment-intent,
{
paymentMethodId: paymentMethod.id,
currency: 'gbp',
amount: bookingPrices.totalPrice,
orderReference,
description: ${bookingLoadData?.from?.postcode} - ${bookingLoadData?.to?.postcode} / ${bookingLoadData?.minVehicleSize},
isMobile: true,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: Bearer ${token},
},
}
);
const responseData = response.data?.data;
if (responseData.clientSecret) {

            console.log('client_secret', responseData.clientSecret);
            intentCreationCallback({ clientSecret: responseData.clientSecret });

        } else if (responseData.error) {
            const error = responseData.error;
            const serverError = error.response?.data?.error || error.response?.data?.message;
            intentCreationCallback({ error: serverError });
        }
    } catch (error: any) {
        const serverError = error.response?.data?.error || error.response?.data?.message;
        const errorMsg2 = serverError || error.response || error.message || 'Unknown error occurred';

        intentCreationCallback({ error: errorMsg2 }); // Pass error to Stripe to reject flow

    }
#

well this is my code for your better understanding

heady charm
#

That all looks fine as far as I can see. I really do think a debugger is the next step. I'll try to run that code in my RN environment and see if I get a similar error as well

mint perch
#

That would be so great if you do that

mint perch
#

how can i show user the error that it has unsufficent balance ?

heady charm
#

As in how do you get that error from the decline object?

#

And is that an error message that you are now seeing related to the intentCreationCallback?

#

Also your code is working fine for me when I run it in my own RN environment now. I think the two options from here are:

  1. Debugger
  2. Create a minimal repro project. Like an RN project with one screen that just tries to open a payment sheet and do this flow that still gets this error. If you send that in to our support team, we can try to reproduce on our side and escalate if we see it as well
mint perch
#

yes

heady charm