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.