Cross-Domain Payment Proxy Architecture
A signed server-to-server payment bridge between two independent applications, with tokenized capture, 3-D Secure and idempotent status reconciliation.
A single payment across two trust boundaries
Two applications under separate trust boundaries needed to complete a single payment. The storefront could not hold gateway credentials, and the payment host could not trust unsigned instructions arriving over the web.
Card data had to stay off the origin entirely while shoppers still saw one continuous checkout. Webhooks could arrive more than once, a 3-D Secure challenge could strand a shopper on a return path, and both systems had to converge on exactly one final order status despite all of that.
No card PAN ever touches the origin. Gateway credentials live on one side of the boundary only.
Constraints that shaped the design
Separate trust boundaries. The storefront never holds gateway credentials.
No card PAN on the origin. Capture is tokenized in the browser.
Duplicate webhook deliveries. Every callback must be safely repeatable.
3-D Secure return path. The shopper leaves mid-payment and must land back safely.
End-to-end payment pipeline
Client → Origin API → Signed Proxy → PSP Adapter → Ledger → Reconciler. The origin records an unsigned intent, the proxy validates and signs over HMAC-SHA256, the adapter charges through the configured gateway, the ledger holds the single status record while the reconciler converges retries to one outcome.
Three paths through the system
Happy Path & 3DS
- 01The shopper submits the form. The origin records the intent as Processing and opens the hosted payment frame.
- 02The payment host validates the entry over an HMAC-signed call before rendering anything.
- 03The card is tokenized inside the payment frame. The number never reaches either server.
- 04The adapter charges through the configured gateway.
- 05A signed callback reports the result. The origin maps it to Paid, Failed or Pending.
- 06A 3-D Secure challenge returns the shopper through a signed verification path before the ledger moves.
Timeout & Recovery
- 01The capture acknowledgement arrives late, or not at all.
- 02The ledger stays Pending. A missing answer is never treated as a failure.
- 03A status poll against the payment host reconciles the true outcome.
- 04Exactly one outcome is recorded. The charge is never retried blindly.
Duplicate Webhooks
- 01A webhook or callback is delivered a second time.
- 02The guard matches an already-seen key before touching the ledger.
- 03The repeat is ignored. The ledger record is unchanged.
- 04No double fulfilment, no second receipt, no manual repair.
Evaluated options and trade-offs
Where to sign
A) Sign at the origin
B) Sign at the payment proxy
Sign at the payment proxy
Key material stays on one sideOnly the payment host holds the shared secret, so a forged instruction from the web cannot move money. Validation happens where the credentials live.
The origin cannot complete a payment while the payment host is unreachable. Availability of one side gates the other.
What to sign
A) HMAC over the raw JSON body
B) HMAC over a sorted canonical string
HMAC over the raw JSON body
Exact bytes, no canonicalization driftBoth sides already hold the exact bytes, so there is no canonicalization step to drift apart. Verification is a single constant-time comparison.
There is no replay window or nonce on the signed call. Hardening that is recorded as a future improvement, not a current guarantee.
How to support three gateways
A) Separate code path per gateway
B) One common adapter workflow
One common adapter workflow
One status model for three gatewaysThe three payment providers share a single status model, Paid, Failed and Pending, so one code path maps every outcome the same way.
Provider-specific features need adapter extensions instead of working inline. The common path stays deliberately narrow.
Security controls
Signed over the raw JSON request body and verified on receipt.
Every signature check compares in constant time.
Shared secret held on the payment host only, never on the origin.
The card number never reaches either server.
Only the last four digits stored, for receipt reference.
Idempotent status updates with duplicate-callback guards.
Outcomes that hold true
- Card data never touches the origin. Only the last four digits are kept.
- Gateway credentials live on one side of the trust boundary.
- Duplicate deliveries collapse to a single ledger outcome.
- Every payment converges on one final status, Paid, Failed or Pending.
- Replay-window and nonce hardening on the signed server-to-server calls.
- Managed secret rotation instead of manual key replacement.
- Contract tests per payment adapter, so gateway drift is caught before deployment.
Transferable engineering principles
Push idempotency to the edges. If every repeat is safe, the center never needs to be clever.
Design the 3-D Secure return path first. It is the part of the system the shopper actually feels.
Continue reading
Next Case Study → Employee Application Management System
A role-scoped operations console for multi-step applications, built on two different form engines.
Need a system architected like this?
Available for architecture advisory, custom PHP payment gateway bridges and resilient distributed workflows.