Today, cryptocurrencies and blockchain have changed a lot of traditional methods and solutions. In the cryptocurrency world, you own your money instead of trusting third parties like banks, as the cryptocurrency communities grow up it would be efficient that websites and applications let their clients pay them cryptocurrencies instead of fiats. Developing a payment platform to accept cryptocurrencies is a time-consuming process and need to write some smart contract on the blockchain to handle your client payments. Today, I’m gonna introduce you to a platform that you can use to implement your cryptocurrency payment gateway in just 2 mins. D-Gate Platform D-Gate is a D-App that is deployed on Binance Smart Chain to serve websites as a payment gateway. D-Gate website: https://d-gate.org Before start developing please make sure you've installed MetaMask wallet, it's needed to interact with the blockchain, If you've installed Let get started with D-Gate ... D-Gate has a dashboard to manage and see your account and your payments : https://dash.d-gate.org This is based on Binance Smart Chain (Mainnet). In this case, we want to create a test app to figure out how D-Gate works. So we can use the sandbox version of D-Gate (on Testnet) with fake BNB : https://testnet.d-gate.org You also can get some fake BNB (on Testnet), to test your app: https://testnet.binance.org/faucet-smart Create your first Express app with D-Gate 1- Create a project and install dependencies: $ mkdir dgate-example $ cd dgate-example $ npm init $ npm i express @dgate/bsc $ touch index.js 2- Copy code below into file. ./index.js app = ( )(); {DGate, Chain} = ( ); wallet = ; dg = DGate( wallet, Chain.Testnet ); invoices = []; lastInvoiceId = ; dg.onNewPayment( { invoice = invoices.find( { ( inv.to.toLowerCase() === payment.to.toLowerCase() && inv.id === payment.id && inv.amount === payment.amount ){ ; } }); (invoice){ invoice.paid = ; invoice.time = payment.time; } }); app.get( , (req, res)=>{ res.json( invoices ); }); fixedAmount = ; app.get( , { lastInvoiceId++; id = lastInvoiceId; invoice = {id, to : wallet, amount : fixedAmount, paid : , time : }; invoices.push(invoice); paymentUrl = dg.createPaymentUrl( invoice.id, invoice.amount, ); res.redirect(paymentUrl); }); app.get( , (req,res)=>{ id = (req.query.id); (id < ){ res.send( ); ; } invoice = invoices.find( invoice.id === id ); (!invoice){ res.send( ); ; } (invoice.paid){ res.json(invoice); ; } payment ; { payment = dg.getPayment(id); invoice = invoices.find( invoice.id === payment.id ); (invoice && DGate.isSamePayment(invoice, payment) ){ invoice.paid = ; invoice.time = payment.time; } res.json(invoice); ; } (e){ paymentLink = dg.createPaymentUrl( invoice.id, invoice.amount, ); res.send( ); ; } }); app.listen( , { .log( ); }) const require 'express' const require '@dgate/bsc' /** * Your wallet address. * You can create an account in MetaMask and copy it's address. * You ever don't need PRIVATE_KEY to interact with D-GATE, So do NOT store your private key anywhere in your code. */ const '' /** * If you are testing your app, you can use testnet chain to test your app with fake BNB (faucet). * In the production mode that you want to receive REAL BNB from your clients, use Chain.Mainnet instead Chain.Testnet. */ const new /** * invoices array holds invoices data on the RAM, this is just a practice . * For the real world you have to save invoices into your database. */ const /** * This is a counter to generate a unique id (64bits uint) for every invoice. * You should generate and save unique ids for every invoice to identify it after user's payment. * */ let 0 /** * Every time a payment transaction occurs for your specified address (your wallet address), * this listener will call the callback function (At Real-Time). */ => payment const => inv /** * The comparision should include 'to' (Your wallet address), 'id', 'amount' (in BNB) for every payment invoice. * You can also use the static method of DGate class like : DGate.isSamePayment( a , b ). */ if return true if // Updating the invoice true // Do something like sending a notification or update a database row. /** * List all of invoices. */ '/invoices' async /** * In this case we specified a fixed amount for every payment (Do not this on the real world app) */ const 0.05 /** * An API to create invoice with unique ids. */ '/new-invoice' ( )=> req,res const const false 0 /** * dg.createPaymentUrl( id, amount ) generates a payment Url according the chain (Testnet/Mainnet) and your wallet address, * The payment link is encrypted to BASE-64 string that will be decrypted at gateway. * You can redirect your client to this link or everything that you want. */ const 'http://localhost:3000/invoice' /** * This will check the payment after client's payment and the redirection. */ '/invoice' async // 'id' and 'address' will be passed by D-Gate. const parseInt //const address = ethers.utils.isAddress(req.query.address) ? req.query.address : null; if 0 // if not a valid id 'Bad request on query params' return false const => invoice /// If the invoice not found. if await 'The invoice not found' return false // If the invoice is paid doesn't need to have been checked. if await return true let try /** * Throttle calling dg.getPayment(id) ( using express-rate-limit package ), it leaks the memory and causes performance issues. */ await const => invoice /** * Comparing 'id', 'amount', 'to' params using DGate.isSamePayment to make sure the payment is exact the same. * And then updating the invoice's 'paid' and 'time' params. */ if true await return true catch /// The Payment was not successful or isn't paid yet. /// re-generate the payment link const 'http://localhost:3000/invoice' await `The invoice is not paid. <a href=" ">Payment link</a>` ${paymentLink} return true 3000 => () console 'Server is running on : http://localhost:3000' 3- Modify the wallet address ( ) that you've got from your MetaMask wallet const wallet = "YOUR-Wallet-Address" 4- Run your app : $ node index.js 5- Open the link below on your compatible browser with MetaMask: This method creates an invoice and its payment URL, then redirects you to the payment gateway that you can pay the invoice on Testnet. If you haven't BNB on your Testnet wallet, you can get some BNB and test your app here: http://localhost:3000/new-invoice https://testnet.binance.org/faucet-smart After a successful payment, the gateway shows you a link to get back to your test app and you can see the invoice is paid successfully (in JSON format).