#mohit_39749

1 messages · Page 1 of 1 (latest)

cursive badgeBOT
night prairie
#

Can you share your code and the exact line that threw this error?

fiery maple
#

Here is the Frontend Code

const handlePayPress = async () => {
try {
const response = await fetch('http://10.255.254.170:5000/create-payment-intent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ amount: parseInt(amount) }),
});

        const { clientSecret, error } = await response.json();

        if (error) {
            console.log('Error:', error);
            Alert.alert('Error processing payment');
        } else {
            const { paymentIntent, error } = await confirmPayment(clientSecret, {
                type: 'Card',
                paymentMethodType: ['card'],
                billingDetails: { email },
            });

            if (error) {
                console.log('Payment Confirmation Error:', error.message);
                Alert.alert(`Payment Confirmation Error: ${error.message}`);
            } else if (paymentIntent) {
                console.log('Payment successful:', paymentIntent);
                Alert.alert('Payment Successful');
            }
        }
    } catch (e) {
        console.error(e);
        Alert.alert('Error processing payment');
    }
};
#

Let me know whats the problem

night prairie
#

Which line is throwing the error?

fiery maple
#

Error is "Value for payment method type cannot be cast from ReadableNativeArray to String"

#

Payment method type

night prairie
#

Which exect line of the code that this error was returned? We need to know the exact line that threw this error in order to know what the problem is

fiery maple
#

Here is the Frontend Code

const handlePayPress = async () => {
try {
const response = await fetch('http://10.255.254.170:5000/create-payment-intent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ amount: parseInt(amount) }),
});

        const { clientSecret, error } = await response.json();

        if (error) {
            console.log('Error:', error);
            Alert.alert('Error processing payment');
        } else {
            const { paymentIntent, error } = await confirmPayment(clientSecret, {
                type: 'Card',
                paymentMethodType: ['card'],
                billingDetails: { email },
            });

            if (error) {
                console.log('Payment Confirmation Error:', error.message);
                Alert.alert(`Payment Confirmation Error: ${error.message}`);
            } else if (paymentIntent) {
                console.log('Payment successful:', paymentIntent);
                Alert.alert('Payment Successful');
            }
        }
    } catch (e) {
        console.error(e);
        Alert.alert('Error processing payment');
    }
};
#

const { paymentIntent, error } = await confirmPayment(clientSecret, {
type: 'Card',
paymentMethodType: ['card'],
billingDetails: { email },
});

#

on This code

#

??

cursive badgeBOT
night prairie
#

Which mobile SDK and version do you use?

fiery maple
#

I am using Expo React Native

#

Android And Ios

#

Android API 34 google API

#

Please let me know the Solution

#

??

spring pebble
#

i believe paymentMethodType is supposed to be a string like what the error message mentions

#

you're passing in an array

fiery maple
#

ok

#

So i put like this paymentMethodType: 'card',