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?

janowitz
  • 2,691
  • 12
  • 30

3 Answers3

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

well_then
  • 430
  • 3
  • 10
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.

sgp
  • 8,836
  • 7
  • 43
  • 113
-1

You can use the code demonstrated here:

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

And detailed here:

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

Ginger Ale
  • 5,694
  • 2
  • 19
  • 46