Skip to content

Fix payment correctness bugs (iteration 10) #1184

Description

@dev-stephenx

Context

Ongoing fix payment correctness bugs initiative for AgenticPay, tracked as one of several planned iterations to keep scope manageable and reviewable.

Proposed work

Deliver the next increment of: Fix payment correctness bugs. Break the work into a focused, reviewable change set.

Acceptance criteria

  • Scope is clearly defined in the PR
  • Tests added or updated
  • Documentation updated where relevant

Activity

  1. OmniZlatoon commented on Oct 17, 2026

    @OmniZlatoon

    @OmniZlatoon has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I remain loyal sir. I can handle this effortlessly based in the task scope and description provided.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @OmniZlatoon to this issue.

  2. SagaciousBoss commented on Oct 17, 2026

    @SagaciousBoss
    Contributor

    @SagaciousBoss has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I would love to apply for this issues , I can handle it .

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @SagaciousBoss to this issue.

  3. drips-wave commented on Oct 17, 2026

    @drips-wave

    Congratulations, @SagaciousBoss! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @SagaciousBoss: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  4. SagaciousBoss commented on Oct 17, 2026

    @SagaciousBoss
    Contributor

    Delivered in #1290 (merged).

    Payment correctness work in that PR:

    • getCurrentRate returned 1.0 for any pair it did not recognise, so GBP -> BTC quoted one Bitcoin per pound and confirmConversion recorded it. Unquoted pairs now raise UNSUPPORTED_FIAT_PAIR; lockRate refuses to create a lock and GET /api/v1/stripe/rates answers 400.
    • Added backend/src/services/money.ts (bigint minor units, half-away-from-zero rounding) and routed FX conversion through it. 33.33 * 1.08 is 35.99640000000001 as a double, so the crypto amount disagreed with the fiat amount charged.
    • lockRate accepted NaN, negative and infinite amounts, producing locks whose conversion amount was NaN. It now validates and normalises sub-cent input to the currency's minor units.
    • processFiatRefund recorded status 'failed' (indistinguishable from a real failure), returned true without refunding anything when no Stripe payment intent was present, and was not idempotent, so a retry issued a second refund. It now records 'refunded' with refundedAt and collapses concurrent calls onto one refund.
    • getConversion / listConversions returned live internal references, letting a caller mutate a financial record. They now return snapshots.
    • idempotency() did not bind a key to its payload: reusing a key with a different body silently replayed the earlier response, so a caller could believe it created a new resource while holding the old one. It now fingerprints the body (object keys sorted) and answers 409 idempotency_key_reuse_mismatch on divergence. The response cache is also bounded instead of growing without limit.
    • Revenue pool recipient ratios were validated individually but not in aggregate, so a pool could be configured to distribute more than 100% of what it received. addRecipient and updateRecipientRatio now enforce sum(ratioBps) <= 10000.
    • recordDistribution had no idempotency on txHash, so a chain reorg or a retried indexer double-counted revenue against every recipient. It now returns the existing row on replay.

    Tests: services/__tests__/money.test.ts (new), plus additions to services/__tests__/fiat-crypto.test.ts, middleware/__tests__/idempotency.test.ts and a new services/revenue-pool/__tests__/revenue-pool.test.ts.

    Docs: docs/PAYMENT_CORRECTNESS.md.

  5. drips-wave commented on Oct 17, 2026

    @drips-wave

    This issue has been completed by @SagaciousBoss as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @SagaciousBoss: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  6. added a commit that references this issue on Oct 17, 2026
    bbdef79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions