#death hand

1 messages · Page 1 of 1 (latest)

flat fjordBOT
late hinge
#

hi! do you have more context like some exact code you're using? if we take it one at a time, are you testing on Android(Google Pay) or iOS(Apple Pay)? which one do you want to look into trying to get working first?

main fjord
#

I tried to follow the first video course, where the functions they call was initPaymentSheet, presentPaymentSheet. Im currently testing on android

#

In initPaymentSheet I added googlePay:{
merchantCountryCode: ,
testEnv: ,
currencyCode:
}

late hinge
#

those values all appear to be empty.

main fjord
#

Yes I didn’t included what the values are here but in my code they exist

late hinge
#

and you're running the app on a phone that has Google Pay working in general, logged in your Google account with cards in your Google Pay wallet?

main fjord
#

yes. I don't think that is the problem because the option does not show at all

late hinge
#

are you in India?

main fjord
#

no

late hinge
#

could you perhaps share the code you're using?

flat fjordBOT
main fjord
#

yes, wait a little so i can make it using the bare minimum

#
            <StripeProvider publishableKey='pk_test_51NBeM4GijvpKRItrry0QbRYNk6xyoPeofTCnH2roG4Xei425NVnVE2PJqJBvk22ZGr1cctPvE4nJ9vB2EUkxgGPg006WOI1CGv'
            >
                <View style={{
                    flexDirection: 'row',
                    justifyContent: 'space-between',
                    alignSelf: 'center',
                    marginHorizontal: 15,
                    
                }}>

                <View style={styles.buttonContainer}>
                    <Button
                        title={'Buy'}
                        onPress={() => handleSelectMethod()}
                    />
                </View>



                </View>
                </StripeProvider>
        </View>```
#
        initPaymentSheet,
        presentPaymentSheet,
        confirmPaymentSheetPayment,
    } = usePaymentSheet();


    // Initialize stripe values upon mounting the screen
    React.useEffect(() => {
        (async () => {
            await initializePaymentSheet();
        })();
    }, []);

    const initializePaymentSheet = async () => {

        const URL = 'http://192.168.2.32:3000/payment-sheet'
        const response = await fetch(URL, {
            method: 'POST',
            headers: {
                'Content-Type': 'application-json'
            },
        })
        /* Await the response */
        const {
          paymentIntent,
          ephemeralKey,
          customer
        } = await response.json();

        const { error, paymentOption } = await initPaymentSheet({
            customerId:customer,
            customerEphemeralKeySecret:ephemeralKey,
            paymentIntentClientSecret: paymentIntent,
            merchantDisplayName: 'nick',
            style: 'alwaysDark', // If darkMode
            googlePay: {
              merchantCountryCode: 'GR',
              testEnv:true,
              currencyCode:'eur'
            }, // If implementing googlePay
            // applePay: {
            //     merchantCountryCode:'GR'
            // }, // If implementing applePay
            merchantCountryCode: 'GR', // Countrycode of the merchant
            
            testEnv: __DEV__, // Set this flag if it's a test environment
        });
        if (error) {
            console.log(error)
        } else {
            setReady(true)
        }
    };

    const handleSelectMethod = async () => {

        const { error, paymentOption } = await presentPaymentSheet();
        if (error) {
            console.log(paymentOption)
            alert(`Error code: ${error.code}`, error.message);
        }
        else{
          alert('success');
          setReady(false);
        }
    }```
#

and this is the post request on the server side

#

  const email = `test${Math.floor(Math.random() * 9999) + 1}@domain.com`
  const stripe = new Stripe(SECRET_KEY, {
    apiVersion: '2020-08-27',
    typescript: true,
  });

  const customer = await stripe.customers.create({email});

  const ephemeralKey = await stripe.ephemeralKeys.create(
    {customer: customer.id},
    {apiVersion: '2020-08-27'},
  );
  const paymentIntent = await stripe.paymentIntents.create({
    amount: 5099,
    currency: 'usd',
    automatic_payment_methods: {
      enabled: true,
    },
  });
  return res.json({
    paymentIntent: paymentIntent.client_secret,
    ephemeralKey: ephemeralKey.secret,
    customer: customer.id,
  });
});```
sonic thicket
#

Hey! Taking over for my colleague. You are testing your website from https of from your localhost ?

main fjord
#

localhost

sonic thicket
#

You need to serve your website over https in order to see Google and Apple Pay

main fjord
#

it is not a website, I'm developing an app using react native Expo. Or do you mean the server I'm using to create the paymentIntent ?

sonic thicket
#

Ah sorry I though you are developping a reactjs app.

#

Do you have a valid card in the device you are testing with ?

main fjord
#

The option google pay or apple pay does not exist in the payment sheet

#

i am seeing this

sonic thicket
#

It won't exist if you don't set Apple wallet on the ios device with or Google Wallet/Account set on the Android device you are testing

main fjord
#

in react native Expo, even tho the docs says it won't work with stripe on the Expo go app, will the option still be visible in the payment sheet?

sonic thicket
#

in react native Expo, even tho the docs says it won't work with stripe on the Expo go app,
Where are you seeing this, can you please share the reference ?

sonic thicket
main fjord
#

then its still a problem

sonic thicket
#

For example, on Ios, using expo react native integration

sonic thicket
main fjord
#

the option for platform pay is not visible in my case

sonic thicket
main fjord
#

yes I have in apple wallet

sonic thicket
main fjord
#

ok I'm testing it and I will tell you how it goes, thank you in advance