stripe / stripe-react-native

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

Apple pay is always not supported #1446

Closed summer-yyyn closed 1 year ago

summer-yyyn commented 1 year ago

Describe the bug When I add applepay within the application, isPlatformPaySupported always returns false isPlatformPaySupported Returns true in the emulator and false on the real device To Reproduce useEffect(() => { (async function () { const res = await isPlatformPaySupported() console.log('isApplePaySupported', res) // got false // setIsApplePaySupported(res); })(); }, [isPlatformPaySupported]);

Smartphone (please complete the following information): emulator: iphone 14 pro max os:ios16.4 device: iphone 11 ios: 14.2

Is it necessary to enable the in app purchase function?

Filippo39 commented 1 year ago

Do you have at least one card in your wallet?

seanzhang-stripe commented 1 year ago

There are some pre-requisites for Apple Pay support. Can you go through them and make sure your project is ready for Apple Pay?

summer-yyyn commented 1 year ago

Do you have at least one card in your wallet?

Yes, I have a credit card and a debit card in my wallet

summer-yyyn commented 1 year ago

There are some pre-requisites for Apple Pay support. Can you go through them and make sure your project is ready for Apple Pay?

There are some pre-requisites for Apple Pay support. Can you go through them and make sure your project is ready for Apple Pay?

I have already operated according to this configuration. I can't call Applepay on the real machine. Is it because I call it in Chinese Mainland?

seanzhang-stripe commented 1 year ago

Did you add a valid Visa or Master card to your Apple Pay wallet? Please note that China UnionPay card isn't supported for wallets (like Apple Pay and Google Pay).

See this page for details.

summer-yyyn commented 1 year ago

您是否已将有效的 Visa 或 Master 卡添加到您的 Apple Pay 钱包中?请注意,钱包不支持中国银联卡(如 Apple Pay 和 Google Pay)。

详情请参阅本页

Thank you. I have successfully paid with Apple Pay in the United States and Singapore. I cannot pay in Chinese Mainland. Is it because there is no collection account in China?

seanzhang-stripe commented 1 year ago

@summer-yyyn What card do you use to pay in China? If it's a China UnionPay card, it's not supported for Apple Pay.

Shivani12345 commented 1 year ago

I am facing the same issue.I have changed my region to USA and added real credit card from USA in my iPhone 13. But still its showing isPlatformPaySupported false. I am testing it from India. Is can be the issue or checking my IP or something?.

paulmbw commented 1 year ago

Hi all,

I can also confirm I'm facing the same issue. I'm calling isPlatformPaySupported in a useEffect (shown below), but it consistently returns false on my physical iOS device (iPhone 12 Pro Max, iOS 17.0.3).

useEffect(() => {
    (async function () {
      setIsAppleOrGooglePaySupported(
        await isPlatformPaySupported()
      );
    })();
  }, [isPlatformPaySupported]);

As a result, payments in Stripe are appearing as incomplete:

Screenshot 2023-10-18 at 18 02 36

I can assure you I have active payment methods on my iPhone as I make payments via Apple very often.

I'm following the right logic according to the docs, here is my payment component:

const [isAppleOrGooglePaySupported, setIsAppleOrGooglePaySupported] =
    useState(false);

  useEffect(() => {
    (async function () {
      setIsAppleOrGooglePaySupported(await isPlatformPaySupported());
    })();
  }, [isPlatformPaySupported]);

const fetchPaymentIntentClientSecret = async () => {}) // calls API endpoint to return client secret

const pay = async () => {
    try {
      const clientSecret = await fetchPaymentIntentClientSecret();

      const { error } = await confirmPlatformPayPayment(clientSecret, {
        applePay: {
          cartItems: [
            {
              label: "Example item name",
              amount: "14.00",
              paymentType: PlatformPay.PaymentType.Immediate,
            },
            {
              label: "Total",
              amount: "14.00",
              paymentType: PlatformPay.PaymentType.Immediate,
            },
          ],
          merchantCountryCode: "GB",
          currencyCode: "GBP",
          requiredShippingAddressFields: [
            PlatformPay.ContactField.PostalAddress,
          ],
          requiredBillingContactFields: [PlatformPay.ContactField.PhoneNumber],
        },
        googlePay: {
          testEnv: true,
          merchantName: "React Native Starter Pack",
          merchantCountryCode: "GB",
          currencyCode: "GBP",
          billingAddressConfig: {
            format: PlatformPay.BillingAddressFormat.Full,
            isPhoneNumberRequired: true,
            isRequired: true,
          },
        },
      });
      if (error) {
        console.log("error: ", error);
        // handle error
      } else {
        console.log("success!");
        Alert.alert("Success", "Your payment was successful!");
      }
    } catch (error) {
      console.log("pay() - error: ", error);
    }
  };

return (
    <View>
      <PlatformPayButton
        onPress={pay}
        type={PlatformPay.ButtonType.Order}
        appearance={PlatformPay.ButtonStyle.Black}
        borderRadius={4}
        style={{
          width: "100%",
          height: 50,
        }}
      />
    </View>
  );
ImmortalRabbit commented 12 months ago

Hi all,

I can also confirm I'm facing the same issue. I'm calling isPlatformPaySupported in a useEffect (shown below), but it consistently returns false on my physical iOS device (iPhone 12 Pro Max, iOS 17.0.3).

useEffect(() => {
    (async function () {
      setIsAppleOrGooglePaySupported(
        await isPlatformPaySupported()
      );
    })();
  }, [isPlatformPaySupported]);

As a result, payments in Stripe are appearing as incomplete:

Screenshot 2023-10-18 at 18 02 36

I can assure you I have active payment methods on my iPhone as I make payments via Apple very often.

I'm following the right logic according to the docs, here is my payment component:

const [isAppleOrGooglePaySupported, setIsAppleOrGooglePaySupported] =
    useState(false);

  useEffect(() => {
    (async function () {
      setIsAppleOrGooglePaySupported(await isPlatformPaySupported());
    })();
  }, [isPlatformPaySupported]);

const fetchPaymentIntentClientSecret = async () => {}) // calls API endpoint to return client secret

const pay = async () => {
    try {
      const clientSecret = await fetchPaymentIntentClientSecret();

      const { error } = await confirmPlatformPayPayment(clientSecret, {
        applePay: {
          cartItems: [
            {
              label: "Example item name",
              amount: "14.00",
              paymentType: PlatformPay.PaymentType.Immediate,
            },
            {
              label: "Total",
              amount: "14.00",
              paymentType: PlatformPay.PaymentType.Immediate,
            },
          ],
          merchantCountryCode: "GB",
          currencyCode: "GBP",
          requiredShippingAddressFields: [
            PlatformPay.ContactField.PostalAddress,
          ],
          requiredBillingContactFields: [PlatformPay.ContactField.PhoneNumber],
        },
        googlePay: {
          testEnv: true,
          merchantName: "React Native Starter Pack",
          merchantCountryCode: "GB",
          currencyCode: "GBP",
          billingAddressConfig: {
            format: PlatformPay.BillingAddressFormat.Full,
            isPhoneNumberRequired: true,
            isRequired: true,
          },
        },
      });
      if (error) {
        console.log("error: ", error);
        // handle error
      } else {
        console.log("success!");
        Alert.alert("Success", "Your payment was successful!");
      }
    } catch (error) {
      console.log("pay() - error: ", error);
    }
  };

return (
    <View>
      <PlatformPayButton
        onPress={pay}
        type={PlatformPay.ButtonType.Order}
        appearance={PlatformPay.ButtonStyle.Black}
        borderRadius={4}
        style={{
          width: "100%",
          height: 50,
        }}
      />
    </View>
  );
  • what am I missing here?

Hey have you found answer to it? I have exact same issue.

trilam1409 commented 11 months ago

Hi all, I can also confirm I'm facing the same issue. I'm calling isPlatformPaySupported in a useEffect (shown below), but it consistently returns false on my physical iOS device (iPhone 12 Pro Max, iOS 17.0.3).

useEffect(() => {
    (async function () {
      setIsAppleOrGooglePaySupported(
        await isPlatformPaySupported()
      );
    })();
  }, [isPlatformPaySupported]);

As a result, payments in Stripe are appearing as incomplete:

Screenshot 2023-10-18 at 18 02 36

I can assure you I have active payment methods on my iPhone as I make payments via Apple very often. I'm following the right logic according to the docs, here is my payment component:

const [isAppleOrGooglePaySupported, setIsAppleOrGooglePaySupported] =
    useState(false);

  useEffect(() => {
    (async function () {
      setIsAppleOrGooglePaySupported(await isPlatformPaySupported());
    })();
  }, [isPlatformPaySupported]);

const fetchPaymentIntentClientSecret = async () => {}) // calls API endpoint to return client secret

const pay = async () => {
    try {
      const clientSecret = await fetchPaymentIntentClientSecret();

      const { error } = await confirmPlatformPayPayment(clientSecret, {
        applePay: {
          cartItems: [
            {
              label: "Example item name",
              amount: "14.00",
              paymentType: PlatformPay.PaymentType.Immediate,
            },
            {
              label: "Total",
              amount: "14.00",
              paymentType: PlatformPay.PaymentType.Immediate,
            },
          ],
          merchantCountryCode: "GB",
          currencyCode: "GBP",
          requiredShippingAddressFields: [
            PlatformPay.ContactField.PostalAddress,
          ],
          requiredBillingContactFields: [PlatformPay.ContactField.PhoneNumber],
        },
        googlePay: {
          testEnv: true,
          merchantName: "React Native Starter Pack",
          merchantCountryCode: "GB",
          currencyCode: "GBP",
          billingAddressConfig: {
            format: PlatformPay.BillingAddressFormat.Full,
            isPhoneNumberRequired: true,
            isRequired: true,
          },
        },
      });
      if (error) {
        console.log("error: ", error);
        // handle error
      } else {
        console.log("success!");
        Alert.alert("Success", "Your payment was successful!");
      }
    } catch (error) {
      console.log("pay() - error: ", error);
    }
  };

return (
    <View>
      <PlatformPayButton
        onPress={pay}
        type={PlatformPay.ButtonType.Order}
        appearance={PlatformPay.ButtonStyle.Black}
        borderRadius={4}
        style={{
          width: "100%",
          height: 50,
        }}
      />
    </View>
  );
  • what am I missing here?

Hey have you found answer to it? I have exact same issue.

I still got same issue.

Shivani12345 commented 11 months ago

@trilam1409 I was getting false response because I was testing this from India and applepay not supported for India .It's only supported by countries like USA, UK, etc. Please check with someone who lives in Countries supported by Apple Pay. Maybe it will help you.

trilam1409 commented 11 months ago

@Shivani12345 I'm testing in Vietnam. Apple Pay is supported in Vietnam. Some apps in Vietnam have the Apple Pay method.

prochickk commented 11 months ago

i have same issue, i am testing from KSA ( which supports apple pay ) with Valid cards added to wallet, still have the issue

trilam1409 commented 11 months ago

I got the issue from my side.

Please check the file "ios/Deskimo/Deskimo.entitlements"

Is there this code or not?

`com.apple.developer.in-app-payments

{YOUR_MERCHANT}

`

phuocantd commented 9 months ago

I got the issue from my side.

Please check the file "ios/Deskimo/Deskimo.entitlements"

Is there this code or not?

<key>com.apple.developer.in-app-payments</key> <array> <string>{YOUR_MERCHANT}</string> </array>

Tôi có thêm này rồi nhưng vẫn không hoạt động, simulator thì work nhưng iphone thì không

nguyentuanit97 commented 8 months ago

Any update?

Morozina commented 4 months ago

Folks, I fixed this issue by add apple pay in project settings, XCode > Project > Capabilities and add/enable Apple Pay to fix the issue.

paulmbw commented 4 months ago

Folks, I fixed this issue by add apple pay in project settings, XCode > Project > Capabilities and add/enable Apple Pay to fix the issue.

Yup, that fixed the issue! Thank you @Morozina!