Repository navigation
fix(upi): M4.3.4 payment provider contract determination (Outcome B) & milestone M4 closure - #34
Open
Satelink-Protocol wants to merge 3 commits into
Conversation
…& milestone M4 closure
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
This PR resolves the remaining PhonePe provider-verification contract issue and formally closes Milestone M4 with a documented, independently reviewable architectural decision (Outcome B), an authoritative 22-vector regression test suite, a full M4 system audit, and a verified pass/fail exit criteria checklist.
1. Technical Contract Determination (PhonePe API v1)
• Merchant Identity & URL Path Verification:
• Outbound S2S status queries (
GET /pg/v1/status/{merchantId}/{orderId}) authenticate the caller via TLS,X-VERIFY: SHA256(path + saltKey)###saltIndex, andX-MERCHANT-ID.• However, the HTTP response body returned by PhonePe is plain unsigned JSON (no response HMAC or signature header).
• If a provider response omits
data.merchantId, relying on the request URL path requires client/adapter-side identity synthesis. Under zero-trust rules, omitted fields remainnulland fail closed (missing_verified_merchant_id), strictly preventing cross-merchant substitution.• Domestic UPI Contract vs Missing Currency Field:
• PhonePe is statutory licensed under RBI/NPCI exclusively for domestic INR transactions (denominated in paise).
• However, PhonePe's official API schema (GET status and S2S webhook callbacks) never returns a
currencyfield.• Under our zero-trust verification standard (
applySuccessfulUpiPayment), payment confirmation requires provider-attestedcurrency === 'INR'. Faithful extraction yieldscurrency: null, resulting in fail-closed dispute (missing_currency).• Injecting hardcoded defaults (
currency: 'INR') inside the adapter is strictly prohibited because it manufactures evidence not present in provider payloads.• Cryptographic Signing Analysis:
• S2S Webhooks are cryptographically signed via
X-VERIFYover the base64 payload, authenticatingmerchantId,amount, andmerchantTransactionId. Currency is omitted.• Status GET responses are unsigned by the provider (relying solely on TLS transport security).
• Forgery & Mismatch Resistance:
• Forged or invalid webhook signatures are rejected with HTTP 401 (
WebhookSignatureError).• Amount mismatches, currency mismatches, or merchant mismatches transition payments to
disputedwith 0 bookings and 0 Telegram invites.2. Safe Integration Approach Decision: Outcome B (Adopted)
• Outcome A (Rejected): Manufacturing synthetic defaults violates non-negotiable safeguard #5 and reopens vulnerability surfaces closed in M4.3.3.
• Outcome B (ADOPTED):
• PhonePe cannot currently meet the required zero-trust verification standard due to the absence of machine-verifiable currency and unsigned status responses.
• PhonePe is formally classified as SANDBOX / MOCK ONLY.
• Production live-payment capability is marked BLOCKED (
ENABLE_LIVE_PAYMENTS=falsepreserved everywhere).• Milestone M4 formally closes with live payments disabled and zero financial exposure.
• Recommends migrating to a modern, zero-trust compatible provider (e.g., Razorpay or Cashfree) for M5 live checkout.
• Outcome C (Rejected): Indefinite delay is unnecessary given that booking integrity, capacity holds, audit logging, and refund controls are fully operational.
3. M4.3.4 Regression Test Suite (38/38 UPI Tests Passing)
Added comprehensive regression suite in
test/upi-checkout.test.jsverifying:missing_verified_merchant_id), polling mismatched (merchant_mismatch), webhook missing (WebhookSignatureError), webhook mismatched (WebhookSignatureError).missing_currencydispute), foreign currency injection (currency_mismatchdispute).Payment not found).duplicate: true), zero duplicate bookings or invites.4. Final M4 System Audit Summary
• Booking Integrity & Concurrency: Double-booking prevented at intent creation (409), confirmation (
refund_pending), and guest claim (409); SQLSTATE23505savepoint recovery; capacity holds held under unexpired intents.• Seat Overselling Prevention: Partial index
idx_payments_active_tier_holdsserializes concurrent bookings; re-checked at confirmation.• Refunds & Reconciliation: Automated refunds for
succeededandrefund_pending; authorized manual finance reconciliation with anti-placeholder validation (operator_attested: true,bankVerified: false).• Audit Ledger Immutability: Append-only
payment_auditsprotected by PostgreSQL trigger (no UPDATE/DELETE).• Tenant & Guest Isolation: Multi-tenant organiser isolation strictly enforced.
• Disabled Live-Payment Safeguards:
ENABLE_LIVE_PAYMENTS=falseenforced across all files and environments.5. M4 Exit Criteria Pass/Fail Checklist
UPI_PROVIDER_READINESS.md,UPI_SECURITY_AUDIT.md,PROJECT_STATE.md)Milestone M4 Verdict: FORMALLY CLOSED (Live Payments Safely Disabled).
6. Governance
• Base branch:
feature/m4-3-3-provider-verification• Head branch:
feature/m4-3-4-contract-decision•
ENABLE_LIVE_PAYMENTS=falsestrictly preserved.• No real payments or refunds initiated.
• PR #33, #32, #31, #30, #17 not merged.
• Stopped for independent owner review.