Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-paypal

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-paypal - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

6

lib/index.d.ts

@@ -26,7 +26,7 @@ import * as hapi from "hapi";

private getMockData(type);
private enableWebhooks();
private enableWebhooks(webhook);
private getWebhookEventTypes();
private getAccountWebhooks();
private createWebhook();
private replaceWebhook();
private createWebhook(webhook);
private replaceWebhook(webhook);
}

@@ -18,2 +18,3 @@ "use strict";

this.register = (server, options, next) => {
const promises = [];
const sdkSchema = Joi.object().keys({

@@ -28,7 +29,3 @@ client_id: Joi.string().min(10).required(),

}
paypal.configure({
client_id: options.sdk.client_id,
client_secret: options.sdk.client_secret,
mode: "sandbox",
});
paypal.configure(options.sdk);
server.expose("paypal", paypal);

@@ -45,3 +42,2 @@ options.routes.forEach((route) => server.route(this.buildRoute(route)));

}
this.webhook = options.webhook;
const webhookRoute = options.routes.filter((route) => route.config.id === "paypal_webhooks_listen")[0];

@@ -51,6 +47,9 @@ if (!webhookRoute) {

}
this.webhook.url += webhookRoute.path;
this.enableWebhooks();
const wopts = Object.assign({}, options.webhook);
wopts.url += webhookRoute.path;
promises.push(this.enableWebhooks(wopts));
}
next();
return Promise.all(promises).then(() => {
next();
});
};

@@ -132,3 +131,3 @@ this.register.attributes = {

}
enableWebhooks() {
enableWebhooks(webhook) {
return __awaiter(this, void 0, void 0, function* () {

@@ -138,7 +137,4 @@ try {

const accountWebHooks = yield this.getAccountWebhooks();
this.webhook = accountWebHooks.filter((hook) => hook.url === this.webhook.url)[0] || this.webhook;
if (!this.webhook.id) {
this.webhook = yield this.createWebhook();
}
this.webhook = yield this.replaceWebhook();
this.webhook = accountWebHooks.filter((hook) => hook.url === webhook.url)[0];
this.webhook = !this.webhook ? yield this.createWebhook(webhook) : yield this.replaceWebhook(webhook);
}

@@ -174,6 +170,5 @@ catch (err) {

}
createWebhook() {
const webhookConfig = this.webhook;
createWebhook(webhook) {
return new Promise((resolve, reject) => {
paypal.notification.webhook.create(webhookConfig, (error, webhook) => {
paypal.notification.webhook.create(webhook, (error, response) => {
if (error) {

@@ -183,3 +178,3 @@ reject(error);

else {
resolve(webhook);
resolve(response);
}

@@ -189,4 +184,3 @@ });

}
replaceWebhook() {
const webhookConfig = this.webhook;
replaceWebhook(webhook) {
return new Promise((resolve, reject) => {

@@ -196,4 +190,4 @@ paypal.notification.webhook.replace(this.webhook.id, [{

path: "/event_types",
value: webhookConfig.event_types,
}], (error, webhook) => {
value: webhook.event_types,
}], (error, response) => {
if (error && error.response.name !== "WEBHOOK_PATCH_REQUEST_NO_CHANGE") {

@@ -203,3 +197,3 @@ reject(error);

else {
resolve(webhook);
resolve(response);
}

@@ -206,0 +200,0 @@ });

{
"name": "hapi-paypal",
"version": "0.0.8",
"version": "0.0.9",
"description": "A hapi plugin to interface with PayPal Rest API's and webhooks.",

@@ -25,4 +25,3 @@ "license": "MIT",

"build": "npm run clean && npm run lint && echo Using TypeScript && tsc --version && tsc --pretty",
"test": "npm run build && mocha --compilers ts:ts-node/register --recursive 'test/**/*-spec.ts'",
"coverage": "nyc --include='src/**/*.ts' --reporter=text --reporter=html --reporter=lcov mocha --compilers ts:ts-node/register --recursive 'test/**/*.test.ts'",
"test": "nyc --reporter=lcov --require ts-node/register tape test/**/*-spec.ts | tap-spec; nyc report ---reporter=text",
"watch": "npm run build -- --watch",

@@ -32,3 +31,4 @@ "watch:test": "npm run test -- --watch",

"release:quick": "npm run build && git add -A && git commit -m 'Quick Release Patch' && npm version patch",
"postversion": "npm publish"
"postversion": "npm publish",
"reinstall": "rimraf node_modules package-lock.json && npm install"
},

@@ -43,14 +43,20 @@ "dependencies": {

"devDependencies": {
"@types/blue-tape": "^0.1.31",
"@types/chai": "^3.0.0",
"@types/hapi": "^16.1.6",
"@types/joi": "^10.4.0",
"@types/mocha": "^2.0.0",
"@types/mongoose": "^4.7.19",
"@types/node": "^7.0.0",
"@types/paypal-rest-sdk": "^1.7.0",
"@types/sinon": "^2.3.3",
"@types/tape": "^4.2.30",
"blue-tape": "^1.0.0",
"chai": "^3.0.0",
"coveralls": "^2.0.0",
"hapi": "^16.4.3",
"mocha": "^3.0.0",
"nyc": "^10.0.0",
"rimraf": "^2.0.0",
"sinon": "^2.3.8",
"tap-spec": "^4.1.1",
"tape": "^4.7.0",
"ts-node": "^3.0.0",

@@ -67,14 +73,6 @@ "tslint": "^5.0.0",

],
"exclude": [
"lib"
],
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"reporter": [],
"all": true
]
}
}

@@ -0,1 +1,4 @@

[![npm version](https://badge.fury.io/js/hapi-paypal.svg)](https://badge.fury.io/js/hapi-paypal)
[![Dependency Status](https://david-dm.org/trainerbill/paypal-hapi.svg)](https://david-dm.org/trainerbill/paypal-hapi)
[![devDependency Status](https://david-dm.org/trainerbill/paypal-hapi/dev-status.svg)](https://david-dm.org/trainerbill/paypal-hapi#info=devDependencies)
# hapi-paypal

@@ -2,0 +5,0 @@ Hapi Plugin for PayPal REST API's

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc