Skip to content

feat: combine payment buttons and Card Fields into one Demo fragment - #1702

Merged
noguier merged 6 commits into
card-fields-compose-featurefrom
card-fields-compose-demo
Sep 14, 2026
Merged

noguier merged 6 commits into
card-fields-compose-featurefrom
card-fields-compose-demo

Conversation

@noguier

@noguier noguier commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary of changes

  • Combine Payment Buttons and Card Fields under one fragment in the Demo app to match XML
  • Remove separate Payment Buttons Compose and Card Fields Compose fragments
  • Update Nav fragment
  • Add CHANGELOG entry

Demo Video

Screen.Recording.2026-09-09.at.5.19.16.PM.mov

AI Usage

Which AI Agent Was Used?

  • Copilot
  • Claude
  • Other (Type Name Here)

How was AI used?
Claude was used as a first reviewer on the combined fragments work

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

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

Copilot AI lite review requested due to automatic review settings September 9, 2026 22:24
@noguier
noguier requested a review from a team as a code owner September 9, 2026 22:24

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

The navigation and Demo consolidation look consistent, with only a minor UI-string localization nit identified.

Pull request overview

This PR streamlines the Demo app’s Compose entry points by consolidating the standalone “Payment Buttons Compose” and “Card Fields Compose” screens into a single Compose-based UI Components fragment, reducing fragmentation in the Demo navigation and surface area.

Changes:

  • Replace two Compose Demo entry buttons with a single “UI Components Compose” entry.
  • Update the Demo navigation graph to remove the old Compose fragments and route to the new combined fragment.
  • Add ComposeUIComponentsFragment that hosts PayPal/Venmo Compose buttons alongside Card Fields in one screen.
File summaries
File Description
Demo/src/main/res/values/strings.xml Replaces two Compose button labels with a single “UI Components Compose” string.
Demo/src/main/res/navigation/nav_graph.xml Removes old Compose fragment destinations and adds a new combined Compose destination + actions.
Demo/src/main/java/com/braintreepayments/demo/MainFragment.kt Updates the Compose entry button and navigation to the new combined fragment.
Demo/src/main/java/com/braintreepayments/demo/ComposeUIComponentsFragment.kt New combined Compose fragment integrating PayPal/Venmo buttons and Card Fields submission flow.
Demo/src/main/java/com/braintreepayments/demo/ComposeCardFieldsFragment.kt Deleted; functionality now covered by the combined Compose fragment.
Demo/src/main/java/com/braintreepayments/demo/ComposeButtonsFragment.kt Deleted; functionality now covered by the combined Compose fragment.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

@noguier noguier changed the title feat: combine payment buttons and Card Fields into one Demo fragment … feat: combine payment buttons and Card Fields into one Demo fragment Sep 9, 2026

@saralvasquez saralvasquez 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.

This looks great! The only thing I noticed during testing that might be worth coming back to is that the color selected for the buttons doesn't survive recomposition so it defaults back to blue whenever the screen is rotated. But I don't know if that's worth digging into now since this is just about bringing the UI components together into one screen

@saralvasquez

Copy link
Copy Markdown
Contributor

Op I missed the lint failure. Looks like a couple things detekt is angry about

@noguier
noguier force-pushed the card-fields-compose-feature branch from c0be0c8 to 46b0321 Compare September 10, 2026 14:13
@noguier
noguier force-pushed the card-fields-compose-demo branch from 84309e2 to 42db49f Compare September 10, 2026 14:16
Copilot AI review requested due to automatic review settings September 10, 2026 14:16

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.

🔵 Needs a closer look

The new Compose screen introduces a hardcoded UI string that should use existing string resources for localization/consistency.

Review details

Suppressed comments (1)

Demo/src/main/java/com/braintreepayments/demo/ComposeUIComponentsFragment.kt:184

  • The Card Fields submit button label is hardcoded ("Pay"), which bypasses existing string resources/localization. Since @string/card_fields_pay already exists and is used by the XML UI components screen, prefer using stringResource(...) here for consistency and translatability.
                        Text("Pay")
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 10, 2026 14:34

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.

🟡 Changes recommended

CHANGELOG.md currently breaks release automation (header casing) and contains an Unreleased note that does not reflect the actual changes in this PR.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md
Copilot AI review requested due to automatic review settings September 10, 2026 14:41

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.

🔵 Needs a closer look

There are correctness/clarity issues to address in the new Compose fragment lifecycle setup and the added CHANGELOG entry does not accurately describe the PR’s changes.

Review details

Suppressed comments (4)

Previously missed (2) — in code that hasn't changed since the last review.

Demo/src/main/java/com/braintreepayments/demo/ComposeUIComponentsFragment.kt:73

  • setViewCompositionStrategy(...) should be set before the first setContent { ... } call; setting it afterwards may not apply to the already-created composition, and you risk using the default disposal strategy for this Fragment's ComposeView.

This issue also appears on line 187 of the same file.
Demo/src/main/java/com/braintreepayments/demo/ComposeUIComponentsFragment.kt:254

  • PayPalRequestFactory.createPayPalCheckoutRequest(...) is called with many positional arguments here, which is hard to review and brittle if the factory signature changes. Other Demo code documents these arguments inline; doing the same here will make intent clearer.

Demo/src/main/java/com/braintreepayments/demo/ComposeUIComponentsFragment.kt:189

  • After setting the composition strategy before setContent, this later call becomes redundant and should be removed to avoid confusion about which strategy is in effect.
            }
            setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
        }

CHANGELOG.md:6

  • This unreleased CHANGELOG entry describes adding Compose CardFields support, but this PR only reorganizes the Demo Compose UI Components screen (the Compose CardFields demo already existed). Please update the entry to describe the Demo change so the release notes remain accurate.
* UIComponents
    * Add Compose `CardFields` support to generate a premade credit card form for submitting credit card tokenize requests
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@noguier

noguier commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

The only thing I noticed during testing that might be worth coming back to is that the color selected for the buttons doesn't survive recomposition so it defaults back to blue whenever the screen is rotated. But I don't know if that's worth digging into now since this is just about bringing the UI components together into one screen

Great catch, I confirmed that this behavior was present in the Compose PaymentButtons and is not caused by this change, since it feels a little out of scope for this PR I will create a separate ticket to address that! Thank you!

@buzzamus buzzamus 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.

Looks good! I had one tiny nit and another take it or leave it, but nothing blocking here.

"https://mobile-sdk-demo-site-838cead5d3ab.herokuapp.com/braintree-payments"
private const val DEEP_LINK_FALLBACK_SCHEME = "com.braintreepayments.demo.braintree"

@Suppress("LongMethod")

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.

Should this just be placed on the offending method, or are there several causing issues in this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great catch thank you!

savedInstanceState: Bundle?
): View {
super.onCreateView(inflater, container, savedInstanceState)
val payPalRequest = paypalRequest(requireContext())

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.

nit: variable name is payPal camelcase while paypalRequest has both P's lower

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good eye!

}
}

