Repository navigation
Feature : Saved payment method data models - #1718
balamaninayard wants to merge 9 commits into
Conversation
…od and credit messaging data models
…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>
|
Do we need the |
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>
|
LGTM |
|
/inner source |
|
/ready |
mzlangreder
left a comment
There was a problem hiding this comment.
Requesting changes:
- Credit request attributes differ from iOS (C1).
- Parsers are looser than the LLD (C2).
- Server URLs aren't validated (C3).
- Some tests can't fail (C4).
- Credit model shape and scope need a decision (C5).
- 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.
| 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? | ||
| ) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
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. |
…ethod-data-models
…ethod-data-models
|
@balamaninayard this PR is missing a XO Tech Lead review and is being moved back to draft |
|
Approved |
XO tech lead - @vkspune & @anibalb2500 has reviewed , and has approved the PR. @jaxdesmarais |
There was a problem hiding this comment.
🟢 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.
Summary of changes
PayPalSavedPaymentMethodClientin the follow-up PR.model/):PayPalSavedPaymentMethodSummary,PayPalSavedPaymentMethod,PayPalSavedPaymentMethodType,PayPalPayer— parse thepaypalFundingInstrumentDetailsGraphQL response.PayPalCreditMessagingRequest(POST body forv2/credit/fetch-presentment-messages, built withtoJson()), plusmodel/PayPalCreditMessagingResult,PayPalCreditMessageItem,PayPalCreditMessageItemType.flow_context.attributessendsBRAND_BRAINTREE,EXPERIENCE_ANDROID_SDK,EXPERIENCE_VIEW_EDIT_FI,EXPERIENCE_EXTERNAL_DIRECT.model/subpackage to keep them separate from the request body and the upcoming client; all types areinternal.Steps to test
./gradlew :PayPalSavedPaymentMethod:testReleaseUnitTest./gradlew :PayPalSavedPaymentMethod:lintRelease detektAI Usage
Which AI Agent Was Used?
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
Checklist
view-edit-fi-beta-featuremerges tomainAuthors
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:
/inner sourceon this PR — this will automatically add theinner sourceandtech lead review requiredlabels. Open the PR in a draft state./readyon this PR — this will automatically remove thetech lead review requiredlabel. Move the PR to ready to review.Inner Source Checklist