Skip to content

feat: state cards only valid in US - #1426

Merged
HashEngineering merged 12 commits into
masterfrom
feat/dashspend-mark-country
Sep 23, 2025
Merged

feat: state cards only valid in US#1426
HashEngineering merged 12 commits into
masterfrom
feat/dashspend-mark-country

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Sep 13, 2025

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

add a note that says gift cards are only valid in the United States.

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Summary by CodeRabbit

  • New Features
    • Added a country availability note on gift card details indicating US-only support.
  • Bug Fixes
    • Merchant availability now reflects enablement status only, preventing unintended activation from fixed denominations.
  • Chores
    • Adjusted internal purchase timing log to report seconds instead of milliseconds.

@coderabbitai

coderabbitai Bot commented Sep 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adjusts merchant activation logic in CTXSpendViewModel, tweaks a gift-card log unit label, adds a “country availability” TextView to the item details layout, and introduces a corresponding string resource.

Changes

Cohort / File(s) Summary
CTXSpend merchant.active logic
features/exploredash/src/main/java/.../ctxspend/CTXSpendViewModel.kt
merchant.active is now assigned solely from this.enabled (merchant.active = this.enabled); removed fallback that used denominationType == DenominationType.Fixed and the related TODO. Other merchant fields unchanged.
Gift card log unit change
features/exploredash/src/main/java/.../dialogs/GiftCardDetailsViewModel.kt
Log message label changed from milliseconds to seconds (event:process_gift_card_purchase: {} s); time computation remains in seconds.
Layout: country availability notice
features/exploredash/src/main/res/layout/item_details_view.xml
Added TextView with id country_availability_text (style Overline.Secondary), visible by default, constrained above temporary_unavailable_text with 16dp bottom margin.
Strings: new resource
features/exploredash/src/main/res/values/strings-explore-dash.xml
Added country_availability string: "This card works only in the United States".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as UI/View
  participant VM as CTXSpendViewModel
  participant M as MerchantModel

  rect rgba(230,245,255,0.5)
  note over VM,M: updateMerchantDetails (new)
  UI->>VM: trigger updateMerchantDetails(...)
  VM->>VM: evaluate this.enabled, read other fields
  VM->>M: set active = this.enabled
  VM->>M: set savingsPercentage, minCardPurchase, maxCardPurchase, fixedDenomination, denominations
  VM-->>UI: emit updated merchant state
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • Syn-McJ

Poem

A rabbit taps keys with a careful hop,
Flips “active” by one tidy toggle—pop!
Logs count seconds now, neat and small,
A signpost tells where cards can call.
I thump for order — hop, ship, and stop. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: state cards only valid in US" addresses the PR's main intent of surfacing a US-only notice for cards, so it is related to the changeset; however the phrase "state cards" is ambiguous and likely a typo for "gift cards," which reduces clarity.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/dashspend-mark-country

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88ff5c8 and 0615630.

📒 Files selected for processing (1)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HashEngineering

Copy link
Copy Markdown
Collaborator Author

@coderabbitai - please review

@coderabbitai

coderabbitai Bot commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

@HashEngineering I'll review the PR changes for you.


🧠 Learnings used
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1410
File: wallet/src/de/schildbach/wallet/data/InvitationLinkData.kt:79-84
Timestamp: 2025-07-12T07:12:04.769Z
Learning: HashEngineering prefers to handle defensive validation improvements for URI parsing in follow-up PRs rather than including them in the current PR when the main focus is on replacing Firebase with AppsFlyer.

Learnt from: HashEngineering
PR: dashpay/dash-wallet#1423
File: wallet/src/de/schildbach/wallet/ui/EditProfileActivity.kt:418-446
Timestamp: 2025-08-25T14:48:39.247Z
Learning: HashEngineering prefers to refactor and reuse topup code for balance validation logic improvements in DashPay activities like EditProfileActivity, rather than implementing individual fixes in the current PR.

Learnt from: HashEngineering
PR: dashpay/dash-wallet#1422
File: common/src/main/java/org/dash/wallet/common/util/Constants.kt:68-69
Timestamp: 2025-08-25T15:00:20.777Z
Learning: HashEngineering prefers to keep HTTP logging enabled in release mode (using log.info instead of gating with BuildConfig.DEBUG) to debug production errors, even though this may leak URLs in production logs. This is a deliberate trade-off for debugging purposes in the Dash wallet project.
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
features/exploredash/src/main/res/values/strings-explore-dash.xml (1)

252-252: Copy polish (optional)

Consider clearer phrasing: “Gift cards are only valid in the United States.”

-    <string name="country_availability">This card works only in the United States</string>
+    <string name="country_availability">Gift cards are only valid in the United States</string>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af92470 and 88ff5c8.

📒 Files selected for processing (4)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt (1 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt (1 hunks)
  • features/exploredash/src/main/res/layout/item_details_view.xml (1 hunks)
  • features/exploredash/src/main/res/values/strings-explore-dash.xml (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1417
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/explore/MerchantDao.kt:0-0
Timestamp: 2025-08-08T16:48:49.964Z
Learning: In PR dashpay/dash-wallet#1417, HashEngineering chose to defer adding Room indexes for gift_card_providers (provider, denominationsType, merchantId) to a follow-up PR; do not block the current PR on this optimization. Files: features/exploredash/.../data/explore/MerchantDao.kt and features/exploredash/.../data/dashspend/GiftCardProvider.kt.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1390
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt:129-145
Timestamp: 2025-05-08T18:11:40.249Z
Learning: The hardcoded test data in the purchaseGiftCard() function of CTXSpendViewModel is intentionally left in place for testing the error handling for limit mismatch, and will be fixed later before release.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1422
File: common/src/main/java/org/dash/wallet/common/util/Constants.kt:68-69
Timestamp: 2025-08-25T15:00:20.777Z
Learning: HashEngineering prefers to keep HTTP logging enabled in release mode (using log.info instead of gating with BuildConfig.DEBUG) to debug production errors, even though this may leak URLs in production logs. This is a deliberate trade-off for debugging purposes in the Dash wallet project.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1410
File: wallet/src/de/schildbach/wallet/data/InvitationLinkData.kt:79-84
Timestamp: 2025-07-12T07:12:04.769Z
Learning: HashEngineering prefers to handle defensive validation improvements for URI parsing in follow-up PRs rather than including them in the current PR when the main focus is on replacing Firebase with AppsFlyer.
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1423
File: wallet/src/de/schildbach/wallet/ui/EditProfileActivity.kt:418-446
Timestamp: 2025-08-25T14:48:39.247Z
Learning: HashEngineering prefers to refactor and reuse topup code for balance validation logic improvements in DashPay activities like EditProfileActivity, rather than implementing individual fixes in the current PR.
📚 Learning: 2025-05-08T18:11:40.249Z
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1390
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt:129-145
Timestamp: 2025-05-08T18:11:40.249Z
Learning: The hardcoded test data in the purchaseGiftCard() function of CTXSpendViewModel is intentionally left in place for testing the error handling for limit mismatch, and will be fixed later before release.

Applied to files:

  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt
📚 Learning: 2025-08-08T16:48:49.964Z
Learnt from: HashEngineering
PR: dashpay/dash-wallet#1417
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/explore/MerchantDao.kt:0-0
Timestamp: 2025-08-08T16:48:49.964Z
Learning: In PR dashpay/dash-wallet#1417, HashEngineering chose to defer adding Room indexes for gift_card_providers (provider, denominationsType, merchantId) to a follow-up PR; do not block the current PR on this optimization. Files: features/exploredash/.../data/explore/MerchantDao.kt and features/exploredash/.../data/dashspend/GiftCardProvider.kt.

Applied to files:

  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt
🔇 Additional comments (3)
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt (1)

194-196: Unit label now matches seconds; verify analytics expects seconds

timeElapsed is already in seconds — confirm downstream dashboards/alerts/ingestion for AnalyticsConstants.Process.PROCESS_GIFT_CARD_PURCHASE expect seconds (not milliseconds).
Location: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt:194-196
Search to run: rg -n -S 'PROCESS_GIFT_CARD_PURCHASE|AnalyticsConstants.Parameter.TIME'

features/exploredash/src/main/res/layout/item_details_view.xml (1)

270-281: Make country_availability_text GONE by default and anchor above pay button

android:visibility="visible" shows the US‑only note for all item types; set default to GONE, toggle visibility from code only for the gift‑card flow, and anchor it to the pay button instead of chaining through a view that may be GONE.

File: features/exploredash/src/main/res/layout/item_details_view.xml (lines 270-281)

Apply:

-        <TextView
+        <TextView
             android:id="@+id/country_availability_text"
             style="@style/Overline.Secondary"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/country_availability"
-            android:layout_marginBottom="16dp"
-            android:visibility="visible"
+            android:layout_marginBottom="16dp"
+            android:visibility="gone"
+            tools:visibility="visible"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintBottom_toTopOf="@id/temporary_unavailable_text"
+            app:layout_constraintBottom_toTopOf="@id/pay_btn"
             />

Confirm visibility is toggled from code only when the gift‑card flow is available and that @id/pay_btn exists (sandbox search returned no results; manual verification required).

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt (1)

229-231: Activation logic change risks hiding fixed‑denomination merchants — verify or revert

File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt (lines 229–231)

merchant.active is now set to only this.enabled; merchant.active is used to gate purchase/visibility (PurchaseGiftCardFragment, ItemDetails, SearchFragment and explore filters/tests). As written, fixed‑denomination merchants may be hidden when the API returns enabled == false.

Apply if revert is desired:

-                merchant.active = this.enabled
+                merchant.active = this.enabled || this.denominationType == DenominationType.Fixed

@HashEngineering
HashEngineering changed the base branch from fix/send-delays to master September 23, 2025 00:26
@HashEngineering
HashEngineering merged commit 6705818 into master Sep 23, 2025
3 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Sep 23, 2025
3 tasks
@HashEngineering
HashEngineering deleted the feat/dashspend-mark-country branch March 17, 2026 15:47
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.

2 participants