r/developersIndia • • Apr 22 '22
AskDevsIndia Fintech Domain Devs, how do you make sure transaction are safe and atomic?
Thinking about security in webapps and native apps, how fintech cos like Paytm, Zerodha, Groww, Razorpay makes sure that each transactions are safe and complete.
What if transaction fails but errors out. amount is refunded? How that logic is coded.
By looking at it, lots of guard rails would be required to make transaction safe? What are those? Is there code example where I can check how it's done.
How is it done anyway.?
32
Upvotes
•
u/AutoModerator Apr 22 '22
Hello! Thanks for submitting to r/developersIndia. This is a reminder that We also have a Discord server where you can share your projects, ask for help or just have a nice chat, level up and unlock server perks!
Our Discord Server
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
16
u/TWO-WHEELER-MAFIA Apr 23 '22
Today is my day to shine
Working as a Full Stack Dev for the Payments processing of an investment bank
There are a ton of checks, exchanges of messages. This system is OLD, Mostly mainframes
To do a transaction by ISO 20022 standards, We make a file that has all data regarding that transaction and that file is transferred between systems, Each system generates an acknowledgement or negative acknowledgement
There are a dozen of statuses that your transaction can be in in our system itself. In the end we send the payment for 'clearning' to the clearing house and then we get an acknowedgement if the payment is 'settled'
If any stage fails then we have to send a relevant acknowledgement to our Customer which then sends a human readable message to the end user
This is a very broad process, Our own payment processor has 3-4 big teams which take care of one component each and I really dont know the minute details of other components. Ask any specific question if you have
We are rewriting this thing to use Microservices :)
6
u/ThatsWhatSheSaid320 Apr 23 '22
> Is there code example where I can check how it's done
if it was so simple we would have had 1000s of fintech companies.
there are many services which provide full payment features. why are you not leveraging that ?
5
u/bow_to_me_plebs Apr 23 '22
Bohot bada topic hai bhai.
Generally what this companies do (except for razorpay) They integrate with a payment provider/processor (billdesk, bharatpe, etc). Since they all have implmented various gateways/banks payment (cc, dc, upi, etc).
Such processor have their documentation and code snippets which the integrators developer team has to follow, meanwhile a few dev/devops teams are there to support the clients integrators developer team, if they are stuck any where.
Transaction error, low balance error, refund etc is generally handled by the payment provider/processor.
One major concernt that occurs is, lets say your customer tries to make
Many have a process set, where, when a complain is raised, they check automatically with provider if payment is deducted, and booking has failed from their end, they will automatically call the refund api of payment provider
OR
Else this leads to manual work where a ticket will be generated to ops team of the app, they will check with provider whether they have actually deducted amount and it was their apps fault. If yes they will manually request refund with the payment provider/processor.
This is why they say... if payment deducted, it will be refunded in 7-14 working days etc.
Generally the API docs of this payment provider/processor is not public and will be provided to their clients only. But Stripe has public documentation if you wanna check it out.
https://stripe.com/docs/api
29
u/huk_n_luk Apr 22 '22
8
u/kisibe_rohan Apr 22 '22
Doesn't Really Answer your questions but have a look at this blog
Here
1
u/Lumpy-Physics4197 Backend Developer Apr 23 '22
Maker checker
1
u/kamikazechaser Apr 24 '22
We back all our txs behind a PoA evm chain. When a tx is made we immediately deduct it and the remaining balance is spendable. Once the tx gets mined on chain the spendable and actual balance become equal. The spendable is only a UX thing cause we want to send out the notification asap.