forked from eddywashere/node-stripe-membership-saas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eddy Hernandez
committed
Oct 24, 2014
0 parents
commit 34eb6fd
Showing
37 changed files
with
2,012 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.tmp | ||
.sass-cache | ||
/npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
Copyright © 2014 Eddy Hernandez <edward.d.hernandez@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the “Software”), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Node Stripe Membership SaaS | ||
|
||
This project is a boilerplate express app for creating a membership/subscription site with [Stripe](https://stripe.com), [Mailgun](https://mailgun.com/signup), mongodb and swig. Inspired by [sahat/hackathon-starter](https://github.com/sahat/hackathon-starter) and [RailsApps/rails-stripe-membership-saas](https://github.com/RailsApps/rails-stripe-membership-saas). | ||
|
||
Checkout the [demo](https://node-stripe-membership-saas.herokuapp.com/dashboard)! | ||
|
||
<a href="https://node-stripe-membership-saas.herokuapp.com/dashboard"> | ||
<img src="https://a16545fb495c8760fb33-4cec33efbe2744e99ba863e52edb2075.ssl.cf2.rackcdn.com/stripe-membership-app-screenshot.png"> | ||
</a> | ||
|
||
### System Requirements | ||
|
||
- mongodb | ||
- nodejs | ||
|
||
### Getting Started | ||
|
||
First update `/server/config/secrets.js` with the following credentials: | ||
|
||
- Stripe [API keys](https://dashboard.stripe.com/account/apikeys) and [plan info](https://dashboard.stripe.com/test/plans) | ||
- [Mailgun](https://mailgun.com/signup) for sending forgot/reset password confirmations. | ||
- session secret | ||
- google analytics id | ||
|
||
Install dependencies with `npm install`. | ||
|
||
Start the server with `node server`. | ||
|
||
### Heroku Deployment | ||
|
||
``` | ||
heroku create your-awesome-saas-product | ||
heroku addons:add mongohq | ||
heroku config:set SESSION_SECRET='your_secret'; | ||
heroku config:set STRIPE_KEY='sk_test_example' | ||
heroku config:set STRIPE_PUB_KEY='pk_test_example' | ||
heroku config:set MAILGUN_USER='example.org' | ||
heroku config:set MAILGUN_PASSWORD='key-secret' | ||
heroku config:set GOOGLE_ANALYTICS='UA-XXXXXX-1' | ||
``` | ||
|
||
Want add a heroku deploy button? Pull requests welcome :] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "node-stripe-membership-saas", | ||
"description": "This project is a boilerplate express app for creating a membership/subscription site with Stripe.", | ||
"version": "1.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/eddywashere/node-stripe-membership-saas.git" | ||
}, | ||
"keywords": [ | ||
"stripe", | ||
"subscription", | ||
"membership", | ||
"saas", | ||
"plan" | ||
], | ||
"author": { | ||
"name": "Eddy Hernandez", | ||
"email": "edward.d.hernandez@gmail.com", | ||
"url": "http://eddywashere.com" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/eddywashere/node-stripe-membership-saas/issues" | ||
}, | ||
"scripts": { | ||
"start": "node server" | ||
}, | ||
"dependencies": { | ||
"async": "^0.9.0", | ||
"bcrypt-nodejs": "0.0.3", | ||
"body-parser": "~1.8.1", | ||
"compression": "*", | ||
"connect-mongo": "*", | ||
"cookie-parser": "~1.3.3", | ||
"cors": "*", | ||
"debug": "~2.0.0", | ||
"express": "~4.9.0", | ||
"express-flash": "*", | ||
"express-session": "*", | ||
"express-subdomain": "^1.0.1", | ||
"express-validator": "^2.6.0", | ||
"lodash": "^2.4.1", | ||
"middleware-responder": "^1.0.0", | ||
"mongoose": "^3.8.16", | ||
"morgan": "~1.3.0", | ||
"nodemailer": "^1.3.0", | ||
"nodemailer-mailgunapi-transport": "0.0.3", | ||
"passport": "^0.2.1", | ||
"passport-local": "^1.0.0", | ||
"serve-favicon": "~2.1.3", | ||
"stripe": "^2.8.0", | ||
"swig": "^1.4.2" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
jQuery(function($) { | ||
|
||
var cardWrapper = $('#cardWrapper'), | ||
cardForm = $('#cardForm'), | ||
formError = $('#cardFormError'), | ||
cardFormBtn = cardForm.find('button'); | ||
|
||
if(cardWrapper.length > 0){ | ||
$("input[name=plan]:radio").change(function (e) { | ||
if(this.value == 'free'){ | ||
cardWrapper.hide(); | ||
} else { | ||
cardWrapper.show(); | ||
} | ||
}); | ||
if($("input:radio[name=plan]:checked").val() == 'free'){ | ||
cardWrapper.hide(); | ||
} | ||
} | ||
|
||
cardForm.submit(function(e) { | ||
e.preventDefault(); | ||
|
||
var cardNum, | ||
cardMonth, | ||
cardYear, | ||
cardCVC; | ||
|
||
if(cardForm.find("input:radio[name=plan]:checked").val() != 'free'){ | ||
cardFormBtn.prop('disabled', true); | ||
|
||
cardNum = $('#card-num').val(); | ||
cardMonth = $('#card-month').val(); | ||
cardYear = $('#card-year').val(); | ||
cardCVC = $('#card-cvc').val(); | ||
|
||
Stripe.card.createToken({ | ||
number: cardNum, | ||
exp_month: cardMonth, | ||
exp_year: cardYear, | ||
cvc: cardCVC | ||
}, function(status, response) { | ||
if (response.error) { | ||
formError.find('p').text(response.error.message); | ||
formError.removeClass('hidden'); | ||
cardForm.find('button').prop('disabled', false); | ||
} else { | ||
var token = response.id; | ||
cardForm.append($('<input type="hidden" name="stripeToken" />').val(token)); | ||
cardForm.get(0).submit(); | ||
} | ||
|
||
}); | ||
|
||
return false; | ||
} | ||
}); | ||
|
||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
body { | ||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; | ||
} | ||
|
||
a { | ||
color: #00B7FF; | ||
} | ||
|
||
.container-max { | ||
max-width: 900px; | ||
} | ||
|
||
.container-wide { | ||
max-width: 1100px; | ||
} | ||
|
||
/* custom navbar */ | ||
.navbar-default { | ||
background-color: #9b59b6; | ||
border-color: #8e44ad; | ||
} | ||
.navbar-default .navbar-brand { | ||
color: #ecf0f1; | ||
} | ||
.navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus { | ||
color: #ecdbff; | ||
} | ||
.navbar-default .navbar-text { | ||
color: #ecf0f1; | ||
} | ||
.navbar-default .navbar-nav > li > a { | ||
color: #ecf0f1; | ||
} | ||
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus { | ||
color: #ecdbff; | ||
} | ||
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus { | ||
color: #ecdbff; | ||
background-color: #8e44ad; | ||
} | ||
.navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus { | ||
color: #ecdbff; | ||
background-color: #8e44ad; | ||
} | ||
.navbar-default .navbar-toggle { | ||
border-color: #8e44ad; | ||
} | ||
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus { | ||
background-color: #8e44ad; | ||
} | ||
.navbar-default .navbar-toggle .icon-bar { | ||
background-color: #ecf0f1; | ||
} | ||
.navbar-default .navbar-collapse{ | ||
border: none; | ||
} | ||
.navbar-default .navbar-collapse, | ||
.navbar-default .navbar-form { | ||
border-color: #ecf0f1; | ||
} | ||
.navbar-default .navbar-link { | ||
color: #ecf0f1; | ||
} | ||
.navbar-default .navbar-link:hover { | ||
color: #ecdbff; | ||
} | ||
|
||
@media (max-width: 767px) { | ||
.navbar-default .navbar-nav .open .dropdown-menu > li > a { | ||
color: #ecf0f1; | ||
} | ||
.navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus { | ||
color: #ecdbff; | ||
} | ||
.navbar-default .navbar-nav .open .dropdown-menu > .active > a, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus { | ||
color: #ecdbff; | ||
background-color: #8e44ad; | ||
} | ||
} | ||
|
||
.btn-primary { | ||
background-color: #9b59b6; | ||
border-color: #9b59b6; | ||
} | ||
.btn-primary:hover, | ||
.btn-primary:focus, | ||
.btn-primary:active, | ||
.btn-primary.active { | ||
background-color: #8f4bab; | ||
border-color: #804399; | ||
} | ||
.btn-primary.disabled:hover, | ||
.btn-primary.disabled:focus, | ||
.btn-primary.disabled:active, | ||
.btn-primary.disabled.active, | ||
.btn-primary[disabled]:hover, | ||
.btn-primary[disabled]:focus, | ||
.btn-primary[disabled]:active, | ||
.btn-primary[disabled].active, | ||
fieldset[disabled] .btn-primary:hover, | ||
fieldset[disabled] .btn-primary:focus, | ||
fieldset[disabled] .btn-primary:active, | ||
fieldset[disabled] .btn-primary.active { | ||
background-color: #9b59b6; | ||
border-color: #9b59b6; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env node | ||
|
||
var debug = require('debug')('app'); | ||
var app = require('./server/index'); | ||
|
||
app.set('port', process.env.PORT || 3000); | ||
|
||
var server = app.listen(app.get('port'), function() { | ||
console.log('Express server listening on port ' + server.address().port); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module.exports = { | ||
|
||
db: process.env.MONGODB || process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || 'mongodb://localhost:27017/stripe-membership', | ||
|
||
sessionSecret: process.env.SESSION_SECRET || 'change this', | ||
|
||
mailgun: { | ||
user: process.env.MAILGUN_USER || '', | ||
password: process.env.MAILGUN_PASSWORD || '' | ||
}, | ||
|
||
stripeOptions: { | ||
apiKey: process.env.STRIPE_KEY || '', | ||
stripePubKey: process.env.STRIPE_PUB_KEY || '', | ||
defaultPlan: 'free', | ||
plans: ['free', 'silver', 'gold', 'platinum'], | ||
planData: { | ||
'free': { | ||
name: 'Free', | ||
price: 0 | ||
}, | ||
'silver': { | ||
name: 'Silver', | ||
price: 9 | ||
}, | ||
'gold': { | ||
name: 'Gold', | ||
price: 19 | ||
}, | ||
'platinum': { | ||
name: 'Platinum', | ||
price: 29 | ||
} | ||
} | ||
}, | ||
|
||
googleAnalytics: process.env.GOOGLE_ANALYTICS || '' | ||
}; |
Oops, something went wrong.