diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 179d848..15bc814 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - BoltReactNativeSdk (0.6.1): + - BoltReactNativeSdk (0.7.2): - hermes-engine - RCTRequired - RCTTypeSafety @@ -2063,7 +2063,7 @@ EXTERNAL SOURCES: :path: "../../node_modules/react-native/ReactCommon/yoga" SPEC CHECKSUMS: - BoltReactNativeSdk: 39c8b5101365cc76c9b46468a9a2243c0230b2d4 + BoltReactNativeSdk: f0c75d2043963259b5da2534cc13e55ffa8006a6 FBLazyVector: c12d2108050e27952983d565a232f6f7b1ad5e69 hermes-engine: 7e38620e1a649887e872d251528805867fa4d0b6 RCTDeprecation: 3280799c14232a56e5a44f92981a8ee33bc69fd9 diff --git a/package.json b/package.json index da8b590..3fa1f31 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "typecheck": "tsc", "test": "jest", "release": "release-it", + "pod": "cd example/ios && pod install", "lint": "eslint \"**/*.{js,ts,tsx}\"", "inject-telemetry-config": "node scripts/inject-telemetry-config.js", "gen-dev-telemetry-config": "node scripts/gen-dev-telemetry-config.js", diff --git a/src/payments/ApplePayWebView.tsx b/src/payments/ApplePayWebView.tsx index c59d465..34fd3ce 100644 --- a/src/payments/ApplePayWebView.tsx +++ b/src/payments/ApplePayWebView.tsx @@ -114,8 +114,28 @@ export const ApplePayWebView = ({ try { const outer = JSON.parse(raw); + // Unwrap bridge postMessage envelope produced by injectedBridge.ts + let unwrapped = outer; + if ( + unwrapped?.__boltBridge === true && + unwrapped.type === 'postMessage' && + unwrapped.data !== undefined + ) { + const inner = unwrapped.data; + if (typeof inner === 'string') { + try { + unwrapped = JSON.parse(inner); + } catch { + // Inner payload is a plain string, keep as-is + unwrapped = inner; + } + } else { + unwrapped = inner; + } + } + // Height change from iframe - let msg = outer; + let msg = unwrapped; if (typeof msg === 'string') { try { msg = JSON.parse(msg); @@ -129,9 +149,8 @@ export const ApplePayWebView = ({ } // Apple Pay result messages - const applePayMsg = parseBoltMessage(raw); + const applePayMsg = parseBoltMessage(unwrapped); if (!applePayMsg) return; - if (applePayMsg.type === 'addCardFromApplePaySuccess') { const message = applePayMsg.message as Record; const tokenResult = message.token as