Nullcorps / woocommerce-gateway-bitcoin

Self custody bitcoin checkout/payment-gateway for woocommerce. Accept Bitcoin on your wordpress+woocommerce shop without needing to sign up for any centralised services or be subject to any Terms of Service. Totally self-custody, uses HD wallet so payments drop straight into your electrum or other wallet. Uses only free, public APIs with a choice (and failover) between blockstream or blockchain.info
GNU General Public License v3.0
4 stars 5 forks source link

woocommerce-gateway-bitcoin

Self-custody Bitcoin checkout for woocommerce. No middle man, privacy oriented, minimal maintenance, simple.

Get paid directly into your self-custody wallet without any middleman or any KYC'd APIs. No signups, no Terms of Service, nobody taking a cut. Make a sale on your site and it drops straight into your Electrum (or whatever) wallet. Payments are between you and the Bitcoin network (well and possibly the public API providers somewhat but you have a choice which to use).


PLEASE NOTE: Brian has created a much improved fork of this project which you should probably use instead: https://github.com/BrianHenryIE/woocommerce-gateway-bitcoin


NO FULL BITCOIN NODE REQUIRED \o/

THIS IS VERY MUCH WIP - MAKE OF IT WHAT YOU WILL. IF YOU MANAGE TO BREAK IT SOMEHOW PLEASE DO LET ME KNOW OR BETTER STILL FIX IT AND THEN LET ME KNOW :)


I'm not a php ninja, I'm just persistent af and am copy & pasting and trial & error-ing my way thru this as I learn the maths/theory behind it, so before you judge my spaghetti code too harshly, please ask yourself with all the amazing coders out there, why it's fallen to little old me to actually write this. And if you can do better, join in ;)

I hope I got the licensing bit right, I have no idea really. It should be free and open source. That's the idea anyway.

Want it to work better in a particular way? congrats you just joined the team. Till then, IIWII :D

NullCorps

Installation instructions:

either:

or:

then:

You should now be able to add an item to your cart, head to the checkout and with a bit of luck you'll see the bitcoin payment option. If you proceed with that it should then show you an address, QR-code etc which is now tied to this order and will not be reused. It's ok though, you can generate as many addresses as you like, all you need to do is re-visit that addresses page periodically to top up your stash of addresses. On a super busy site you might want to adjust the settings to pre-generate a larger number of addresses e.g. 200.

Since the /addresses page exposes all your addresses, you may wish to limit access to that page using something like my guestshortcode plugin, in which case your custom HTML block would look a bit like this:

[admin][woobtc_addresses][/admin] [guest] Sorry, access denied [/guest]

That would mean you as admin can see the addresses apge and generate/refresh them, but nobody else can.

Alternatively you could wrap the [woobtc_addresses] in some php and have it pass in a password via a url some sort of scheduled thing like cron hit that page to keep your addresses topped up automatically. So then you'd set your cron to hit /addresses?p=somelongpassword2340903852924 and only show the [woobtc_addresses] shortcode if said password is present.

PLEASE NOTE: segwit wallets doesn't seem to be supported by bitwasp, there's nothing i can really do about that currently.

Installation requirements:

This plugin requires the following php modules to work. Please note Mcrypt is no longer included as part of the standard php modules so needs a little extra work to install, I've included a link to a set of instructions which worked. Replace "7.4" with whatever version of php you're using. I've only tested up to 7.4 currently:

Stuff to do:

MOSTLY DONE? - make it also work with blockstream.info's api, allow user to set preference but keep the other as a failover in case of rate limiting

IN PROG - add a settings field to allow css hacks? or could this be done at the theme customer level. The css id's should be unique so why not?

IN PROG - idk, tidy it up a bit, remove any inline css

IN PROG (needs automating now) - auto refill addresses when running low, something like on payme page, self maintaining.

DITC - just before fresh address is linked to order in the postmeta, check past/present balances are still 0

DONE - added "percentage discount for BTC payment" option (2021-11-02) DONE - integrate in SS (test) DONE - integrate in FDV DONE - integrate in MSL DONE - integrate in TG DONE - auto prune addresses which may have been used in the mean time (e.g. multiple instances?) NOPE - maybe allow user-definable derivation paths? Do other wallets use something other than m/0/1? << HA! How about no(t right now anyway) NOPE - give the option of QR from google images or local libary depending on privacy preference << meh, why?

Considerations:

In this case you can set the lookahead value (gap limit?) for electrum from the electrum console (tab) by typing the following and your payments will magically appear:

wallet.change_gap_limit(200) wallet.synchronize()

see: https://bitcoin.stackexchange.com/questions/63641/how-to-list-all-the-hd-address-in-electrum

Big thank you to @orionwl for talking things through along the way and paitently explaining the maths side of it over and over till I get it :)

This uses the Bitwasp library for all the maths heavy lifting, address generating etc. https://github.com/Bit-Wasp/bitcoin-php