Static Serving PayID Addresses
Tags: payid, xrp, bitcoin, ilp
Published: 2020-06-18 21:47:50

# What is PayID?

So you heard the great news about [PayID](https://payid.org/)? 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:

- [Industry Leaders Launch PayID, the Universal ID for Payments](https://www.businesswire.com/news/home/20200618005489/en/Industry-Leaders-Launch-PayID-Universal-ID-Payments/?feedref=JjAwJuNHiystnCoBq_hl-aWOJSq7maz1kUlsOIrkZM4xz5QOdfJiTifxwfmkU5A67fxFuNFTHSunhvli30RlBNXya2izy9YOgHlBiZQk2LPgxNjXHjsNmKaXEz4koEK2KQOELXF1Klv27yoigQe38g==)
- [Ripple backs simplified SWIFT rival PayID](https://decrypt.co/32712/ripple-brave-payid-swift-codes-email-address)
- [Simplifying Global Payments with PayID](https://medium.com/brd-blog/simplifying-global-payments-with-payid-ee683d1235b9)
- [PayID: 'email address' for payments, available today in XUMM](https://coil.com/p/wietse/PayID-email-address-for-payments-available-today-in-XUMM/dQlHAvNKe)

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](https://payid.org/about-us).

# 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.

```apache
<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>
```

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:

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

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](https://xumm.app/), one of the first to support PayID, looking up the PayID setup above.

![Screencast of Xumm looking up a PayID](https://dev-to-uploads.s3.amazonaws.com/i/8hfn0bklymsxktbs373p.gif)