Stripe API finished
parent
dfc5a2c435
commit
5c51aab076
|
@ -205,6 +205,13 @@ app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRe
|
|||
|
||||
<hr>
|
||||
|
||||
<img src="https://stripe.com/img/about/logos/logos/black@2x.png" width="200">
|
||||
- [Sign up](http://stripe.com) or log into your your [dashboard](https://manage.stripe.com)
|
||||
- Click on your profile and click on Account Settings
|
||||
- Then click on [API Keys](https://manage.stripe.com/account/apikeys)
|
||||
- Copy the **Secret Key**. and add this into `config/secrets.js`
|
||||
<hr>
|
||||
|
||||
<img src="https://www.paypalobjects.com/webstatic/developer/logo_paypal-developer_beta.png" width="200">
|
||||
- Visit [PayPal Developer](https://developer.paypal.com/)
|
||||
- Log in to your PayPal account
|
||||
|
|
3
app.js
3
app.js
|
@ -126,14 +126,11 @@ app.get('/api/paypal', apiController.getPayPal);
|
|||
app.get('/api/paypal/success', apiController.getPayPalSuccess);
|
||||
app.get('/api/paypal/cancel', apiController.getPayPalCancel);
|
||||
app.get('/api/steam', apiController.getSteam);
|
||||
|
||||
app.get('/api/stripe', apiController.getStripe);
|
||||
app.get('/api/stripe/onetime', apiController.getStripeOnetime);
|
||||
app.post('/api/stripe/onetime', apiController.postStripeOnetime);
|
||||
app.get('/api/stripe/newsubscriber', apiController.getStripeNewSubscriber);
|
||||
app.post('/api/stripe/newsubscriber', apiController.postStripeNewSubscriber);
|
||||
app.get('/api/stripe/customers', apiController.getStripeCustomers);
|
||||
|
||||
app.get('/api/scraping', apiController.getScraping);
|
||||
app.get('/api/twilio', apiController.getTwilio);
|
||||
app.post('/api/twilio', apiController.postTwilio);
|
||||
|
|
|
@ -385,6 +385,12 @@ exports.getSteam = function(req, res, next) {
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /api/stripe
|
||||
* Stripe API example.
|
||||
*/
|
||||
|
||||
exports.getStripe = function(req, res, next) {
|
||||
//Create a token for the CC
|
||||
res.render('api/stripe/index', {
|
||||
|
@ -392,6 +398,10 @@ exports.getStripe = function(req, res, next) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /api/onetime
|
||||
* Stripe One Time Charge API example.
|
||||
*/
|
||||
exports.getStripeOnetime = function(req, res, next) {
|
||||
//Create a token for the CC
|
||||
res.render('api/stripe/onetime', {
|
||||
|
@ -399,6 +409,18 @@ exports.getStripeOnetime = function(req, res, next) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* POST /api/stripe/onetime
|
||||
* @param ccNumber
|
||||
* @param expMonth
|
||||
* @param expYear
|
||||
* @param ccNumber
|
||||
* @param expMonth
|
||||
* @param expYear
|
||||
* @param customerName
|
||||
* @param email
|
||||
* @param chargeAmount
|
||||
*/
|
||||
exports.postStripeOnetime = function(req, res, next) {
|
||||
stripe.tokens.create({
|
||||
card: {
|
||||
|
@ -440,7 +462,10 @@ exports.postStripeOnetime = function(req, res, next) {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* GET /api/newsubscriber
|
||||
* Stripe Subscription API example.
|
||||
*/
|
||||
exports.getStripeNewSubscriber = function(req, res, next) {
|
||||
stripe.plans.list(function(err, plans) {
|
||||
res.render('api/stripe/newsubscriber', {
|
||||
|
@ -450,6 +475,18 @@ exports.getStripeNewSubscriber = function(req, res, next) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* POST /api/stripe/newsubscriber
|
||||
* @param ccNumber
|
||||
* @param expMonth
|
||||
* @param expYear
|
||||
* @param ccNumber
|
||||
* @param expMonth
|
||||
* @param expYear
|
||||
* @param customerName
|
||||
* @param email
|
||||
* @param plantype
|
||||
*/
|
||||
exports.postStripeNewSubscriber = function(req, res, next) {
|
||||
console.log(req.body.plantype);
|
||||
|
||||
|
@ -496,15 +533,6 @@ exports.postStripeNewSubscriber = function(req, res, next) {
|
|||
});
|
||||
};
|
||||
|
||||
exports.getStripeCustomers = function(req, res, next) {
|
||||
stripe.customers.list(function(err, customers) {
|
||||
customersList = JSON.stringify(customers.data);
|
||||
res.render('api/stripe/customers', {
|
||||
title: 'Stripe API',
|
||||
customers: customersList
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /api/twilio
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
extends ../../layout
|
||||
|
||||
block content
|
||||
.page-header
|
||||
h2
|
||||
i.fa.fa-dollar
|
||||
| Stripe API
|
||||
|
||||
.btn-group.btn-group-justified
|
||||
a.btn.btn-primary(href='/api/stripe')
|
||||
i.fa.fa-home
|
||||
| All API Calls
|
||||
a.btn.btn-primary(href='https://stripe.com/docs/api', target='_blank')
|
||||
i.fa.fa-code
|
||||
| API Reference
|
||||
a.btn.btn-primary(href='https://manage.stripe.com/account/apikeys', target='_blank')
|
||||
i.fa.fa-gear
|
||||
| API Keys
|
||||
br
|
||||
.row
|
||||
.col-sm-12
|
||||
if customers
|
||||
h2 Customers
|
||||
pre
|
||||
|!{JSON.stringify(customer)}
|
||||
h2 Payment
|
||||
pre
|
||||
|!{JSON.stringify(charge)}
|
||||
else
|
||||
h2 No Customers API
|
|
@ -8,6 +8,3 @@ block content
|
|||
a(href='/api/stripe/onetime') One Time Charges
|
||||
li
|
||||
a(href='/api/stripe/newsubscriber') New Subscriber
|
||||
li
|
||||
a(href='/api/stripe/customers') List All Customers
|
||||
|
||||
|
|
Loading…
Reference in New Issue