stripe / stripe-react-native

React Native library for Stripe.
https://stripe.dev/stripe-react-native
MIT License
1.25k stars 256 forks source link

Expo React Native iOS Payment Options not shown (only card shown) #1570

Closed faisalhotak closed 7 months ago

faisalhotak commented 9 months ago

Hello everyone!

I have implemented the stripe payment inside my mobile app. It works fine but payment cards options are only shown on Android and only "card" option is shown on iOS (they use the same stripe public key so they should show the same card options as the ones activated in my dashboard). The most important payment option being "bancontact" and I do not see it on iOS.

To Reproduce Steps to reproduce the behavior:

  1. Creating the payment intent
  2. Showing the payment intent element to the user
  3. All the options are available on Android
  4. No card options available on iOS (except the "card")

Server side :

const paymentIntent = await stripe.paymentIntents.create({
    amount,
    customer: customer.id,
    currency: "eur",
    automatic_payment_methods: {
        enabled: true,
    },
    metadata: { pendingPaymentId: pendingPayment.id },
  });

Client side :

const initializePaymentSheet = async () => {
    const { payload } = await createPaymentIntent();

    console.log("payload", payload);

    const { clientSecret, ephemeralKey, customerId, publishableKey } = payload;

    const { error } = await initPaymentSheet({
      merchantDisplayName: "TEST APP",
      customerId: customerId,
      customerEphemeralKeySecret: ephemeralKey,
      paymentIntentClientSecret: clientSecret,
      merchantCountryCode: "BE",
    });

    if (error) {
      console.log(error);
    }
  };

  const payTest = async () => {
    await initializePaymentSheet();
    // const response = await confirmPaymentSheetPayment();
    const { error } = await presentPaymentSheet();

    console.log("error", error);

    if (error) {
      Toast.show(error.message, {
        duration: Toast.durations.SHORT,
        position: Toast.positions.CENTER,
        animation: true,
        delay: 0,
      });

      return;
    }

    Toast.show("Paiement effectué", {
      duration: Toast.durations.SHORT,
      position: Toast.positions.CENTER,
      animation: true,
      delay: 0,
    });
  };

Screenshots

On Android (showing all the options) :

Capture d’écran 2023-11-26 à 13 26 11

On iOS (only showing "card" and not other options such as "bancontact" or others") :

Capture d’écran 2023-11-26 à 13 25 15

Smartphone :

Thanks !

oaxio commented 7 months ago

Same issue here

oaxio commented 7 months ago

For anyone with this issue,

Add
returnURL: 'your-app://stripe-redirect', in your initPaymentSheet

faisalhotak commented 7 months ago

@oaxio Thank you very much!

Indeed, the return url is needed, make sure to replace 'your-app' by your app name.

const { error } = await initPaymentSheet({
      merchantDisplayName: "TEST APP",
      customerId: customerId,
      customerEphemeralKeySecret: ephemeralKey,
      paymentIntentClientSecret: clientSecret,
      merchantCountryCode: "BE",
      returnURL: 'your-app://stripe-redirect'
    });

Then the payment methods will be shown !

Capture d’écran 2024-01-29 à 13 48 08