Skip to content

Feature : Saved payment method data models - #1718

Open
balamaninayard wants to merge 9 commits into
braintree:view-edit-fi-beta-featurefrom
balamaninayard:feature/saved-payment-method-data-models
Open

balamaninayard wants to merge 9 commits into
braintree:view-edit-fi-beta-featurefrom
balamaninayard:feature/saved-payment-method-data-models

Conversation

@balamaninayard

Copy link
Copy Markdown

Summary of changes

  • Adds the internal data layer for the PayPal Saved Payment Method (View/Edit FI) module. No public API changes; nothing is wired up yet — these types are consumed by PayPalSavedPaymentMethodClient in the follow-up PR.
  • Funding instrument response models (model/): PayPalSavedPaymentMethodSummary, PayPalSavedPaymentMethod, PayPalSavedPaymentMethodType, PayPalPayer — parse the paypalFundingInstrumentDetails GraphQL response.
  • Credit messaging: PayPalCreditMessagingRequest (POST body for v2/credit/fetch-presentment-messages, built with toJson()), plus model/PayPalCreditMessagingResult, PayPalCreditMessageItem, PayPalCreditMessageItemType.
  • flow_context.attributes sends BRAND_BRAINTREE, EXPERIENCE_ANDROID_SDK, EXPERIENCE_VIEW_EDIT_FI, EXPERIENCE_EXTERNAL_DIRECT .
  • Response models live in a model/ subpackage to keep them separate from the request body and the upcoming client; all types are internal.
  • Replaces the scaffold placeholder unit test with 34 unit tests (one test file per source file).

Steps to test

  • ./gradlew :PayPalSavedPaymentMethod:testReleaseUnitTest
  • ./gradlew :PayPalSavedPaymentMethod:lintRelease detekt

AI Usage

Which AI Agent Was Used?

  • Copilot
  • Claude
  • Other (Type Name Here)

How was AI used?
Code generation for the models and request body, writing unit tests, reviewing parity again and its review comments, and applying review fixes (naming, KDoc, test coverage). Alloutput was reviewed, and tests, lint and detekt were run locally.

Estimated AI Code Contribution

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

Checklist

  • Added a changelog entry — not needed on the feature branch; will be added when view-edit-fi-beta-feature merges to main
  • Tested and confirmed payment flows affected by this change are functioning as expecteonly; no payment flow uses them yet

Authors

List GitHub usernames for everyone who contributed to this pull request.


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 LGTe 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 ck 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 — N/A, no UI or flow changes
  • All upstream dependencies are merged in and this PR can be released at any time; PRs l this is true
  • Unit tests and builds have been run locally and pass/compile as expected

balamaninayard and others added 5 commits October 6, 2026 15:06
…d models with SDK conventions

- rename PayPalCreditMessagingRequest.build() to toJson()
- remove internal terms from KDoc and test names, document request properties
- limit paymentMethods and subtype KDoc to documented API behavior
- simplify the displayable-text check and link KDoc references

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e and unknown type cases

- use a PAYPAL_CREDIT fixture for subtype
- cover preferred_message without content and explicit null embeddable
- assert unknown types keep the remaining fields

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@balamaninayard
balamaninayard requested a review from a team as a code owner October 6, 2026 10:34
@balamaninayard
balamaninayard marked this pull request as draft October 6, 2026 10:35
@anibalb2500

Copy link
Copy Markdown
Contributor

Do we need the @Serializable annotation on any of these models?

@balamaninayard

Copy link
Copy Markdown
Author

Do we need the @Serializable annotation on any of these models?

No, kotlinx.serialization isn't used anywhere in this repo — these models follow the existing pattern of manual parsing via fromJson(JSONObject), same as other SDK response models.

…saging response

Addresses PR review comment confirming Json.optString handles a null
analytics object safely, but was missing test coverage for that case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@Bhuvana-S100 Bhuvana-S100 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@anibalb2500

Copy link
Copy Markdown
Contributor

LGTM

@balamaninayard
balamaninayard marked this pull request as ready for review October 7, 2026 15:55
@balamaninayard

Copy link
Copy Markdown
Author

/inner source

@github-actions github-actions Bot added inner source This PR is internal to PP but external to the mobile SDK team tech lead review required labels Oct 7, 2026
@balamaninayard

Copy link
Copy Markdown
Author

/ready

@mzlangreder mzlangreder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes:

  1. Credit request attributes differ from iOS (C1).
  2. Parsers are looser than the LLD (C2).
  3. Server URLs aren't validated (C3).
  4. Some tests can't fail (C4).
  5. Credit model shape and scope need a decision (C5).
  6. Note for the client PR (C6).

C6. Follow-up note
For #1719: BraintreeGraphQLClient throws only on non-2xx. HTTP 200 with errors[] is returned raw, contrary to LLD §8.1. The client must check errors first (see CardClient.kt:102). Please take a look.

Comment on lines +17 to +24
internal data class PayPalCreditMessagingResult(
val mainItems: List<PayPalCreditMessageItem>,
val disclaimerItems: List<PayPalCreditMessageItem>,
val actionItems: List<PayPalCreditMessageItem>,
val messageId: String?,
val messageType: String?,
val impressionUrl: String?
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C5. Credit LLD §6.4 specifies a sealed MessageItem (Text/Image), non-null messageId/messageType, and flattened learnMoreText/learnMoreUrl. This PR exposes raw wire blocks (7 nullable fields). iOS needed a second mapping layer in #1886. §6.4 sign-off is still Pending.

  • Parse into the §6.4 shape here (preferred), or
  • Update §6.4 to match iOS #1850 and get sign-off first.

Should these models move to their own PR? The parent LLD lists Upstream Messaging as separate.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated Credit LLD §6.4 to match the iOS model (#1850).
Although Funding Instrument and Credit Messaging have separate LLDs, we're raising the PRs in layers (data models, then the client, then the view), with each layer covering both features. That's why the credit messaging models are in this PR alongside the saved payment method models

…ver URLs

Drop instruments with a blank type or label and payers with a blank email so
the LLD fallback (email only, else hidden) triggers instead of rendering an
empty row. Accept only https URLs for click, source, impression and image
URLs since they are fired automatically or opened in a Custom Tab. Unwrap
parsed results in tests so assertions cannot pass on a null result.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@balamaninayard

Copy link
Copy Markdown
Author

C6. Follow-up note
For #1719: BraintreeGraphQLClient throws only on non-2xx. HTTP 200 with errors[] is returned raw, contrary to LLD §8.1. The client must check errors first (see CardClient.kt:102). Please take a look

Already handled in #1719: PayPalSavedPaymentMethodClient checks errors[] on the HTTP 200 response and throws a BraintreeException with the GraphQL error message before reading data, the same as CardClient, with unit tests.
and updated in the LLD

@balamaninayard balamaninayard mentioned this pull request Oct 13, 2026
4 of 11 tasks
@jaxdesmarais

Copy link
Copy Markdown
Contributor

@balamaninayard this PR is missing a XO Tech Lead review and is being moved back to draft

@jaxdesmarais
jaxdesmarais marked this pull request as draft October 15, 2026 13:41
@vkspune

vkspune commented Oct 15, 2026

Copy link
Copy Markdown

Approved

@balamaninayard
balamaninayard marked this pull request as ready for review October 15, 2026 16:57
@balamaninayard

Copy link
Copy Markdown
Author

@balamaninayard this PR is missing a XO Tech Lead review and is being moved back to draft

XO tech lead - @vkspune & @anibalb2500 has reviewed , and has approved the PR. @jaxdesmarais

@noguier
noguier requested a balanced review from Copilot and removed request for Bhuvana-S100 October 16, 2026 19:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues in these isolated internal additions and accompanying tests; tests were not executed.

0 open findings

What changed in this PR

Adds internal data models for the upcoming PayPal saved-payment-method client, without changing public APIs or existing payment flows.

Changes:

  • Adds funding-instrument and credit-message response parsing.
  • Adds credit-messaging request serialization and HTTPS URL filtering.
  • Replaces the placeholder test with focused parsing, serialization, and validation tests.

Paths below are relative to PayPalSavedPaymentMethod/src/.

File Description
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​UrlValidationUnitTest.kt Tests HTTPS URL filtering.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​PayPalSavedPaymentMethodUnitTest.kt Removes the scaffold test.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​PayPalCreditMessagingRequestUnitTest.kt Tests request serialization.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalSavedPaymentMethodUnitTest.kt Tests instrument parsing and fallback behavior.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalSavedPaymentMethodTypeUnitTest.kt Tests instrument-type mapping.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalSavedPaymentMethodSummaryUnitTest.kt Tests summary parsing and malformed entries.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalPayerUnitTest.kt Tests payer parsing and defaults.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalCreditMessagingResultUnitTest.kt Tests message parsing and displayability checks.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalCreditMessageItemUnitTest.kt Tests content blocks and URL filtering.
test/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalCreditMessageItemTypeUnitTest.kt Tests content-type mapping.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​UrlValidation.kt Filters URLs to HTTPS with a host.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​PayPalCreditMessagingRequest.kt Serializes credit-messaging request bodies.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalSavedPaymentMethodType.kt Defines funding-instrument types.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalSavedPaymentMethodSummary.kt Parses funding instruments and payer details.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalSavedPaymentMethod.kt Parses individual funding instruments.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalPayer.kt Parses payer email and editability.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalCreditMessagingResult.kt Parses preferred messages and metadata.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalCreditMessageItemType.kt Defines message content types.
main/​java/​com/​braintreepayments/​api/​paypalsavedpaymentmethod/​model/​PayPalCreditMessageItem.kt Parses individual message blocks.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants