DEV Community

Cover image for How I Made My Own BNB Payment Gateway with PHP?
bgokcol
bgokcol

Posted on

How I Made My Own BNB Payment Gateway with PHP?

I like to use Binance Smart Chain and sometimes I need to get paid with using it. I used to send my BSC wallet address to the customer manually. But when there are many customers, it became difficult to do manually. Then I thought, Automate the boring stuff!

Why Don't You Use Ready-Made Gateways Like Coinpayments?

These gateways are useful, especially if you need to accept multiple cryptocurrencies. But I just need BNB. So, I won't pay commission for that! 😀

What Do You Need to Know Before Start?

  • BSC is a fork of Go Ethereum protocol. Because of that our software will work on all ETH networks, not just BSC.
  • You can generate a wallet address offline (on ETH), it's not necessary to activate it. (Read this post)
  • DAPPs use Web3 to connect to the ETH network.
  • We have to store the private key of the wallet to access funds.

Let's Start!

We'll create a unique wallet address for each payment. Our system will approve the payment when the customer sends enough BNB to the generated wallet. And after approval, it will transfer the funds to my payout wallet address.

I used web3.php and ethereum-tx libraries in my project.

After several hours of fighting with the ETH network, my system is ready.

Check the demo: https://bg.je/projects/bsc-payment/example_form.php
Source code: https://github.com/bgokcol/bsc-pay

What's Next?

  • I will add user and admin dashboard.
  • I will add support for stable coins like BUSD, USDT, DAI.
  • Transfer fee (gas limit & gas price) is provided by the user for now. I will make it automatic in the future.

Top comments (1)

Collapse
 
gisomusic profile image
GisoMusic

thats great thanks for sharing gisomusic.com/music/