You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add PayPal vault flow for editing payment method (#71)
* feat: add PayPal vault flow for editing payment method
- Add PayPal vault button rendering in ia-mgc-braintree-manager
- Wire paypalBlockerSelected to set PaymentProvider.PayPal
- Auto-dispatch UpdatePaymentMethod on PayPal authorization (no submit button needed)
- Fix setNewPaymentMethod() to correctly set paypalEmail, clear card fields, update paymentMethodType
- Fix 'Paypal' casing in plans.ts to match PaymentProvider.PayPal
- Show PayPal email in payment method view mode
- Hide CC fields via CSS when PayPal is selected
- Add PayPalVaultError event with UI error message on SDK failure
- Update demo to show PayPal nonce and email on UpdatePaymentMethod
- Add integration tests for PayPal selection and UpdatePaymentMethod dispatch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: handle unhandled rejection in renderPayPalVaultButton
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: resolve ESLint errors in PayPal payment method changes
- Fix import order for PaymentProvider in plan.ts and plans.ts
- Add file-level no-console disable in braintree-manager.ts
- Add console.log to empty PayPal delegate methods
- Add eslint-disable-next-line for console.log in payment-method.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: resolve high priority code review issues in PayPal payment flow
- Fix race condition in braintree-manager: set paypalButtonRendered optimistically before async call, reset on error to prevent infinite retry
- Fix plans.ts: Venmo display was showing paypalEmail instead of venmoUsername
- Add tests: PayPal email fallbacks, old btData snapshot, PayPalVaultError, hidden submit button, Venmo provider switch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: correct PayPal email fallback test to assert 'not_found'
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: resolve remaining code review issues
- Use PaymentProvider enum consistently in plans.ts (replace string literals)
- Remove debug console.log from contactFormSection getter
- Replace self=this alias with arrow functions in PayPal delegate
- Remove unused setupPaymentHandlers() method
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: add session notes for Apr 6, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat: render PayPal button eagerly on BraintreeManagerSetupComplete
Align with iaux-donation-form pattern: render the Braintree PayPal iframe
into the slot immediately when setup completes, rather than lazily on user
selection. Removes the displayPayPal property from ia-mgc-braintree-manager
since it is no longer needed. Adds test verifying the eager render is triggered.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: remove unused displayContactForm variable in contactFormSection getter
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: apply prettier formatting to PayPal branch changes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: apply prettier formatting to plans.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: fix failing tests for PayPal selection event and Venmo payment method
- Fix test dispatching wrong event name (paypalBlockerSelected → paypalSelected)
- Add explicit Venmo branch in setNewPaymentMethod to map details.username
to venmoUsername and clear card fields (cardType, last4, expiration)
- Add username field to BTPaymentMethodUpdate.details type
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: add new tests for PayPal slot, cancel button, braintree getter, and Venmo fields
- PayPal slot (#ia-mgc-paypal-button) exists in DOM when currentlyEditing is true
- Cancel button resets selectedPaymentProvider and closes the form
- braintreeManagerElement getter returns ia-mgc-braintree-manager element
- Venmo branch clears expirationMonth and expirationYear from previous btdata
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Code reviewed the `display-cents` branch and addressed all review items from the initial review.
7
+
8
+
## Code Review Items & Resolutions
9
+
10
+
1.**`Receipt.amount` and `Receipt.amountFormatted` identical** — Removed `amountFormatted`, kept `amount`. Updated `receipts.ts` reference. (commit `2d3c8ff`)
11
+
12
+
2.**`Receipt.currencySymbol` / `MonthlyPlan.currencySymbol` dead code** — Removed both getters and their tests since `formatCurrency` handles symbols via `Intl.NumberFormat`. (commit `bdf4a2e`)
13
+
14
+
3.**Unsafe `as number` cast in `coveredFeesText`** — Replaced with falsy check. `undefined`, `null`, and `0` now return fallback text `"I'll generously cover the fees."`. Added 3 unit tests. (commit `df00ed3`)
15
+
16
+
4.**"Invalid amount" as user-facing text** — Decided to keep current behavior.
17
+
18
+
5.**Hardcoded `'en-US'` locale** — Added `currencyToLocale` map (USD only) with `en-US` fallback. Added unit tests for `formatCurrency`. (commit `04605e0`)
19
+
20
+
6.**No unit tests for `formatCurrency()`** — Added `test/utils/currency-format.test.ts` with 11 tests covering USD, EUR, GBP, zero, negative, NaN, Infinity, rounding, and `currencyToSymbol` map. (commit `04605e0`)
21
+
22
+
7.**Hardcoded `$` prefix in input form (nit)** — Added `currencyToSymbol` map, replaced hardcoded `$` with map lookup. (commit `62a5dcc`)
23
+
24
+
## Key Decisions
25
+
- Keep `amount` over `amountFormatted` on Receipt model
26
+
-`coveredFeesText` uses fallback text when fee is `0` (not `$0.00`)
27
+
-`currencyToLocale` and `currencyToSymbol` maps only contain USD for now
28
+
- "Invalid amount" string kept as-is for non-finite inputs
29
+
30
+
## Commits (5 new)
31
+
-`04605e0` add currency-to-locale map and unit tests for formatCurrency
32
+
-`df00ed3` fix unsafe cast in coveredFeesText and add unit tests
33
+
-`bdf4a2e` remove dead currencySymbol getters from Plan and Receipt models
34
+
-`2d3c8ff` remove duplicate amountFormatted getter from Receipt model
35
+
-`62a5dcc` replace hardcoded $ prefix with currencyToSymbol map lookup
- Updated `coveredFeesText` getter in `amount.ts` to derive fee from `this.newAmount` using `DonationPaymentInfo.calculateFeeAmount()` instead of `this.donationPaymentInfo?.feeAmountCovered`
9
+
- Shows generic text when `newAmount` is 0, dynamic fee text when filled
- Lint, prettier, and circular dependency checks all pass
20
+
- Branch: `display-cents`
21
+
22
+
## Notes
23
+
-`dist/test/receipts.test.js` was a stale compiled artifact with no source `.ts` file on current branch or main (only existed on `unit-tests-2` branch). Was deleted during debugging — gets regenerated by `tsc` if source exists.
24
+
-`DonationPaymentInfo` (feeAmountCovered, calculateTotal) comes from external package `@internetarchive/donation-form-data-models` — cannot be modified in this repo.
25
+
26
+
---
27
+
28
+
## Session 2 - Time Display Audit & Fixes
29
+
30
+
### Task
31
+
Audit all places where time/dates are displayed and fix locale/timezone issues.
32
+
33
+
### Key Decisions
34
+
- Fixed invalid `'US-EN'` locale tags to `'en-US'` (BCP 47) in `demo/index.html`
35
+
- Switched `nextBillingDateLocale` and `lastBillingDateLocale` from `Date.toLocaleDateString()` to `Intl.DateTimeFormat` with `timeZone: 'UTC'` to prevent off-by-one-day display for users west of UTC
36
+
- Added try/catch to return `"Invalid date"` instead of throwing `RangeError` on bad date strings
37
+
- Added early return pattern to `lastBillingDateLocale` to match `nextBillingDateLocale` style
- All 38 plan model tests passing (4 new tests added)
44
+
- Full test suite (73+ tests) passing
45
+
- Squashed into single commit `8ae7c84` on branch `pin-us-locale`
46
+
47
+
### Audit Findings (for future work)
48
+
-`date.ts:217-228`: "second donation this month" validation compares local-time user input against UTC server date — potential timezone mismatch near month boundaries
49
+
- Receipt dates (`receipt.ts`) are raw strings passed through from consumers — no formatting done in the model
0 commit comments