@@ -16,7 +16,7 @@ var fs = require("fs")
16
16
// express library for defining routes
17
17
var express = require ( "express" ) ;
18
18
19
- // try and load a .env file.
19
+ // try and load a .env file.
20
20
// This will put out a warning if one does not exist but that's fine
21
21
// if it doesn't exist, you should be setting the environment variables manually.
22
22
require ( "dotenv" ) . config ( ) ;
@@ -62,7 +62,7 @@ if(process.env.NODE_ENV !== 'production') {
62
62
var webpackHotMiddleware = require ( 'webpack-hot-middleware' ) ;
63
63
var webpack = require ( 'webpack' ) ;
64
64
var compiler = webpack ( config ) ;
65
-
65
+
66
66
app . use ( webpackDevMiddleware ( compiler , { noInfo : true , publicPath : config . output . publicPath } ) ) ;
67
67
app . use ( webpackHotMiddleware ( compiler ) ) ;
68
68
}
@@ -73,7 +73,7 @@ var cookieParser = require("cookie-parser")
73
73
var csrf = require ( "csurf" ) ;
74
74
var csrfProtection = csrf (
75
75
{ cookie :{
76
- secure : app_config . http_override ? false : true ,
76
+ secure : app_config . http_override ? false : true ,
77
77
httpOnly : true
78
78
}
79
79
}
@@ -122,7 +122,7 @@ winston.add(winston.transports.Console, {
122
122
123
123
// define our logger
124
124
// the expressWinston.logger only logs the HTTP(s) requests and response
125
- // the expressWinston.errorLogger is at the bottom of the file. It has be
125
+ // the expressWinston.errorLogger is at the bottom of the file. It has be
126
126
var expressTransports = [
127
127
new winston . transports . Console ( {
128
128
colorize : true ,
@@ -194,9 +194,9 @@ function sendResponse(package, res) {
194
194
res . setHeader ( 'Content-Type' , 'application/json' ) ;
195
195
if ( package . error_code ) {
196
196
var error_package = {
197
- "error_code" :500 ,
198
- "error_description" :"wepay call died. Check server logs for more details." ,
199
- "error_message" :package . error_description ,
197
+ "error_code" :500 ,
198
+ "error_description" :"wepay call died. Check server logs for more details." ,
199
+ "error_message" :package . error_description ,
200
200
"original_error" :package }
201
201
winston . warn ( "Sending error!\t" , error_package ) ;
202
202
return res . status ( 500 ) . send ( JSON . stringify ( error_package ) ) ;
@@ -216,7 +216,7 @@ function sendResponse(package, res) {
216
216
* @param package - the package of data we want to send along with request. This can be an empty object depending on the endpoint
217
217
*/
218
218
function getWePayData ( res , wepay_endpoint , access_token , package ) {
219
-
219
+
220
220
var wepay_settings = { }
221
221
222
222
if ( access_token ) {
@@ -263,13 +263,13 @@ function getDataFromMiddleware(resource, data, callback) {
263
263
winston . info ( "Requesting data from middleware: " , uri , data ) ;
264
264
return request . post (
265
265
{
266
- url : uri ,
266
+ url : uri ,
267
267
json : data ,
268
268
headers : {
269
269
"Authorization" :app_config . middleware_secret
270
270
}
271
271
272
- } ,
272
+ } ,
273
273
callback
274
274
) ;
275
275
}
@@ -317,20 +317,20 @@ function parseMiddlewareResponse(req, res, error, response, body, wepay_endpoint
317
317
app . post ( "/user" , csrfProtection , function ( req , res ) {
318
318
winston . info ( 'Incoming user request: ' , req . body ) ;
319
319
var package = { } ;
320
-
320
+
321
321
// get the email from the search
322
322
var email = req . body . email ;
323
323
var account_id = req . body . account_id ;
324
324
325
325
// get the necessary data from our middleware function and then make the corresponding request to WePay
326
326
getDataFromMiddleware (
327
- "user" ,
327
+ "user" ,
328
328
{
329
329
"account_owner_email" :email ,
330
330
"account_id" : account_id
331
- } ,
331
+ } ,
332
332
function ( error , response , body ) {
333
- return parseMiddlewareResponse ( req , res , error , response , body , "/user" , { } ) ;
333
+ return parseMiddlewareResponse ( req , res , error , response , body , "/user" , { } ) ;
334
334
}
335
335
) ;
336
336
} )
@@ -355,8 +355,8 @@ app.post('/account', csrfProtection, function(req, res){
355
355
package [ 'account_id' ] = req . body . account_id ;
356
356
wepay_endpoint = "/account" ;
357
357
return getDataFromMiddleware (
358
- "user" ,
359
- { "account_id" :req . body . account_id } ,
358
+ "user" ,
359
+ { "account_id" :req . body . account_id } ,
360
360
function ( error , response , body ) {
361
361
parseMiddlewareResponse ( req , res , error , response , body , wepay_endpoint , package )
362
362
} ) ;
@@ -374,7 +374,7 @@ app.post('/account', csrfProtection, function(req, res){
374
374
* This endpoint has two seperate actions depending on the parameters passed
375
375
* If no checkout_id is given, then this will get the 50 most recent checkouts for the given account_id
376
376
* If a checkout_id is given, then this will fetch information for that checkout specifically.
377
- * Passing the checkout_id is useful for updating a checkout's info after performing an action with the dashboard.
377
+ * Passing the checkout_id is useful for updating a checkout's info after performing an action with the dashboard.
378
378
*/
379
379
app . post ( "/checkout" , csrfProtection , function ( req , res ) {
380
380
// prep the package and wepay_endpoint we want to hit
@@ -395,7 +395,7 @@ app.post("/checkout", csrfProtection, function(req, res) {
395
395
396
396
return getDataFromMiddleware ( "user" , { "account_id" :req . body . account_id } , function ( error , response , body ) {
397
397
parseMiddlewareResponse ( req , res , error , response , body , wepay_endpoint , package ) ;
398
- } ) ;
398
+ } ) ;
399
399
} )
400
400
401
401
/**
@@ -412,24 +412,24 @@ app.post("/withdrawal", csrfProtection, function(req, res){
412
412
winston . info ( "Received request for withdrawals" ) ;
413
413
var package = { "account_id" :req . body . account_id } ;
414
414
return getDataFromMiddleware (
415
- "user" ,
416
- { "account_id" :req . body . account_id } ,
415
+ "user" ,
416
+ { "account_id" :req . body . account_id } ,
417
417
function ( error , response , body ) {
418
418
parseMiddlewareResponse ( req , res , error , response , body , "/withdrawal/find" , package ) ;
419
419
} ) ;
420
420
} )
421
421
422
422
/**
423
423
* Perform a refund for a given checkout_id.
424
- *
424
+ *
425
425
* This endpoint expects the following fields in the body of the request:
426
426
* @param checkout_id - the checkout_id
427
427
* @param refund_reason - the reason that the checkout is being refunded
428
428
* @param amount - (optional) initates a partial refund for the specified amount
429
429
* @param app_fee - (optional) initiates a partial refund for the specified app_fee amount
430
430
* The amount field should be used to perform a partial refund.
431
431
* When doing a partial refund, you can also pass a app_fee that specifies how much of the app_fee you want to refund
432
- *
432
+ *
433
433
* If no amount is passed, this will do a full refund
434
434
*/
435
435
app . post ( "/refund" , csrfProtection , function ( req , res ) {
@@ -445,8 +445,8 @@ app.post("/refund", csrfProtection, function(req, res) {
445
445
}
446
446
447
447
return getDataFromMiddleware (
448
- "user" ,
449
- { "account_id" :req . body . account_id } ,
448
+ "user" ,
449
+ { "account_id" :req . body . account_id } ,
450
450
function ( error , response , body ) {
451
451
return parseMiddlewareResponse ( req , res , error , response , body , "/checkout/refund" , package )
452
452
}
@@ -472,14 +472,14 @@ app.post("/reserve", csrfProtection, function(req, res) {
472
472
/**
473
473
* Given a payer's unique identifying information (such as their email), get a list of all of their checkouts from the middleware
474
474
*/
475
- app . post ( "/payer" , csrfProtection , function ( req , res ) {
476
- winston . info ( "Received request for payer" ) ;
475
+ app . post ( "/payer" , csrfProtection , function ( req , res ) {
476
+ winston . info ( "Received request for payer" ) ;
477
477
// get the email from the search
478
478
var email = req . body . email ;
479
479
// get the necessary data from our middleware function and then make the corresponding request to WePay
480
480
return getDataFromMiddleware (
481
- "payer" ,
482
- { "payer_email" :email , "num_elements" :50 } ,
481
+ "payer" ,
482
+ { "payer_email" :email , "num_elements" :50 } ,
483
483
function ( error , response , body ) {
484
484
return parseMiddlewareResponse ( req , res , error , response , body , null , null ) ;
485
485
}
0 commit comments