Unable to make Apple Pay work with the react native plugin

I’m making some tests on the iOS simulator. I have the following code below. The requestApplePayNonce gets called however only the complete callback is called. The error and success are just skipped.

export async function startApplePay(): Promise<void> {
  await SQIPCore.setSquareApplicationId(
    'sandbox-sq0idb-XXXXXXX'
  );

  await SQIPApplePay.initializeApplePay('merchant.com.XXXXXXX');
  const digitalWalletEnabled = await SQIPApplePay.canUseApplePay();

  console.log('User can use ApplePay?', digitalWalletEnabled);

  if (Platform.OS === 'ios' && digitalWalletEnabled) {
    try {
      await SQIPApplePay.requestApplePayNonce(
        {
          price: '1.00',
          summaryLabel: 'Test Item',
          countryCode: 'US',
          currencyCode: 'USD',
          paymentType: 2,
        },
        async (cardDetails: CardDetails) => {
          console.log('Card Details', cardDetails);
          await SQIPApplePay.completeApplePayAuthorization(true);
        },
        async (errorInfo: any) => {
          console.log('Error:', errorInfo.message);
          await SQIPApplePay.completeApplePayAuthorization(
            false,
            errorInfo.message
          );
        },
        () => {
          console.log('Apple pay is complete');
        }
      );
    } catch (e: any) {
      console.log('Error', e);
    }
  }
}

In some rare cases, I was able to see an error message related to not being able to connect to PassKit server.

The only thing that is presented on the output logs is " [General] Connection to remote alert view service failed". Right before the “Apple pay is complete” is logged.

:wave: If I remember correctly you’ll need to test Apple Pay on a device. It currently won’t work with the simulator. :slightly_smiling_face: