You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(android): fix Google Pay crash — Activity context and ActivityEventListener (#49)
### Description
Fix two bugs that caused Google Pay to crash and a third that sent the
wrong auth header when fetching the Bolt APM config.
**1. `PaymentsClient` created with wrong context
(`GooglePayModule.kt`)**
`Wallet.getPaymentsClient()` was called with `reactApplicationContext`
(the Application context). The Google Pay SDK needs an `Activity`
context to attach the payment sheet to a window — hence `Tried to show
an alert while not attached to an Activity`.
**2. `onActivityResult` never received (`GooglePayModule.kt`)**
`GooglePayModule` never registered as an `ActivityEventListener`, so the
result from the Google Pay sheet was silently swallowed and the pending
`Promise` would hang forever. The module now implements
`ActivityEventListener` and registers itself in `init{}` — no changes to
`MainActivity` required.
**3. Wrong header when fetching APM config (`GoogleWallet.tsx`)**
The `fetchGooglePayAPMConfig` request used `merchant_token` as the
header name instead of the correct `x-publishable-key`, causing the
config fetch to fail before the payment sheet could even be shown.
### Testing
- [ ] Tap Google Pay button on Android — payment sheet opens without
crash
- [ ] Complete a Google Pay payment — `onComplete` callback fires with
token + billing address
- [ ] Cancel/dismiss the Google Pay sheet — `onError` callback fires
with `CANCELLED`
- [ ] Cold-start the app and tap Google Pay immediately — no
`NO_ACTIVITY` rejection
### Security Review
> [!IMPORTANT]
> A security review is required for every PR in this repository to
comply with PCI requirements.
- [x] I have considered and reviewed security implications of this PR
and included the summary below.
#### Security Impact Summary
No new data flows or secrets introduced. The `x-publishable-key` header
fix corrects which key is sent to the Bolt APM config endpoint — the key
itself was already present in the original code, just under the wrong
header name. The Activity context change only affects where Google Pay's
system UI is anchored; no payment data handling is altered.
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments