Skip to content

feat: implement InvoiceContract on Soroban with full invoice lifecycle#88

Open
jerrybarry wants to merge 4 commits intoMetroLogic:mainfrom
jerrybarry:feature/invoice-soroban-contract
Open

feat: implement InvoiceContract on Soroban with full invoice lifecycle#88
jerrybarry wants to merge 4 commits intoMetroLogic:mainfrom
jerrybarry:feature/invoice-soroban-contract

Conversation

@jerrybarry
Copy link
Copy Markdown

Summary

Adds a Soroban InvoiceContract that stores invoice lifecycle on-chain, prevents double payment via payment_id, emits events for issued / paid / cancelled transitions, and restricts mark_paid to the configured Payment Processor address.

Closes #39.

Changes

  • fluxapay/src/invoice.rsInvoiceContract with Invoice, InvoiceStatus, storage DataKey, and InvoiceError; entrypoints: invoice_initialize, create_invoice, issue_invoice, mark_paid, cancel_invoice, get_invoice, plus get_admin / get_payment_processor for tests and integrations.
  • fluxapay/src/lib.rspub mod invoice; and RefundManager storage fixes (FluxaDataKey) so the crate builds cleanly.
  • Tests — coverage for initialization, duplicate create_invoice, issue_invoice / status errors, mark_paid (including AlreadyPaid), cancel_invoice, and get_invoice / NotFound.
  • Build fixes — repairs in fx_oracle.rs and merchant_registry.rs where corrupted code blocked compilation; payment-related tests grant the MERCHANT role with payment_grant_role before create_payment where required.

Design notes

  • invoice_initialize (not initialize) — multiple contracts share one WASM artifact; exported names must be unique, consistent with oracle_initialize / merchant_initialize.
  • mark_paid — returns AlreadyPaid when payment_id is already set (checked before status) so a second settlement maps to double-payment, not a generic invalid status.

Verification

cargo test
cargo build --target wasm32-unknown-unknown --release
cargo clippy --all-targets

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@jerrybarry Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…oroban-contract

Resolve MetroLogic upstream conflicts by taking upstream sources and snapshots,
then wire invoice module and fix multi-contract WASM symbol clashes:
- Rename PaymentProcessor::grant_role to payment_grant_role
- Rename InvoiceContract getters to invoice_get_admin / invoice_get_payment_processor
- Align auth_test and test.rs with Metro merchant initialize and refund grant_role API

Made-with: Cursor
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.

[Contract] Implement InvoiceContract on Soroban for on-chain invoice state

1 participant