This PR introduces a single-file, enterprise-grade Marketplace + Audit + Settlement engine for pi-sdk-rails. The goal is to extend (not modify) the existing Pi SDK Rails engine with production-ready capabilities required by multi-merchant / marketplace applications, while keeping full backward compatibility.#1
Open
Clawue884 wants to merge 1 commit intopi-apps:mainfrom
Open
This PR introduces a single-file, enterprise-grade Marketplace + Audit + Settlement engine for pi-sdk-rails. The goal is to extend (not modify) the existing Pi SDK Rails engine with production-ready capabilities required by multi-merchant / marketplace applications, while keeping full backward compatibility.#1Clawue884 wants to merge 1 commit intopi-apps:mainfrom
Clawue884 wants to merge 1 commit intopi-apps:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multi-merchant support
One Rails app → many merchants → many orders → unified Pi SDK
Immutable audit trail
Append-only audit logs for reconciliation & compliance
Transaction reconciliation engine
Detects incomplete, inconsistent, or invalid payment states
Automated settlement
Merchant balance crediting with configurable platform fee
Marketplace-ready routing
Explicit order → merchant → transaction resolution
Risk & safety checks
Merchant status & transaction sanity validation
Single-file implementation
Easy to review, easy to adopt, zero generator complexity
Architecture Highlights
Implemented as one Ruby file:
lib/pi_sdk_marketplace_audit.rb
Uses:
ActiveSupport::Concern for model extensions
Service-style engines (Reconciliation, Settlement, Risk)
No changes to existing Pi SDK protocol or callbacks
Automatically hooks into existing models if present (Merchant, Order, PiTransaction, etc.)