Skip to content

feature(PayPal): collect and send device_info to determine app switch eligibility#1600

Open
santugowda wants to merge 3 commits into
braintree:mainfrom
santugowda:paypal-app-switch-device-info
Open

feature(PayPal): collect and send device_info to determine app switch eligibility#1600
santugowda wants to merge 3 commits into
braintree:mainfrom
santugowda:paypal-app-switch-device-info

Conversation

@santugowda

@santugowda santugowda commented May 14, 2026

Copy link
Copy Markdown

Summary of changes

Sends device information as a nested app_switch_context object in PayPal Hermes requests when enablePayPalAppSwitch is enabled. This data is used downstream to determine app switch eligibility.

JSON structure sent to BTGW:

{
  "launch_paypal_app": true,
  "app_switch_context": {
    "device_info": {
      "model": "SM-A166U",
      "memory_available_mb": 350,
      "memory_total_mb": 4096
    },
    "native_app": {
      "app_url": "https://...",
      "os_type": "ANDROID",
      "os_version": "35"
    }
  }
}

Changes:

  • PayPalVaultRequest / PayPalCheckoutRequest: replaced flat os_type, os_version, merchant_app_return_url keys with nested app_switch_context.native_app object
  • PayPalInternalClient: injectDeviceInfo() adds device_info (model, memory_available_mb, memory_total_mb) into app_switch_context
  • PayPalRequest: updated constants for new nested key structure
  • Updated unit and instrumentation tests to verify nested structure

AI Usage

Which AI Agent Was Used?

  • Claude

How was AI used?
Code generation, cross-codebase analysis (Android SDK, BTGW, backend), refactoring from flat to nested JSON structure, and writing tests.

Estimated AI Code Contribution

  • less than 30%
  • 30 - 60%
  • 60 - 100%

Checklist

  • Added a changelog entry
  • Tested and confirmed payment flows affected by this change are functioning as expected

Authors


Inner Source Process

Internal to PayPal contributors should fill out this section. All others can delete.

PR should follow these steps before codeowners review will begin:

  1. Comment /inner source on this PR — this will automatically add the inner source and tech lead review required labels. Open the PR in a draft state.
  2. PR should be reviewed by and approved by your team's technical lead, we do not allow LGTM reviews, there should be comments and feedback provided on all PR reviews
  3. Once the above steps are completed, comment /ready on this PR — this will automatically remove the tech lead review required label. Move the PR to ready to review.
  4. PR comments must be addressed within 24 hours, if you are unable to address within this timeframe, move the PR back to a draft state so our team knows not to review

Inner Source Checklist

  • Added all labels to the PR
  • Provide steps to test the flows changed, if applicable in the summary
  • Demo video of the functionality, if applicable
  • All upstream dependencies are merged in and this PR can be released at any time; PRs should not be opened until this is true
  • Unit tests and builds have been run locally and pass/compile as expected

@saralvasquez saralvasquez added inner source This PR is internal to PP but external to the mobile SDK team tech lead review required labels May 18, 2026
Santhosh Bhutegowda and others added 2 commits June 9, 2026 12:27
… eligibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@santugowda santugowda force-pushed the paypal-app-switch-device-info branch from 0025eb8 to f30f4ca Compare June 9, 2026 17:29
@santugowda santugowda marked this pull request as ready for review June 9, 2026 17:29
@santugowda santugowda requested a review from a team June 9, 2026 17:29
@santugowda santugowda requested a review from a team as a code owner June 9, 2026 17:29
@jaxdesmarais

Copy link
Copy Markdown
Contributor

@santugowda please follow the Inner Source Process in the PR description.

@jaxdesmarais jaxdesmarais marked this pull request as draft June 10, 2026 14:25
- Wrap ActivityManager.getMemoryInfo() in withContext(Dispatchers.IO) to
  avoid Binder IPC on Dispatchers.Main
- Switch getJSONObject → optJSONObject in injectDeviceInfo for defense-in-depth
  (outer guard already ensures the key exists, but this makes the function safe
  in isolation)
- Extract hardcoded "ANDROID" string to OS_TYPE_VALUE constant in PayPalRequest
- Rename MODEL_KEY → DEVICE_MODEL_KEY for consistency with sibling constants
- Promote activityManager to class field in unit tests with non-zero default
  memory values in beforeEach, removing per-test mock duplication
- Add instrumentation test for PayPalVaultRequest app switch nested structure
- Add unit test for vault path device_info injection
- Add unit test for no-op when app switch enabled but no app link present

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@santugowda santugowda marked this pull request as ready for review June 13, 2026 02:20
@santugowda

Copy link
Copy Markdown
Author

/ready

@santugowda santugowda marked this pull request as draft June 13, 2026 02:22
@santugowda santugowda marked this pull request as ready for review June 13, 2026 18:38
@santugowda

Copy link
Copy Markdown
Author

/inner source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inner source This PR is internal to PP but external to the mobile SDK team tech lead review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants