summaryrefslogtreecommitdiff
path: root/server/lib/views/subscription.js
blob: 251e2170a33f54f064bf382fb956553b7f776453 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* jshint node: true */

var User = require('../schemas/User'),
	Subscription = require('../schemas/Subscription'),
	config = require('../../../config'),
	middleware = require('../middleware'),
	util = require('../util'),
	_ = require('lodash'),
	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 = {
	
	fields: {
	  user: "_id username displayName photo created_at updated_at last_seen created_ip last_ip",
	},
	
	defaults: {
	  user: {
	    _id: "", username: "", displayName: "",
      created_at: "", updated_at: "", created_ip: "", last_ip: "",
	  },
	},

	middleware: {
  },

	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 }));
		});
	},
}