Commit graph

11 commits

Author SHA1 Message Date
6ceb9375de modified: Makefile
new file:   docs/state-machine.dot
	new file:   docs/state-machine.dot.svg
	renamed:    state-machine.svg -> docs/state-machine.svg
2025-09-30 15:43:54 -04:00
0b5554e431 modified: docs/crypto-payments-state-machine.md
modified:   state-machine.svg
2025-09-30 14:46:47 -04:00
c7caae8d4a Fix crypto payment state machine logic and naming consistency
Major fixes:
1. Remove invalid received→expired transition
   - Payments that reach 'received' state cannot expire
   - Only pending payments can expire
   - Updated VALID_TRANSITIONS and tests accordingly

2. Rename STATUS_DOUBLEPAY_REFUND to STATUS_DOUBLEPAY_REFUNDED
   - Maintains consistency with all other past-tense status names
   - Updated all references across codebase and tests

3. Add INITIAL_WAITING_STATUSES semantic group
   - Groups states that are entry points: pending, latepay_refunded, doublepay_refunded
   - These states don't transition from 'received' - they represent initial states
   - Added is_initial_waiting_state() helper method

4. Update semantic groups
   - Removed latepay_refunded and doublepay_refunded from FAILED_PAYMENT_STATUSES
   - These are now in INITIAL_WAITING_STATUSES as they represent entry points

5. Fix mermaid diagram label
   - confirmed_overpay_not_refunded now correctly labeled as "Terminal Success (Not Refunded)"
   - Remove invalid received→expired transition from documentation

This improves the logical consistency of the state machine and aligns
the naming conventions across all status constants.
2025-09-30 14:34:11 -04:00
5c67b9ca4c Fix all crypto payment test failures and status constant issues
- Fix duplicate detection logic to prevent amount accumulation when new transactions arrive to already-processed payments
- Fix status constant naming errors: STATUS_CONFIRMED_OVERPAID → STATUS_CONFIRMED_OVERPAY, STATUS_EXPIRED_REFUNDED → STATUS_LATEPAY_REFUNDED
- Fix SweepRestockingFeeTests mock setup: add missing refund_confirmations, get_coin_config patches, and proper XMR client mocks
- Correct overpayment test expectations: restocking fee sweep happens later after refund confirmation, not immediately
- Update test assertions to match actual implementation behavior (transfer vs sweep_all for XMR)
- Add comprehensive mock configurations for DOGE/XMR atomic units and balance methods

All 108 crypto payment tests now pass. Fixes critical duplicate payment processing bug and aligns test expectations with production behavior.
2025-09-30 13:56:42 -04:00
923bd873f2 Add comprehensive crypto payment state transition validation
* Implement complete state machine with 17 test scenarios
* Add priority-based processing order validation
* Include property-based testing for state transitions
* Add graph analysis for state machine integrity
* Validate all payment lifecycle paths
* Ensure robust error handling and logging
* Remove temporary debug files and consolidate test structure
2025-09-30 11:26:44 -04:00
c1a936539e deleted: debug_auth_headers.py
deleted:    debug_digest_details.py
	deleted:    debug_monero_auth.py
	renamed:    CRYPTO_WATCHER_FLOW.md -> docs/CRYPTO_WATCHER_FLOW.md
	deleted:    test_digest_auth_local.py
	deleted:    test_dogecoin_client.py
	deleted:    test_monero_auth.py
	deleted:    test_monero_client.py
	deleted:    test_requests_lib.py
	deleted:    test_urllib_variants.py
2025-09-28 15:26:42 -04:00
c3c05796da Remove pooled sweep behavior and implement individual payment sweeping
- Remove pooled_sweep logic from both Monero and Dogecoin sweep functions
- Each payment now swept individually for better accounting and audit trail
- Insufficient balance now returns False to retry later instead of fake pooled_sweep
- Update all tests to expect new behavior (False for insufficient balance)
- Update documentation to reflect 1:1 payment-to-sweep mapping
- Add link to refund address configuration in crypto checkout template
- All crypto watcher tests now passing with new individual sweep logic
2025-09-24 16:03:50 -04:00
e4990a5462 Document Monero RPC get_transfers unlocked field defect
- Add comprehensive documentation of RPC inconsistency
- Include symptoms, impact, workarounds, and references
- Establishes framework for documenting future Monero RPC issues
2025-09-24 15:03:31 -04:00
c4d9192540 Improve crypto payment handling and out-of-stock refunds
- Add proper inventory checking before crypto payment completion
- Implement sequential (FIFO) crypto payment processing to prevent race conditions
- Add comprehensive out-of-stock refund handling with two statuses:
  - STATUS_OUT_OF_STOCK_REFUNDED: Full refund to customer (no restocking fee)
  - STATUS_OUT_OF_STOCK_NO_REFUND: Sweep to shop when no refund address
- Use sweep_all with subaddr_indices for Monero to ensure complete fund recovery
- Use sendtoaddress with subtractfeefromamount for Dogecoin fee handling
- Add refund tracking fields (refund_reason, refund_tx_hash, refund_amount)
- Update MONERO.rst with subaddress isolation and refund processing documentation
- Ensure action buttons are removed for non-pending crypto quotes to prevent double payments
2025-09-24 09:35:07 -04:00
b2a47f6789 Move crypto documentation to docs directory
- Move CRYPTO.rst to docs/CRYPTO.rst
- Move CRYPTO_PROBLEMS.rst to docs/CRYPTO_PROBLEMS.rst

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 13:21:15 -04:00
68d4ccfc25 Dogecoin payment support 2025-09-23 11:17:05 +00:00