Author

Topic: How can I add 'Bitcoin Payment Gateway' on my website? (Read 315 times)

legendary
Activity: 3416
Merit: 1912
The Concierge of Crypto
The bigger payment processors or exchanges have more than one full node too, not just as a backup, but to monitor the network from more than one physical location, probably from at least two different countries. For example, you could run a node in a VPS in Singapore, another one in Europe, and another one in North America. Might as well keep a full node on a local computer at your office or home or something.

If transactions that you are looking for show up in all of them within a few seconds, that's a good sign.

One is probably enough if you require at least 1 confirmation.
staff
Activity: 3500
Merit: 6152
Thank you so much guys. It was really great help from all of you.

While searching for possible solutions, I came across this: https://www.blockchain.com/api/api_receive

Has anyone tried this before? How good is blockchain receive payments API? Can I use it in production?

Yes, it should work fine. You also have Blockonomics API as an alternative.

If you're still planning to build the same thing you mentioned in your original post, then what Dabs suggested is the best solution, you should be running your own node, instead of relying on third-party APIs.
hero member
Activity: 2114
Merit: 603
Thank you so much guys. It was really great help from all of you.

While searching for possible solutions, I came across this: https://www.blockchain.com/api/api_receive

Has anyone tried this before? How good is blockchain receive payments API? Can I use it in production?
legendary
Activity: 2198
Merit: 1150
Freedom&Honor
On top of what Dabs has said you would really like to go and use Electrum instead of merchant services like Bitpay and Coinbase commerce if you want to avoid some additional cost and of course unwanted KYC. What they'll just offer you is the convenience of having the html code ready to be plugged into your website and also the availability of liquidating your BTC payments quickly in your bank but you'll be paying Bitpay and Coinbase a cut of your earnings on every transaction you make with them. Here is Electrum's official guide on applying your Electrum wallet as a payment gateway for your website.  

Wow. This is nice!
I didn't know it's so straightforward with Electrum!
There's a good YT tutorial here -> https://www.youtube.com/watch?v=9PNHvr0e7sI
I always wanted to add bitcoin for my webshop though, unfortunately I think I have to use  use BitPay because I need to get FIAT on my company account so it can be legal :/ Can't bookkeep sales in crypto. I think.

That does not mean that it is impossible. If you work with WordPress and Woocommerce, a good module for FIAT is "Stripe" it works really well for our website. And it was to be validated by Stripe (Yes they carry out a verification before validation) After which, you can determine on what bank account the collected money will be sent.
But otherwise I saw that there is also a similar module for sites not using Wordpress try looking on the internet for more information.

My shop is operating solely through social media currently but I've been planning to start a Wordpress shop for years, just never caught the time (Wordpress is the only one I have some experience with ). Thanks for the info, I'll check back on this post once I get the time to build it  Smiley
jr. member
Activity: 30
Merit: 1
On top of what Dabs has said you would really like to go and use Electrum instead of merchant services like Bitpay and Coinbase commerce if you want to avoid some additional cost and of course unwanted KYC. What they'll just offer you is the convenience of having the html code ready to be plugged into your website and also the availability of liquidating your BTC payments quickly in your bank but you'll be paying Bitpay and Coinbase a cut of your earnings on every transaction you make with them. Here is Electrum's official guide on applying your Electrum wallet as a payment gateway for your website.  

Wow. This is nice!
I didn't know it's so straightforward with Electrum!
There's a good YT tutorial here -> https://www.youtube.com/watch?v=9PNHvr0e7sI
I always wanted to add bitcoin for my webshop though, unfortunately I think I have to use  use BitPay because I need to get FIAT on my company account so it can be legal :/ Can't bookkeep sales in crypto. I think.

That does not mean that it is impossible. If you work with WordPress and Woocommerce, a good module for FIAT is "Stripe" it works really well for our website. And it was to be validated by Stripe (Yes they carry out a verification before validation) After which, you can determine on what bank account the collected money will be sent.
But otherwise I saw that there is also a similar module for sites not using Wordpress try looking on the internet for more information.
legendary
Activity: 2198
Merit: 1150
Freedom&Honor
On top of what Dabs has said you would really like to go and use Electrum instead of merchant services like Bitpay and Coinbase commerce if you want to avoid some additional cost and of course unwanted KYC. What they'll just offer you is the convenience of having the html code ready to be plugged into your website and also the availability of liquidating your BTC payments quickly in your bank but you'll be paying Bitpay and Coinbase a cut of your earnings on every transaction you make with them. Here is Electrum's official guide on applying your Electrum wallet as a payment gateway for your website.  

Wow. This is nice!
I didn't know it's so straightforward with Electrum!
There's a good YT tutorial here -> https://www.youtube.com/watch?v=9PNHvr0e7sI
I always wanted to add bitcoin for my webshop though, unfortunately I think I have to use  use BitPay because I need to get FIAT on my company account so it can be legal :/ Can't bookkeep sales in crypto. I think.
hero member
Activity: 1680
Merit: 655
On top of what Dabs has said you would really like to go and use Electrum instead of merchant services like Bitpay and Coinbase commerce if you want to avoid some additional cost and of course unwanted KYC. What they'll just offer you is the convenience of having the html code ready to be plugged into your website and also the availability of liquidating your BTC payments quickly in your bank but you'll be paying Bitpay and Coinbase a cut of your earnings on every transaction you make with them. Here is Electrum's official guide on applying your Electrum wallet as a payment gateway for your website. 
legendary
Activity: 1946
Merit: 1427
If you only need invoices, i definitely recommend Btcpayserver, but i see that that isn't the case here.


