DEV Community

Cover image for Static Serving PayID Addresses
Matt Hamilton
Matt Hamilton

Posted on • Updated on

Static Serving PayID Addresses

What is PayID?

So you heard the great news about PayID? It is a universal payment identified to be used with both traditional banking and cryptocurrency accounts to provide a simple, easy to use ID for payments.

It was launched today, and quite a lot of coverage about it:

Want to pay me? My PayID is matt$quernus.co.uk. Is that a bank? XRP? Bitcoin? Who knows? Who cares! But you can pay me by sending a payment to that ID. And the great thing is that it is backed by a whole load of companies.

Setting up PayID

There are some great instructions for setting up a PayID server here: https://docs.payid.org/

But! What if you don't want to run a server to do it? What if you just want to statically configure an entry or two and you happen to run your own server and have your own domain?

Here is how to setup a PayID on an Apache server to serve up a simple static PayID file. In this case directing to an XRP wallet.

The convention for the lookup is that matt$quernus.co.uk is rewritten to an HTTPS request to https://quernus.co.uk/matt ie. the local part before the $ is put in the end as the path.

First: You need to configure Apache. I'll include the full virtualhost directive below for completeness, but the PayID bit is just the last 3 lines below the comment.

<VirtualHost [2001:41c8:11a:5::1]:443 46.43.0.47:443>
    ServerName www.quernus.co.uk
    ServerAlias quernus.co.uk
    DocumentRoot "/var/www/htdocs/www.quernus.co.uk/"

    Header always set Strict-Transport-Security "max-age=63072000; preload"

    SSLEngine on
    SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
    SSLProtocol All -SSLv2 -SSLv3
    SSLHonorCipherOrder On
    SSLSessionTickets Off

    SSLCertificateFile "/etc/letsencrypt/live/www.quernus.co.uk/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/www.quernus.co.uk/privkey.pem"

    ErrorDocument 404 /404.html

    # PayID
    RewriteEngine On
    RewriteCond "%{HTTP_ACCEPT}" "application/xrpl-mainnet\+json"
    RewriteRule ^(.+) /.pay/$1.json [L]

</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

The first list turn Apache's rewrite engine on. You may already have this. The second line is a rewrite condition that means it will only catch requests with a specific accept request HTTP header. The last line is the actual rewrite rule and will fetch the requested file with .json on the end.

So I then have a file /var/www/htdocs/www.quernus.co.uk/.pay/matt.json that contains:

{
  "addresses": [
    {
      "paymentNetwork": "XRPL",
      "environment": "MAINNET",
      "addressDetailsType": "CryptoAddressDetails",
      "addressDetails": {
        "address": "X75nEw5QD8Ej8jWt7EkJXHoVAV9YCtjuUSJppADpNtPKdim"
      }
    }
  ],
  "payId": "matt$quernus.co.uk"
}
Enter fullscreen mode Exit fullscreen mode

You can look up the full format of this file in the PayID docs site above, but in short the above details an XRP account on the mainnet of the XRP Ledger.

Demo of PayID in Xumm

Below is a demo of this excellent wallet Xumm, one of the first to support PayID, looking up the PayID setup above.

Screencast of Xumm looking up a PayID

Top comments (6)

Collapse
 
guykatz profile image
guykatz

is there a big enogh company that I can get a payid from right now?
for example, google controls the email market. I am looking for the company that will potentialy control the payid market to sign up and get my payid from (names will be taken very fast)...

Collapse
 
freakaz0idberg profile image
Freakaz0idberg

hey Matt, thanks for the tutorial :-) I‘ve set up all, but xumm doesnt recognice my payID. How can i test it? Is there an API testtool where i can put my websitepath in or something? Maybe my rewriterule doesnt work.

Collapse
 
hammertoe profile image
Matt Hamilton

Hi! Glad you found it useful. I'm not aware of any testing tools, but that certainly would be a useful thing. I am thinking I might try and make one if I can.

Collapse
 
ronpimplebut profile image
RonPimplebut

is it works on raspberry pi 4?

Collapse
 
besmily profile image
besmily

quel développeur serait compétent pour l'integrer sur mon site web?

Collapse
 
besmily profile image
besmily

le systeme xumm est possible sur htpps?