stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

Google Pay not working in Android, am getting false when I call isPlatformPaySupported

Open Stancobridge opened this issue 2 years ago • 5 comments

I can't seem to get Google pay to work on Android, am using Expo Custom dev client, after installing stripe I rebuilt the dev client

I also added this in my app.json

  [
      '@stripe/stripe-react-native',
      {
        enableGooglePay: true,
      },
    ],

Here is the code am using

import { initStripe, usePlatformPay } from '@stripe/stripe-react-native';
import { useEffect } from 'react';
import Toast from 'react-native-toast-message';
import { useInitializePlanSubscription } from './useInitializePlanSubscription';

export const useProcessSubscriptionIntent = () => {
  const { initializePaymentIntent } = useInitializePlanSubscription();
  const { isPlatformPaySupported, confirmPlatformPayPayment } = usePlatformPay();
  useEffect(() => {}, []);
  const showPaymentSheet = async () => {
    await initStripe({
      publishableKey:
        'pk_test_51O945CDwXNu7P228DqG3OyOQ3G7Le4qSi8hUtp7wqWppxIMpZkmeLw7Kjh2VSA1HWbN92cfY0Gq9ISFQDxvDd6NL00WX1zTsup',
    });
    const platformPayAvailable = await isPlatformPaySupported();
    if (!platformPayAvailable) {
      Toast.show({
        type: 'errorToast',
        text1: 'Platform payment not supported',
      });
      return;
    }
    const paymentIntent = await initializePaymentIntent(1);
    const { paymentIntent: data, error } = await confirmPlatformPayPayment(paymentIntent.payment.paymentIntent, {
      googlePay: { currencyCode: 'USD', merchantCountryCode: 'US', testEnv: true },
    });

    console.log({ data, error });
  };

  return { showPaymentSheet };
};```

Stancobridge avatar Nov 16 '23 07:11 Stancobridge

I created this example to help track this, https://github.com/Stancobridge/google-pay-rn-example

Stancobridge avatar Nov 24 '23 22:11 Stancobridge