#nahoor_api

1 messages ยท Page 1 of 1 (latest)

tropic spruceBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

quiet bluff
#

you need to use initPaymentSheet

quiet cypress
quiet bluff
#

would you mind sharing your code then?

quiet cypress
# quiet bluff would you mind sharing your code then?

This is my initializePaymentSheet :
const initializePaymentSheet = async () => {

    const { error } = await initPaymentSheet({
        // customFlow: true,
        merchantDisplayName: 'Example .inc',
        intentConfiguration: {
            mode: {
                amount: (bookingPrices.totalPrice * 100),
                currencyCode: 'gbp',
                
            },
            confirmHandler,
        },
        
        defaultBillingDetails: {},

        googlePay: {
            merchantCountryCode: 'GB',
            testEnv: true, // use test environment
        },
        applePay: {
            merchantCountryCode: 'GB',
        },
    });
    if (error) {
        console.error('โŒ PaymentSheet init error:', error);
    } else {
        console.log('โœ… PaymentSheet initialized successfully!');
    }
};
quiet bluff
#

you're not passing the confirmHandler here

quiet cypress
#

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

    const orderReference = `${bookingLoadData?.loadId}`;
    console.log('orderReference', orderReference);
    setLoading(true);
 


    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 client_secret = response.data?.data?.clientSecret;
        if (client_secret) {

            console.log('client_secret', client_secret);

            intentCreationCallback({ clientSecret: 'your_client_secret' });

        } else {
            throw new Error('Client secret not found in response');
        }
    } 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);
    }
}; and my confirm handler
#

well this is showing me my paymentMethod showing me in console in here

quiet bluff
#

you need to pass to intentConfiguration the confirmHandler

quiet cypress
#

u mean i need to do like this :
merchantDisplayName: 'Intercargo Logistics',
intentConfiguration: {
mode: {
amount: (bookingPrices.totalPrice * 100),
currencyCode: 'gbp',

            },
           confirmHandler: confirmHandler,
        },
quiet bluff
#

Oh sorry I missed that ๐Ÿ˜ฆ

#

you're already passing it

quiet cypress
#

yes

quiet bluff
#

const confirmHandler = async (paymentMethod, shouldSavePaymentMethod, intentCreationCallback) => {
// explained later
}

#

you're missing the shouldSavePaymentMethod param of the confirmHandler

#

the intentCreationCallback is the 3 param

quiet cypress
#

is shouldSavePaymentMethod necessary?

quiet bluff
#

and you're using the second one instead

#

no it's not but the order should be preserved

tropic spruceBOT
quiet bluff
#

so you can pass (pm, _, icC)

#

but the order of the params should always be respected