hapi-paypal
Advanced tools
Comparing version 0.0.29 to 0.0.30
@@ -32,2 +32,3 @@ import * as hapi from "hapi"; | ||
register: hapi.PluginFunction<any>; | ||
private defaultResponseHandler(ohandler, request, reply, error, response); | ||
private buildRoutes(routes); | ||
@@ -34,0 +35,0 @@ private enableWebhooks(webhook); |
@@ -66,8 +66,3 @@ "use strict"; | ||
paypal.payment.create(request.payload, (error, response) => { | ||
if (ohandler) { | ||
ohandler.apply(this, [request, reply, error, response]); | ||
} | ||
else { | ||
return error ? reply(boom.badRequest(error.response.message)) : reply(response); | ||
} | ||
this.defaultResponseHandler(ohandler, request, reply, error, response); | ||
}); | ||
@@ -88,8 +83,3 @@ return; | ||
} | ||
if (ohandler) { | ||
ohandler.apply(this, [request, reply, error, response]); | ||
} | ||
else { | ||
return error ? reply(boom.badRequest(error.response.message)) : reply(response); | ||
} | ||
this.defaultResponseHandler(ohandler, request, reply, error, response); | ||
}); | ||
@@ -106,10 +96,4 @@ }, | ||
paypal.invoice.search(request.payload, (error, response) => { | ||
if (ohandler) { | ||
ohandler.apply(this, [request, reply, error, response]); | ||
} | ||
else { | ||
return error ? reply(boom.badRequest(error.response.message)) : reply(response); | ||
} | ||
this.defaultResponseHandler(ohandler, request, reply, error, response); | ||
}); | ||
return; | ||
}, | ||
@@ -125,10 +109,4 @@ method: "POST", | ||
paypal.invoice.create(request.payload, (error, response) => { | ||
if (ohandler) { | ||
ohandler.apply(this, [request, reply, error, response]); | ||
} | ||
else { | ||
return error ? reply(boom.badRequest(error.response.message)) : reply(response); | ||
} | ||
this.defaultResponseHandler(ohandler, request, reply, error, response); | ||
}); | ||
return; | ||
}, | ||
@@ -144,8 +122,3 @@ method: "POST", | ||
paypal.invoice.send(request.params.invoiceid, request.payload, (error, response) => { | ||
if (ohandler) { | ||
ohandler.apply(this, [request, reply, error, response]); | ||
} | ||
else { | ||
return error ? reply(boom.badRequest(error.response.message)) : reply(response); | ||
} | ||
this.defaultResponseHandler(ohandler, request, reply, error, response); | ||
}); | ||
@@ -163,8 +136,3 @@ return; | ||
paypal.invoice.get(request.params.invoiceid, (error, response) => { | ||
if (ohandler) { | ||
ohandler.apply(this, [request, reply, error, response]); | ||
} | ||
else { | ||
return error ? reply(boom.badRequest(error.response.message)) : reply(response); | ||
} | ||
this.defaultResponseHandler(ohandler, request, reply, error, response); | ||
}); | ||
@@ -177,2 +145,16 @@ return; | ||
} | ||
defaultResponseHandler(ohandler, request, reply, error, response) { | ||
if (ohandler) { | ||
ohandler(request, reply, error, response); | ||
} | ||
else { | ||
if (error) { | ||
const bError = boom.badRequest(error.response.message); | ||
bError.output.payload.details = error.response.details; | ||
bError.reformat(); | ||
return reply(bError); | ||
} | ||
return reply(response); | ||
} | ||
} | ||
buildRoutes(routes) { | ||
@@ -179,0 +161,0 @@ routes.forEach((route) => { |
{ | ||
"name": "hapi-paypal", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "A hapi plugin to interface with PayPal Rest API's and webhooks.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29434
369