private fun handleNonce(nonce: PaymentMethodNonce) {

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.

nice! Love the consolidation of the separate result handling 😎

Copilot AI review requested due to automatic review settings September 11, 2026 20:41

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.

🔵 Needs a closer look

Address the two moderate findings before approval.

Review details

Suppressed comments (2)

CHANGELOG.md:6

  • This release-note entry claims that this PR adds Compose CardFields support, but the deleted ComposeCardFieldsFragment already used the existing Compose CardFields API; this change only moves that Demo UI into the combined fragment. Please describe the Demo reorganization instead so the changelog does not attribute an SDK feature addition to this patch.
    * Add Compose `CardFields` support to generate a premade credit card form for submitting credit card tokenize requests

Demo/src/main/java/com/braintreepayments/demo/ComposeUIComponentsFragment.kt:94

  • The Compose payment-button implementations render their inner row at a fixed 300dp width (UIComponents/.../PayPalButtonView.kt:47-49,82-87 and the equivalent Venmo view). Each weighted column here is only about half the phone width, so the buttons overflow and overlap on normal portrait devices. Make this layout responsive (for example, stack the columns when they cannot fit) or update the button composables to honor the available width.
                    Row(modifier = Modifier.fillMaxWidth()) {
                        Column(modifier = Modifier.weight(1f)) {
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 14, 2026 14:39

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.

🟡 Changes recommended

Resolve the changelog wording, avoid the class-level API test suppression, and fix the suppression message grammar.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (3)

CHANGELOG.md:6

  • This release-note entry claims that this change adds Compose CardFields support, but the base already contains ComposeCardFieldsFragment; this PR only moves that existing Demo implementation into the combined fragment. As written, the changelog falsely suggests a new SDK capability, so please describe the Demo reorganization or omit the entry if Demo-only changes are not released.
* UIComponents
    * Add Compose `CardFields` support to generate a premade credit card form for submitting credit card tokenize requests

LocalPayment/src/androidTest/java/com/braintreepayments/api/localpayment/LocalPaymentApiTest.kt:15

  • The new suppression message has a grammatical error: “This test are” should be “These tests are” (or “This test is”).
@Ignore("This test are failing intermittently, LocalPayment team is investigating")

LocalPayment/src/androidTest/java/com/braintreepayments/api/localpayment/LocalPaymentClientTest.kt:25

  • Applying @Ignore to the whole class removes every LocalPaymentClientTest case from the connected test suite, including the validation and browser-switch result coverage. This Demo-only refactor should not silently reduce unrelated LocalPayment coverage; remove the class-level ignore, or isolate only the known flaky methods and track the root cause.
@Ignore("This test are failing intermittently, LocalPayment team is investigating")
  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment on lines +11 to +15
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith

@Ignore("This test are failing intermittently, LocalPayment team is investigating")
import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch

@Ignore("This test are failing intermittently, LocalPayment team is investigating")
Copilot AI review requested due to automatic review settings September 14, 2026 16:39

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.

🔵 Needs a closer look

Correct the changelog and button layout, and remove or narrowly scope the LocalPayment test ignores.

Review details

Suppressed comments (6)

Previously missed (2) — in code that hasn't changed since the last review.

Demo/src/main/java/com/braintreepayments/demo/ComposeUIComponentsFragment.kt:97

  • Each payment button renders a fixed 300dp-wide row, but this Row gives each weighted column only about half the screen width after padding and spacing. On typical phones the PayPal and Venmo buttons will overflow or be clipped; keep these fixed-width buttons in full-width containers or use a responsive layout instead of placing them side by side.
    LocalPayment/src/androidTest/java/com/braintreepayments/api/localpayment/LocalPaymentClientTest.kt:25
  • This class-level ignore disables every LocalPayment client instrumentation test, so CI can no longer detect regressions in this suite. The combined UI-components Demo change is unrelated to these tests; please remove this ignore and address or narrowly scope the intermittent test failures with a tracking issue instead of suppressing the whole class.

CHANGELOG.md:6

  • The PR reuses the existing Compose CardFields API in the Demo app; it does not add SDK support. This entry therefore misstates the change and duplicates the existing CardFields release note at CHANGELOG.md:79-80. Replace it with a Demo-specific description of the combined fragment, or omit the entry if Demo-only changes are not released.
* UIComponents
    * Add Compose `CardFields` support to generate a premade credit card form for submitting credit card tokenize requests

LocalPayment/src/androidTest/java/com/braintreepayments/api/localpayment/LocalPaymentApiTest.kt:15

  • This class-level ignore disables every LocalPayment API instrumentation test, so CI can no longer detect regressions in this suite. The combined UI-components Demo change is unrelated to these tests; please remove this ignore and address or narrowly scope the intermittent test failures with a tracking issue instead of suppressing the whole class.
@Ignore("This test are failing intermittently, LocalPayment team is investigating")

LocalPayment/src/androidTest/java/com/braintreepayments/api/localpayment/LocalPaymentApiTest.kt:15

  • The ignore rationale has a grammar error and is missing the article before the team name. Use “These tests are failing intermittently; the LocalPayment team is investigating.”
@Ignore("This test are failing intermittently, LocalPayment team is investigating")

LocalPayment/src/androidTest/java/com/braintreepayments/api/localpayment/LocalPaymentClientTest.kt:25

  • The ignore rationale has a grammar error and is missing the article before the team name. Use “These tests are failing intermittently; the LocalPayment team is investigating.”
@Ignore("This test are failing intermittently, LocalPayment team is investigating")
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@noguier
noguier merged commit 2dd2e2f into card-fields-compose-feature Sep 14, 2026
10 checks passed
@noguier
noguier deleted the card-fields-compose-demo branch September 14, 2026 18:19
noguier added a commit that referenced this pull request Sep 16, 2026
* feat: add compose card number field (#1677)

* feat: add compose card number functionality and demo

* pr-feedback: fix spacing and round card corners

* pr-feedback: rename base text input class

* pr-feedback: dimens strings, error icon, content description, composition strategy

* fix: card number description

* fix: rename state class to controller

* feat: add card fields compose expiration field (#1678)

* feat: add compose card fields expiration date field

* fix: lint issues

* pr-feedback: consolidate test classes

* fix: add contentDescription

* fix: lint issue

* fix: rename controller

* fix: rename state in unit tests

* feat: add compose cvv field (#1681)

* feat: add cvv field

* test: add unit tests

* fix: lint issues

* fix: resolve length truncation bug

* fix: cvv popup spacing issue

* fix: allow paste for cvv

* fix: narrow screen expiration overflow

* pr-feedback: dimens values

* fix: add contentDescription

* fix: complexity lint issue

* fix: re-add value removed in merge conflict

* pr-feedback: fix unit tests, add visual remember, resolve UI bug

* feat: add compose pay button and processing (#1683)

* feat: add compose pay button and processing

* pr-feedback: update unit tests, add demo comment, fix process death bug, and remove initialize

* feat: add compose card field analytics (#1685)

* Compose autoadvance (#1687)

* initial commit of the autoadvance

* feat: add compose card fields expiration date field

* fix: lint issues

* pr-feedback: consolidate test classes

* fix: fix lint

* fix: fix KDoc wording

* fix: address PR comment to abstract duplicate code

---------

Co-authored-by: Sara Vasquez <saravasquez@paypal.com>

* Compose CardFields Instrumentations Tests (#1692)

* feat: add instrumentation tests to cover CardFields Compose module

* fix: fix lint

* fix: fix failing ci tests

* fix: address PR comment to add more tests

* feat: add compose card fields README entry (#1691)

* feat: add readme entry for compose card fields

* fix: tweak language

* fix: updated code block to match controller

* docs: add missing kdocs

* fix: remove unnecessary param comments

* feat: combine payment buttons and Card Fields into one Demo fragment (#1702)

* feat: combine payment buttons and Card Fields into one Demo fragment to match XML

* fix: address PR Comment and add `CHANGELOG` entry

* fix: address PR Comment

* fix: address PR Comments

* fix: ignore failing test to ensure all other tests pass

* fix: fix failing test in UI components Compose

* pr-feedback: add cvv popup anchor and fix dp to sp conversion bug

* fix: PR suggestions and a patch to resize text in PaymentButtons style buttons to fit smaller devices

* fix: revert back to using KeyboardType.Number to allow pasting an input

---------

Co-authored-by: Sara Vasquez <98496950+saralvasquez@users.noreply.github.com>
Co-authored-by: Sara Vasquez <saravasquez@paypal.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants