I am looking to set up a simple single page store. This store should respect the privacy of users by not requiring personal information where none is needed. I want to retain control of the funds, I don't want to sign up with an exchange, but want payments to go directly to my wallet. How can I achieve that?
closed as off-topic by Pieter Wuille, MCCCS, Raghav Sood, Ugam Kamat, 0xb10c Jul 30 at 19:12
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking product or service reviews are off-topic because they tend to attract subjective, low-quality, and spam answers. On the other hand, offerings in the Bitcoin space are still evolving rapidly which often renders answers outdated quickly. For more information see this meta-discussion." – Pieter Wuille, MCCCS, Raghav Sood, Ugam Kamat, 0xb10c
If for you it's ok to use 3rd parties' services, a simple google search will present to you several plug-ins that suit your purpose.
If you want to do it by yourself, here is how you may want to tackle this endevour:
you must have an HD wallet (aka deterministic wallet compliant with BIP 32).
you put your XPUB in your server and you use it to generate dynamically the public keys that will be shown to your customers.
You want to make sure that every customer sees a different public address, so that when you receive a payment you will know who paid for what. If you always use the same public address (besides compromising the privacy of all parties involved in the transaction) you won't have any way to know which customer paid for what product. More on this point later.
in HD wallets new key pairs and public addresses are generated using the XPUB in conjunction with an HD path such as this: M/44'/0'/0'/0/x. Every time a new customer sees the payment page , in order to show him or her a new address, you need to change the 'x' (child) value. For example the first customer will see an address which corresponds to HD path M/44'/0'/0'/0/0 , the second customer will see the public address which corresponds to M/44'/0'/0'/0/1 and the third one will see M/44'/0'/0'/0/2 and so forth. You can go on for millions of addresses, but you need to put in place some mechanism that allows you to keep track of the last child number. You can do that on a JSON file on your server or through your DB.
if you want to apply some sort of automated business logic you need to monitor the blockchain to listen to incoming payments to the addresses you created. Sure enough, purchase data must be saved into your DB along with the bitcoin public address created for that specific purchase. This will come handy later when you will need to automatically confirm the purchase to the customer and deliver the order.
You may want to use a websocket to listen to unconfirmed payments (in mempool) received by the address shown in the webpage that the cusomer is seeing. As soon as a payment is detected , with a dozen lines of JS you ll be able to print a "thank you" message on the customer's screen.
Monitor the blockchain for confirmed payments (at least one confirmation, but 3 confirmations is safer) received by the addresses you generated. When you see a new confirmed payment you can confirm the purchase to the customer by email and ship your product to him or her.
As a final piece of recomendation, you should set up some sort of count down or other mechanism that limits the validity of the address you generated and prices quoted. This is vital to protect yourself and your customer from the tremendous price swings of BTC against major fiats.
I hope that this helped you :-)