From 221b91319e1e786c4c200121fe13240f2b8c7e40 Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Tue, 3 Feb 2026 20:16:35 +0800 Subject: [PATCH] Make addCardToAppleWallet fail consistently when module is not linked (cherry picked from commit 6f8ad2aa92a14a3999fb5f2852b9b6ac1fdb1f9f) --- src/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 1f94756..4cf6661 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -133,14 +133,20 @@ async function addCardToAppleWallet( throw new Error('addCardToAppleWallet is not available on Andorid'); } - const passData = await Wallet?.IOSPresentAddPaymentPassView(cardData); + if (!Wallet) { + return getModuleLinkingRejection(); + } + const wallet = Wallet; + + const passData = await wallet.IOSPresentAddPaymentPassView(cardData); + if (!passData || passData.status !== 0) { return getTokenizationStatus(passData?.status || -1); } async function addPaymentPassToWallet(paymentPassData: IOSAddPaymentPassData): Promise { const responseData = await issuerEncryptPayloadCallback(paymentPassData.nonce, paymentPassData.nonceSignature, paymentPassData.certificates); - const response = await Wallet?.IOSHandleAddPaymentPassResponse(responseData); + const response = await wallet.IOSHandleAddPaymentPassResponse(responseData); // Response is null when a pass is successfully added to the wallet or the user cancels the process // In case the user presses the `Try again` option, new pass data is returned, and it should reenter the function if (response) {