I have written website shopping cart software using MySQL and PHP and I need to add a way for users to pay with Bitcoin. This seems like a basic need for developers in general, but I'm having difficulty nailing down exactly how this works. Apologies in advance if this is a duplicated question!

The shopping cart shows the total amount due and when the user chooses to pay with Bitcoin, I imagine it should work like this:

shopping cart software generates a new payment (raw transaction?) address where the user should send their bitcoin payment.

Something (?) monitors the blockchain for the payment to this new address and updates the local database / user web interface to acknowledge when the payment is received.

I would appreciate any information clarifying the above processes!

A lot of searches about this including here on StackExchange are returning plugins for wordpress or joomla or such, but I don't want to use one of those overloaded CMS packages. Perhaps there's an existing API I would leverage but ideally I'd like to code as much of it myself as possible to limit the "unknowns" in the workings of this cart. tyvmia

  • 1
    Look up BTCPAYSERVER, it is an open source project that may do what you want. – chytrik May 23 '19 at 20:30

You can generate bitcoin addresses for each new payment with a script or using Bitcoin core. To see what has been received you can use some api of blockchain to see the balance in bitcoin of an address.

| improve this answer | |
  • You need to learn the concept of private and public keys, and you can search for similar content: duckduckgo.com/… – Anderson Juhasc May 23 '19 at 19:49
  • 1
    If you are running your own node (which you should do, if accepting payments), then there is no reason to use blockchain (the company's) API. Why trust, and sacrifice your privacy to them? – chytrik May 23 '19 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.