Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/cli invoice expiry opt #4 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nanotip.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ app.post('/', (req, res, next) =>
amount: req.body.amount
, currency: req.body.currency
, description: app.settings.title
, expiry: process.env.INVOICE_EXPIRY
, webhook: app.settings.url + '/webhook/' + webhookToken
, metadata: { source: 'nanotip', checkout: { redirect_url: thankyouUrl }, info: req.body.info }
})
Expand Down
9 changes: 5 additions & 4 deletions nanotipd
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ const args = require('meow')(`
-u, --url <url> http server public url (used for webhooks) [default: http://{host}:{port}]
-T, --thankyou-url <url> url to send users to after completing the payment [default: {url}/thankyou]
-e, --node-env <env> nodejs environment mode [default: production]
-X, --expiry <sec> invoice expiry time [default: 3600 seconds]
-h, --help output usage information
-v, --version output version number

Example
$ nanotipd -c http://localhost:9112 -t chargeSecretToken

`, { flags: { chargeUrl: {alias:'c', default: 'http://localhost:9112'}, chargeToken: {alias:'t'}, chargePublicUrl: {alias:'P'}
, theme: {alias:'m'}, title: {alias:'l'}, url: {alias:'u'}, thankyouUrl: {alias:'T'}
, port: {alias:'p'}, host: {alias:'i'}, nodeEnv: {alias:'e', default:'production'} } }
, theme: {alias:'m'}, title: {alias:'l'}, url: {alias:'u'}, thankyouUrl: {alias:'T'}
, port: {alias:'p'}, host: {alias:'i'}, nodeEnv: {alias:'e', default:'production'}, invoiceExpiry: {alias: 'X', default: "3600" } } }
).flags

Object.keys(args).filter(k => k.length > 1)
.forEach(k => process.env[k.replace(/([A-Z])/g, '_$1').toUpperCase()] = args[k])

process.env.CHARGE_TOKEN || (console.error('--charge-token is required'), process.exit(1))

require('./nanotip')