14 Comments

I have trouble wrapping my head around why we need ledger and wallet. In my mind these are all derived information that shouldn't be part of the payment flow. At best these just need to be updated asynchronously to be used for e.g. reconciliation as mentioned. Can you explain why you design them to be part of the payment flow?

Expand full comment

Wallet gives you the user balance at any given point of time{pending transactions}

Ledger gives you a list of all transactions completed and pending. Ledger does not necessarily hold balance info. It is out of scope for that model

Expand full comment

How will the system remain in consistent state if there's a failure in wallet service or ledger service?

Should there be a synchronous transaction among all the services involved? If yes, how would it be implemented.

Expand full comment

Thinking that the there is a webhook set-up in each of the wallet and ledger service. The PSPs usually requires the services to have an endpoint wherein they can send the event for successful capture and successful charges. Failure in webhook processing means nothing will move forward, meaning everything will remain in its old initial state until a process becomes successful. Also, there is a reconciliation service that is present in the design that can do the rollbacks and roll-forwards that need to happen.

Expand full comment

You might also wanna consider gift cards and order cancellations in this aspect? What are your thoughts?

Expand full comment

Hi Alex. I’m reading the Volume 2 of your book. If a payment event is broken down to n payment orders and the idempotency key is in the payment order, wouldn’t the buyer have to complete multiple “payment” n times?

Expand full comment

This is REALLY superficial. Any good interviewer would dig deeper into the DB, whether the ones shown are the same or different, SQL/NOSQL, txn failures modes, database schema etc. This diagram may be ok for an intern applying for a company no one has heard of, but beyond that, it's insufficient.

Expand full comment

Here's the associated chapter from the book:

https://newsletter.pragmaticengineer.com/p/designing-a-payment-system

It goes into a lot more details describing the db schema, retry policy etc.

Expand full comment

Especially the TXN failure handling, would make the candidate articulate the logic for each step of the complete payment transaction, including retries, timeouts, network errors.

Expand full comment

Which is the payment executor in this scenario ?

Expand full comment

How and when would Amazon/seller get the money for the sale? Can you elaborate on the settlement process a bit please?

Expand full comment

Could you please shed some light on BNPL SD Alex?

Expand full comment

very useful design flow:thanks

reconciliation:对账

Ledger:账本

settlement file:结算文件

Expand full comment

the payment service is the api to connect between mobile and Backend. ? Payment executer is the use case or BE service ? If we want to create the payment sdk, what kind of certification process needed ?

Expand full comment