Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rn_apple_pay_not_supported #246

Open
Deepali-Rai opened this issue Dec 11, 2024 · 1 comment
Open

rn_apple_pay_not_supported #246

Deepali-Rai opened this issue Dec 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Deepali-Rai
Copy link

Deepali-Rai commented Dec 11, 2024

Describe the issue

Our team is trying to integrate Apple Pay into our React Native app using the RN Plugin for In-App Payments SDK, but we keep running into this error: [Error: Something went wrong. Please contact the developer of this application and provide them with this error code: rn_apple_pay_not_supported] whenever we call SQIPApplePay.requestApplePayNonce.

To Reproduce

Steps to reproduce the issue.

  1. Initialize the SDK
  2. Initialize Apple Pay
  3. call await SQIPApplePay.requestApplePayNonce

Here the piece of code that reproduce the issue.

useEffect(() => {
  const initializeDigitalWallet = async () => {
    let digitalWalletEnabled = false;

    if (Platform.OS === 'ios') {
      try {
        await SQIPApplePay.initializeApplePay('merchant.FMApplePay');
        digitalWalletEnabled = await SQIPApplePay.canUseApplePay();
      } catch (error) {
        console.error('Error initializing Apple Pay:', error);
      }
    } else if (Platform.OS === 'android') {
      // Add Android-specific logic here
    }

    setCanUseDigitalWallet(digitalWalletEnabled);
  };

  initializeDigitalWallet();
}, []);

const onApplePayNonceRequestSuccess = async (cardDetails) => {
  try {
    // Process the card nonce details (e.g., take payment)
    // await chargeCard(cardDetails);

    // Close the Apple Pay sheet successfully
    await SQIPApplePay.completeApplePayAuthorization(true);
  } catch (ex) {
    // Handle card nonce processing failure
    await SQIPApplePay.completeApplePayAuthorization(false, ex.message);
  }
};

const onApplePayNonceRequestFailure = async (errorInfo) => {
  // Handle the error and close the Apple Pay sheet
  console.log(errorInfo, '!!!!!!!!!!!!err')
  await SQIPApplePay.completeApplePayAuthorization(false, errorInfo.message);
};

const onApplePayEntryComplete = () => {
  // Handle the event when the Apple Pay sheet is closed
  console.log('Apple Pay sheet closed');
};

 const onStartDigitalWallet = async () => {
  if (Platform.OS === 'ios') {
    const applePayConfig = {
      price: '1.00',
      summaryLabel: 'Test Item',
      countryCode: 'US',
      currencyCode: 'USD',
    };

    try {
      await SQIPApplePay.requestApplePayNonce(
        applePayConfig,
        onApplePayNonceRequestSuccess,
        onApplePayNonceRequestFailure,
        onApplePayEntryComplete,
      );
    } catch (ex) {
      console.error('Error requesting Apple Pay nonce:', ex);
    }
  } else if (Platform.OS === 'android') {
    // Add Android-specific logic here
  }
};


Expected behavior

The Apple Pay finish and return me the valid token.



**Environment (please complete the following information):**

- platform: iOS
- In-App Payments Plugin version: [e.g. 1.7.6]
@Deepali-Rai Deepali-Rai added the bug Something isn't working label Dec 11, 2024
@devwithshahzaib
Copy link

Is this happening on iPad?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants