helloejsulit's avatar

How does e-wallet works?

Hello,

I am having a bit of confusion regarding how does money coming from PayPal or credit card be converted to an e-wallet balance and use that balance as payment to the merchant?

Say, I cash in $100 to my e-wallet account using PayPal. That transaction should be saved on my database, right? Then, I'll update the user's e-wallet balance to $100. Now, I'm going to purchase an item from a merchant using my e-wallet balance, how then can the e-wallet balance be validated and transferred to the merchant as money?

I am maybe missing a step here, could you please help me clarify this flow?

Thank you!

0 likes
14 replies
bugsysha's avatar

What do you consider as e-wallet because PayPal itself is an e-wallet?

helloejsulit's avatar

Well, yeah, just like PayPal, one where you can have a balance from different sources and use to pay merchants

I guess I should ask, how does PayPal works in terms of cashing in from banks, updating the user's e wallet balance, and using it for payment.

bugsysha's avatar

PayPal is either PCI compliant or it is using some third party system that is PCI compliant to communicate with the banks. Considering that PayPal is a giant, I can almost safely assume that they are PCI compliant. For that reason there is no need to use any third party systems cause they would have to pay for using their services same way PayPal charges end user.

If you can ask a more detailed question, then maybe answer can be better. But since it is still vague, I would wait for you to follow up.

helloejsulit's avatar

If I were to create a custom e-wallet apo, how can I:

  1. Cash in using credit card, bank, etc.
  2. Update the e-wallet balance with the amount that is cashed in
  3. Use the e-wallet balance for coupons, items, etc.

Thanks!

bugsysha's avatar

First you need to fulfil all of the PCI compliance requirements. Certification takes up to two weeks. Also you will have regular vulnerability scans at least 4 times per year. Maybe even more than 4 in the beginning. Only after that can you start communicating with Visa/Master/American and other CC vendors.

All of the steps you've asked about have to be implemented by you. Maybe there are libraries that can speed up the process, but being such a sensitive thing, I would build it myself.

Search and look at API for those CC vendors. You will find more info there.

helloejsulit's avatar

Cool yup. Thank you for this. Thanks for clearing that up for me. I really appreciate it

martinbean's avatar
Level 80

@helloejsulit I don’t really understand your question. Are you building an “e-wallet” or are you just wanting to know how PayPal works?

Either way, a wallet is just a ledger. Same as any bank account. A user has an account, and they can they make debits and credits to that account. All transactions are recorded on a separate line. If a user adds funds to an e-wallet, that’s recorded as a credit on the account. If a user uses their e-wallet balance to pay for something, then that’s recorded as a debit. You can then calculate a user’s balance by summing the transaction amounts (all credits minus all debits):

$userBalance = Transaction::where('user_id', '=', $user->getKey())->sum('amount');

You may then be thinking, “But won’t this be heavy on the database?” and the answer is, well, it depends on the number of users you have and transactions you’re handling. Databases are pretty good at handling large amounts of data (so long as you have efficient indexes), but at PayPal scale they’ll probably be using some form of event sourcing architecture where they’ll create snapshots, and then calculate balances from a specific point in time instead of summing transactions all the way back to 1998 or whenever it was PayPal was established.

1 like
helloejsulit's avatar

Got it. Yes, I'm building an e-wallet. So if I understand it correctly you'll create some kind of a ledger that updates the balance through the transactions? I think I am beginning to understand the flow.

helloejsulit's avatar

Got it. Thanks I'll have a look into this, I hope I'll find what I'm looking for

martinbean's avatar

An API or playground isn’t going to tell you how PayPal works under the hood.

jlrdw's avatar

The api and sandbox walks you through exactly how the "ledger" wallet works. The api is the base for interacting with paypal: https://developer.paypal.com/docs/checkout/integrate/ But many more articles.

The user never gets all paypal background code, unless you are on the paypal development team. So the api is what's exposed to users of the system, and there is a lot of documentation.

Experimenting in their sandbox simulates real World transactions. So would it hurt to try the sandbox. Choice is yours. But it's purpose is learning. I would guess @jeffreyway would agree that it doesn't hurt to experiment and learn prior to committing to real app. Especially since you are dealing with users credit cards and private information.

But it's just a suggestion to experiment first.

Please or to participate in this conversation.