Here is what happens when you click the Buy button on Amazon or any of your favorite shopping websites.

1. When a user clicks the “Buy” button, a payment event is generated and sent to the payment service.

2. The payment service stores the payment event in the database. 1/6 Image
3. Sometimes a single payment event may contain several payment orders. For example, you may select products from multiple sellers in a single checkout process. The payment service will call the payment executor for each payment order. 2/6
4. The payment executor stores the payment order in the database.

5. The payment executor calls an external PSP to finish the credit card payment. 3/6
6. After the payment executor has successfully executed the payment, the payment service will update the wallet to record how much money a given seller has.

7. The wallet server stores the updated balance information in the database. 4/6
8. After the wallet service has successfully updated the seller’s balance information, the payment service will call the ledger to update it.

9. The ledger service appends the new ledger information to the database. 5/6
10. Every night the PSP or banks send settlement files to their clients. The settlement file contains the balance of the bank account, together with all the transactions that took place on this bank account during the day. 6/6

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Alex Xu

Alex Xu Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @alexxubyte

5 Jan
Here is a simplified design diagram that explains how a stock exchange such as Nasdaq or Newyork exchange works under the hood: #developers #systemdesign

Step 1: A client places an order via the broker’s web or mobile app.

Step 2: The broker sends the order to the exchange.1/6 Stock exchange design
Step 3: The exchange client gateway performs operations such as validation, rate limiting, authentication, normalization, etc., and sends the order to the order manager.

Step 4-5: The order manager performs risk checks based on rules set by the risk manager.2/6
Step 6: Once risk checks are passed, the order manager checks if there is enough money in the wallet.

Step 7 - 9: The order is sent to the matching engine. The matching engine sends back the execution result if a match is found. 3/6
Read 6 tweets
4 Jan
One of the most serious problems a payment system can have is to 𝐝𝐨𝐮𝐛𝐥𝐞 𝐜𝐡𝐚𝐫𝐠𝐞 𝐚 𝐜𝐮𝐬𝐭𝐨𝐦𝐞𝐫. When we design the payment system, it is important to guarantee that the payment system executes a payment order exactly-once.1/6 Image
At the first glance, exactly-once delivery seems very hard to tackle, but if we divide the problem into two parts, it is much easier to solve. An operation is executed exactly-once if:

1. It is executed at least once.
2. At the same time, it is executed at most once.2/6
We now explain how to implement at least once using retry and at most once using idempotency check.

𝐑𝐞𝐭𝐫𝐲
Occasionally, we need to retry a payment transaction due to network errors or timeout. Retry provides the at-least-once guarantee. 3/6
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(