10

I would like to integrate Monero payments on my website. I already know some of the PHP Libraries and https://monero-merchants.com/

Is there a simple way (somehow easy like monero-merchants.com) to integrate Monero payments to my website without having to trust a third party? The PHP libraries seem to require an own full node to run, or are there "open" nodes available which I can use in the PHP libraries?

3 Answers 3

7

From the looks of it it seems that you need to run a full node. I run a node myself and there is very little system overhead outside of hard disk space to store the block chain (which honestly isn't too big of a deal, so long as you make sure you have enough space for it to grow).

Once you have a node that's caught up on the blockchain (in my experience this takes anywhere between a few hours to 2 days depending on the system (SSD's help a lot) and network).

The basics of receiving payment are:

  1. Generate a payment ID (a random 64 character hexadecimal string)
  2. Communicate the payment ID and Monero address
  3. Check for the payment using the "payments" command in simplewallet

It's worth noting that the name of this command has been changed to monero-wallet-cli since the writing of the tutorial

Then you'd want to check your wallet to ensure that the funds have been received. To do this programatically a JSON RPC API is available. Here are two helpful commands to accomplish this:

  • get_payments: this requires a payment_id parameter with a single payment ID
  • get_bulk_payments: this is the preferred method, and requires two parameters, payment_ids - a JSON array of payment IDs - and an optional min_block_height - the block height to scan from.

additionally here is the general algorithm that is recommended to scan for transactions:

  1. Get the current block height from the daemon, only proceed if it has increased since our last scan
  2. Call the get_bulk_payments RPC API call with our last scanned height and the list of all payment IDs in our system
  3. Store the current block height as our last scanned height
  4. Remove duplicates based on transaction hashes we have already received and processed

Also the following is essential knowledge to tally payments:

a transaction will typically have multiple outputs that add up to the total required for the payment, the amounts should be grouped by the tx_hash or the payment_id and added together. Additionally, as multiple outputs can have the same amount, it is imperative not to try and filter out the returned data from a single get_bulk_payments call.

See https://getmonero.org/getting-started/accepting for more details

2
  • Welcome to Monero! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Oct 9, 2016 at 9:43
  • Updated my original answer with plenty of details!
    – well_then
    Oct 10, 2016 at 6:12
1

You can attempt to communicate with another person's node. For instance, you can connect to node.moneroworld.com or 2nodez.moneroworld.com. See more information about these specific nodes, which are actually collections of nodes, here. I have not tested to see if these accept RPC connections, but this method will only work if they do accept RPC connections.

Take one of these nodes and follow this page to check for Monero payments programically. I have adapted the command below:

curl -X POST http://node.moneroworld.com/json_rpc -d '{"jsonrpc":"2.0","method":"get_bulk_payments","id":"test", "params":{"payment_ids": ["666c75666679706f6e7920697320746865206265737420706f6e792065766572"]}}' -H "Content-Type: application/json"

If this is a valid command, it will return a result showing the amount, block height, payment ID, transaction hash, and unlock time for each transaction.

3
  • I don't think this works, mainly due to the new user permissions thing.
    – Ginger Ale
    Oct 9, 2016 at 23:54
  • @GingerAle I haven't tried this myself, but if this no longer works, I hope someone can update the getmonero page.
    – sgp
    Oct 9, 2016 at 23:58
  • 1
    It will work on a node that you own and operate. But remote nodes are started with the flag --restricted-rpc in order to prevent malicious behavior. I assume this flag is why the above doesn't work with remote nodes.
    – Ginger Ale
    Oct 10, 2016 at 1:08
-1

You can use the code demonstrated here:

https://xmr.llcoins.net/addresstests.html

And detailed here:

https://xmr.llcoins.net/js/site.js

2
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Oct 10, 2016 at 8:14
  • I agree, but I don't know what the essential parts of that code are. Hopefully someone else can step up to the plate.
    – Ginger Ale
    Oct 10, 2016 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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