diff options
| -rw-r--r-- | package.json | 37 | ||||
| -rw-r--r-- | server/index.js | 1 | ||||
| -rw-r--r-- | server/lib/views/subscription.js | 81 |
3 files changed, 92 insertions, 27 deletions
diff --git a/package.json b/package.json index adefb82..34e0c4c 100644 --- a/package.json +++ b/package.json @@ -6,32 +6,33 @@ "url": "git://github.com/okfocus/vvalls.git" }, "dependencies": { - "express": "~3.4.8", - "monk": "~0.7.1", - "socket.io": "~0.9.16", + "body-parser": "1.3.0", "connect-mongo": "~0.4.1", - "passport": "~0.2.0", - "passport-local": "~1.0.0", - "passport-twitter": "~1.0.2", - "passport-facebook": "~1.0.3", - "passport.socketio": "~3.0.1", - "node-restful": "~0.1.14", "ejs": "^0.8.8", - "useful-string": "0.0.1", + "emailjs": "~0.3.6", + "express": "~3.4.8", "express-subdomain-handler": "~0.1.0", "express-subdomains": "0.0.5", + "html-entities": "~1.0.10", + "intro.js": "^0.9.0", + "knox": "~0.8.10", "lodash": "~2.4.1", + "marked": "~0.3.2", + "moment": "~2.6.0", "mongoose": "~3.8.8", - "mongoose-unique-validator": "~0.3.0", "mongoose-lifecycle": "~1.0.0", - "knox": "~0.8.10", - "moment": "~2.6.0", - "html-entities": "~1.0.10", + "mongoose-unique-validator": "~0.3.0", + "monk": "~0.7.1", "multer": "~0.1.0", - "body-parser": "1.3.0", - "marked": "~0.3.2", - "emailjs": "~0.3.6", - "intro.js": "^0.9.0" + "node-restful": "~0.1.14", + "passport": "~0.2.0", + "passport-facebook": "~1.0.3", + "passport-local": "~1.0.0", + "passport-twitter": "~1.0.2", + "passport.socketio": "~3.0.1", + "socket.io": "~0.9.16", + "useful-string": "0.0.1", + "xml2js": "^0.4.4" }, "devDependencies": { "grunt": "~0.4.1", diff --git a/server/index.js b/server/index.js index a14eaab..0f4941a 100644 --- a/server/index.js +++ b/server/index.js @@ -70,6 +70,7 @@ site.setup = function(){ app.all('*', middleware.ensureLocals); app.all('*', middleware.ensureIP); + // where should this live? app.get('/subscribe/webhook', views.subscription.webhook); server = http.createServer(app) diff --git a/server/lib/views/subscription.js b/server/lib/views/subscription.js index e29e40d..251e217 100644 --- a/server/lib/views/subscription.js +++ b/server/lib/views/subscription.js @@ -6,7 +6,15 @@ var User = require('../schemas/User'), middleware = require('../middleware'), util = require('../util'), _ = require('lodash'), - moment = require('moment'); + moment = require('moment'), + xml2js = require('xml2js'); + +var parser = new xml2js.Parser(); +// fs.readFile('./foo.xml', function(err, data) { +// parser.parseString(data, function (err, result) { +// console.log(inspect(result, { colors: true, depth: Infinity })); +// }); +// }); var subscription = module.exports = { @@ -24,18 +32,73 @@ var subscription = module.exports = { middleware: { }, - helpers: { - project: function(project){ - project = project.toObject() - project.date = moment( project.updated_at || project.created_at ).format("M/DD/YYYY hh:mm a") - project.user = {} - return project - }, - }, + fields: [ + "new_account_notification", + "canceled_account_notification", + "billing_info_updated_notification", + "reactivated_account_notification", + "new_invoice_notification", + "closed_invoice_notification", + "past_due_invoice_notification", + "new_subscription_notification", + "updated_subscription_notification", + "canceled_subscription_notification", + "expired_subscription_notification", + "renewed_subscription_notification", + "successful_payment_notification", + "failed_payment_notification", + "successful_refund_notification", + "void_payment_notification", + ], + + callbacks: { + // accounts + new_account_notification: function(data){ + }, + canceled_account_notification: function(data){ + }, + billing_info_updated_notification: function(data){ + }, + reactivated_account_notification: function(data){ + }, + + // invoices + new_invoice_notification: function(data){ + }, + closed_invoice_notification: function(data){ + }, + past_due_invoice_notification: function(data){ + }, + + // subscriptions + new_subscription_notification: function(data){ + }, + updated_subscription_notification: function(data){ + }, + canceled_subscription_notification: function(data){ + }, + expired_subscription_notification: function(data){ + }, + renewed_subscription_notification: function(data){ + }, + + // payments + successful_payment_notification: function(data){ + }, + failed_payment_notification: function(data){ + }, + successful_refund_notification: function(data){ + }, + void_payment_notification: function(data){ + }, + }, // need a route for the webhook, // then calls to get appropriate info from the recurly api webhook: function(req, res){ res.status(200).end() + parser.parseString(data, function (err, result) { + console.log(inspect(result, { colors: true, depth: Infinity })); + }); }, } |
