Skip to content

Commit 307874c

Browse files
Establish https://localhost:8443/.well-known/pay
1 parent b2ceaeb commit 307874c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/create-app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const vhost = require('vhost')
1515
const EmailService = require('./services/email-service')
1616
const TokenService = require('./services/token-service')
1717
const capabilityDiscovery = require('./capability-discovery')
18+
const paymentPointerDiscovery = require('./payment-pointer-discovery')
1819
const API = require('./api')
1920
const errorPages = require('./handlers/error-pages')
2021
const config = require('./server-config')
@@ -166,6 +167,7 @@ function initHeaders (app) {
166167
})
167168

168169
app.use('/', capabilityDiscovery())
170+
app.use('/', paymentPointerDiscovery())
169171
}
170172

171173
/**

lib/payment-pointer-discovery.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
/**
3+
* @module payment-pointer-discovery
4+
*/
5+
const express = require('express')
6+
7+
module.exports = paymentPointerDiscovery
8+
9+
/**
10+
* Returns a set of routes to deal with server payment pointer discovery
11+
* @method paymentPointerDiscovery
12+
* @return {Router} Express router
13+
*/
14+
function paymentPointerDiscovery () {
15+
const router = express.Router('/')
16+
17+
// Advertise the server payment pointer discover endpoint
18+
router.get('/.well-known/pay', paymentPointerDocument())
19+
return router
20+
}
21+
22+
/**
23+
* Serves the service payment pointer document (containing server root URL, including
24+
* any base path the user specified in config, server API endpoints, etc).
25+
* @method paymentPointerDocument
26+
* @param req
27+
* @param res
28+
* @param next
29+
*/
30+
function paymentPointerDocument () {
31+
return (req, res) => {
32+
res.json({
33+
hello: 'world'
34+
})
35+
}
36+
}

0 commit comments

Comments
 (0)