https://bitcoin.stackexchange.com/questions/25763/how-to-receive-payments-online-to-single-address-per-user-in-scalable-way?rq=1
Recommends you to simply use Bitcoin Core and build an api around it yourself. (eg assign adresses to userID's yourself in a database for example.)

https://bitcoin.stackexchange.com/questions/20821/build-an-online-wallet-service-with-bitcoind-can-it-scale-if-not-what-can-be?rq=1
Some more interesting reading material, and maybe check out - https://github.com/bitcoinj/bitcoinj

For a more JS-related library, check out https://github.com/bcoin-org/bcoin || https://bcoin.io/ , looks pretty nice, and promising (Might check them out myself later).

Imagine if your website only does withdrawals once every few hours, or once a day, how much in fees everyone would save.
Or, if you're running a really big site, you can also do the exact opposite of batching. Instead of sending out 100's at the time, you simply collect as much inputs as possible, and when you have a really big UTXO set, you can, when someone requests a withdrawal, try to match it as closely as possible and only have 1 output adress (no change) and thus save heavily on fees.

Again, that only works when heavily scaled.
legendary
Activity: 3416
Merit: 1912
The Concierge of Crypto
To save on fees, use native segwit addresses. To accommodate users who send from older wallets, maybe use legacy compatible segwit addresses.

Electrum will let you do this, or you can use that bip39 website to generate the appropriate extended public and private keys. Keep the private key on a machine that is separate from the website, preferably one where you have direct or better control of it.

Batching can be done by collating several transactions together, either when the queue is large enough, or after a set time, maybe offer options to the individual if they want to save on fees if they can wait like 30 minutes or 1 hour or even 1 day (maybe a few hours is good.) Batching also indirectly offers slightly better privacy, since it is essentially a coin join (all under control of the website owner) of plenty of people's withdrawals.

Imagine if your website only does withdrawals once every few hours, or once a day, how much in fees everyone would save.

Lightning isn't even in the picture yet. That's another option.
staff
Activity: 3500
Merit: 6152
In addition to what has been said, you might want to consider generating a new address for each transaction, instead of assigning one unique address for each user. Also, to save some fees: if a user wins/loses, nothing should happen on-chain (just 1's and 0's changing in the database). When sending (user withdrawal): make sure to batch transactions instead of sending funds on each individual's request.

If you're familiar with Node.js, take a look at this open-source dice game. It should help you understand how things work. Keep in mind that the code hasn't been reviewed by so many people, so I wouldn't suggest forking it and using it on a live product unless you can check it yourself and confirm that it has no backdoors.
hero member
Activity: 2114
Merit: 603
Also, I am not looking for options like BitPay or CoinGate. I want to learn how to develop it from scratch.
Edit: Check step 3 in this article: https://blog.blockonomics.co/accepting-bitcoin-do-you-need-a-payment-gateway-832487d3b84c

If I am not massively wrong then this is the solution you are looking at.

Thanks Royse. This article cleared many doubts of mine. Bitcoinjs-lib is great solution to get started.

I will do it from scratch.let's connect on (Telegram: @Mavensr) for more details 

Sorry brother, I am not looking for someone to do it for me. This wasn't job opening.

Some time ago, I ran a gaming site. I generated 10,000 (ten thousand) addresses and had my site dev keep it in the site's database to assign to each user uniquely.

Then we had a bitcoin daemon watch those addresses.

The private keys were all on my side, so it was almost as good as cold storage for each user.

These days, it might be better to use HD type wallets and use the master public extended key, so you have an infinite number of addresses, you just need a database to assign each address to each user.

Thanks Dabs. I will try this approach in the project.
legendary
Activity: 3416
Merit: 1912
The Concierge of Crypto
Some time ago, I ran a gaming site. I generated 10,000 (ten thousand) addresses and had my site dev keep it in the site's database to assign to each user uniquely.

Then we had a bitcoin daemon watch those addresses.

The private keys were all on my side, so it was almost as good as cold storage for each user.

These days, it might be better to use HD type wallets and use the master public extended key, so you have an infinite number of addresses, you just need a database to assign each address to each user.
newbie
Activity: 116
Merit: 0
I am logging on the forum after very long time. Happy to see that Bitcoin is still going strong and have strong community behind it. Anyways, I am currently building a project which requires an option through which users can deposit bitcoins to their account. It is somewhat similar to option provided by most of the gambling site.

Unique Address for every user ---> User deposits btc to that address ---> BTC goes to site's wallet ---> Similar amount reflects in user's front-end as balance

How can I implement this? If there's any thread where this topic has been already discussed then please refer me to that.

Also, I am not looking for options like BitPay or CoinGate. I want to learn how to develop it from scratch.

I will do it from scratch.let's connect on (Telegram: @Mavensr) for more details 
legendary
Activity: 2464
Merit: 3878
Hire Bitcointalk Camp. Manager @ r7promotions.com
Also, I am not looking for options like BitPay or CoinGate. I want to learn how to develop it from scratch.
BitPay is good for marcents point of view but it sucks in customers point of view. As a customer to purchase anything from a site which ask pay to bitpay is annoying to me.

Give me few minutes to find you something from Google as I know there is something which allows you to integrate bitcoin payments in your site like without giving any fees and stuffs. One can do it using the bitcoin core they have.

Edit: Check step 3 in this article: https://blog.blockonomics.co/accepting-bitcoin-do-you-need-a-payment-gateway-832487d3b84c

If I am not massively wrong then this is the solution you are looking at.
hero member
Activity: 2114
Merit: 603
I am logging on the forum after very long time. Happy to see that Bitcoin is still going strong and have strong community behind it. Anyways, I am currently building a project which requires an option through which users can deposit bitcoins to their account. It is somewhat similar to option provided by most of the gambling site.

Unique Address for every user ---> User deposits btc to that address ---> BTC goes to site's wallet ---> Similar amount reflects in user's front-end as balance

How can I implement this? If there's any thread where this topic has been already discussed then please refer me to that.

Also, I am not looking for options like BitPay or CoinGate. I want to learn how to develop it from scratch.
Jump to: