mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 22:54:05 -08:00
🚧 Resource descriptions
This commit is contained in:
parent
13f71d3af0
commit
b46a29b1a7
23
packages/nodes-base/credentials/PaddleApi.credentials.ts
Normal file
23
packages/nodes-base/credentials/PaddleApi.credentials.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import {
|
||||
ICredentialType,
|
||||
NodePropertyTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class PaddleApi implements ICredentialType {
|
||||
name = 'paddleApi';
|
||||
displayName = 'Paddle API';
|
||||
properties = [
|
||||
{
|
||||
displayName: 'Vendor Auth Code',
|
||||
name: 'vendorAuthCode',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Vendor ID',
|
||||
name: 'vendorId',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
}
|
447
packages/nodes-base/nodes/Paddle/CouponDescription.ts
Normal file
447
packages/nodes-base/nodes/Paddle/CouponDescription.ts
Normal file
|
@ -0,0 +1,447 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const couponOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a coupon.',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all coupons.',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a coupon.',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const couponFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* coupon:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Coupon Type',
|
||||
name: 'couponType',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
`create`
|
||||
]
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Either product (valid for specified products or subscription plans) or checkout (valid for any checkout).',
|
||||
options: [
|
||||
{
|
||||
name: 'Checkout',
|
||||
value: 'checkout'
|
||||
},
|
||||
{
|
||||
name: 'Product',
|
||||
value: 'product'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Product ID(s)',
|
||||
name: 'productIds',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
`create`
|
||||
],
|
||||
couponType: [
|
||||
'product',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Comma-separated list of product IDs. Required if coupon_type is product.',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Discount Type',
|
||||
name: 'discountType',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
`create`
|
||||
],
|
||||
},
|
||||
},
|
||||
default: 'flat',
|
||||
description: 'Either flat or percentage.',
|
||||
options: [
|
||||
{
|
||||
name: 'Flat',
|
||||
value: 'flat'
|
||||
},
|
||||
{
|
||||
name: 'Percentage',
|
||||
value: 'percentage'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Discount Amount Currency',
|
||||
name: 'discountAmount',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Discount amount in currency.',
|
||||
typeOptions: {
|
||||
minValue: 0
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
`create`
|
||||
],
|
||||
discountType: [
|
||||
'flat',
|
||||
]
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Discount Amount %',
|
||||
name: 'discountAmount',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Discount amount in percentage.',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
maxValue: 100
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
`create`
|
||||
],
|
||||
discountType: [
|
||||
'percentage',
|
||||
]
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'options',
|
||||
default: 'eur',
|
||||
description: 'The currency must match the balance currency specified in your account.',
|
||||
options: [
|
||||
{
|
||||
name: 'EUR',
|
||||
value: 'eur'
|
||||
},
|
||||
{
|
||||
name: 'GBP',
|
||||
value: 'gbp'
|
||||
},
|
||||
{
|
||||
name: 'USD',
|
||||
value: 'usd'
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
`create`
|
||||
],
|
||||
discountType: [
|
||||
'flat',
|
||||
]
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Allowed Uses',
|
||||
name: 'allowedUses',
|
||||
type: 'number',
|
||||
default: 1,
|
||||
description: 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.',
|
||||
},
|
||||
{
|
||||
displayName: 'Coupon Code',
|
||||
name: 'couponCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Will be randomly generated if not specified.',
|
||||
},
|
||||
{
|
||||
displayName: 'Coupon Prefix',
|
||||
name: 'couponPrefix',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Prefix for generated codes. Not valid if coupon_code is specified.',
|
||||
},
|
||||
{
|
||||
displayName: 'Expires',
|
||||
name: 'expires',
|
||||
type: 'DateTime',
|
||||
default: '',
|
||||
description: 'The coupon will expire on the date at 00:00:00 UTC.',
|
||||
},
|
||||
{
|
||||
displayName: 'Group',
|
||||
name: 'group',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 50
|
||||
},
|
||||
default: '',
|
||||
description: 'The name of the coupon group this coupon should be assigned to.',
|
||||
},
|
||||
{
|
||||
displayName: 'Recurring',
|
||||
name: 'recurring',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase.',
|
||||
},
|
||||
{
|
||||
displayName: 'Number of Coupons',
|
||||
name: 'numberOfCoupons',
|
||||
type: 'number',
|
||||
default: 1,
|
||||
description: 'Number of coupons to generate. Not valid if coupon_code is specified.',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Description of the coupon. This will be displayed in the Seller Dashboard.',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* coupon:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Update by',
|
||||
name: 'updateBy',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
`update`
|
||||
],
|
||||
},
|
||||
},
|
||||
default: 'couponCode',
|
||||
description: 'Either flat or percentage.',
|
||||
options: [
|
||||
{
|
||||
name: 'Coupon Code',
|
||||
value: 'couponCode'
|
||||
},
|
||||
{
|
||||
name: 'Group',
|
||||
value: 'group'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Coupon Code',
|
||||
name: 'couponCode',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
'update'
|
||||
],
|
||||
updateBy: [
|
||||
'couponCode'
|
||||
]
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Identify the coupon to update',
|
||||
},
|
||||
{
|
||||
displayName: 'Group',
|
||||
name: 'group',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
'update'
|
||||
],
|
||||
updateBy: [
|
||||
'group'
|
||||
]
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The name of the group of coupons you want to update.',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coupon',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Allowed Uses',
|
||||
name: 'allowedUses',
|
||||
type: 'number',
|
||||
default: 1,
|
||||
description: 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.',
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'options',
|
||||
default: 'eur',
|
||||
description: 'The currency must match the balance currency specified in your account.',
|
||||
options: [
|
||||
{
|
||||
name: 'EUR',
|
||||
value: 'eur'
|
||||
},
|
||||
{
|
||||
name: 'GBP',
|
||||
value: 'gbp'
|
||||
},
|
||||
{
|
||||
name: 'USD',
|
||||
value: 'usd'
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
displayName: 'Discount Amount',
|
||||
name: 'discountAmount',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Discount amount.',
|
||||
typeOptions: {
|
||||
minValue: 0
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Expires',
|
||||
name: 'expires',
|
||||
type: 'DateTime',
|
||||
default: '',
|
||||
description: 'The coupon will expire on the date at 00:00:00 UTC.',
|
||||
},
|
||||
{
|
||||
displayName: 'New Coupon Code',
|
||||
name: 'newCouponCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'New code to rename the coupon to.',
|
||||
},
|
||||
{
|
||||
displayName: 'New Group Name',
|
||||
name: 'newGroup',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 50
|
||||
},
|
||||
default: '',
|
||||
description: 'New group name to move coupon to.',
|
||||
},
|
||||
{
|
||||
displayName: 'Product ID(s)',
|
||||
name: 'productIds',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated list of product IDs. Required if coupon_type is product.',
|
||||
},
|
||||
{
|
||||
displayName: 'Recurring',
|
||||
name: 'recurring',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
] as INodeProperties[];
|
41
packages/nodes-base/nodes/Paddle/GenericFunctions.ts
Normal file
41
packages/nodes-base/nodes/Paddle/GenericFunctions.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
IWebhookFunctions,
|
||||
BINARY_ENCODING
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function paddleApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('paddleApi');
|
||||
|
||||
const options = {
|
||||
method,
|
||||
qs: query || {},
|
||||
uri: uri || `${env}/v1${endpoint}`,
|
||||
body,
|
||||
json: true
|
||||
};
|
||||
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
|
||||
if (error.response.body) {
|
||||
let errorMessage = error.response.body.message;
|
||||
if (error.response.body.details) {
|
||||
errorMessage += ` - Details: ${JSON.stringify(error.response.body.details)}`;
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
52
packages/nodes-base/nodes/Paddle/OrderDescription.ts
Normal file
52
packages/nodes-base/nodes/Paddle/OrderDescription.ts
Normal file
|
@ -0,0 +1,52 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const orderOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'order',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get an order',
|
||||
}
|
||||
],
|
||||
default: 'get',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const orderFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* order:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Checkout ID',
|
||||
name: 'checkoutId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'order',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The identifier of the buyer’s checkout.',
|
||||
},
|
||||
] as INodeProperties[];
|
92
packages/nodes-base/nodes/Paddle/Paddle.node.ts
Normal file
92
packages/nodes-base/nodes/Paddle/Paddle.node.ts
Normal file
|
@ -0,0 +1,92 @@
|
|||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class Paddle implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Paddle',
|
||||
name: 'paddle',
|
||||
icon: 'file:paddle.png',
|
||||
group: ['output'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Paddle API',
|
||||
defaults: {
|
||||
name: 'Paddle',
|
||||
color: '#45567c',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'paddleApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Coupon',
|
||||
value: 'coupon',
|
||||
|
||||
},
|
||||
{
|
||||
name: 'Payments',
|
||||
value: 'payments',
|
||||
},
|
||||
{
|
||||
name: 'Plan',
|
||||
value: 'plan',
|
||||
},
|
||||
{
|
||||
name: 'Product',
|
||||
value: 'product',
|
||||
},
|
||||
{
|
||||
name: 'Order',
|
||||
value: 'order',
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
value: 'user',
|
||||
},
|
||||
],
|
||||
default: 'coupon',
|
||||
description: 'Resource to consume.',
|
||||
},
|
||||
|
||||
],
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let responseData;
|
||||
const qs: IDataObject = {};
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
returnData.push(responseData as unknown as IDataObject);
|
||||
}
|
||||
}
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
164
packages/nodes-base/nodes/Paddle/PaddleTrigger.node.ts
Normal file
164
packages/nodes-base/nodes/Paddle/PaddleTrigger.node.ts
Normal file
|
@ -0,0 +1,164 @@
|
|||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeTypeDescription,
|
||||
INodeType,
|
||||
IWebhookResponseData,
|
||||
ILoadOptionsFunctions,
|
||||
INodePropertyOptions,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class PaddleTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Paddle Trigger',
|
||||
name: 'paddleTrigger',
|
||||
icon: 'file:paddle.png',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
description: 'Handle Paddle events via webhooks',
|
||||
defaults: {
|
||||
name: 'Paddle Trigger',
|
||||
color: '#32325d',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'paddleApi',
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
reponseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Events',
|
||||
name: 'events',
|
||||
type: 'multiOptions',
|
||||
required: true,
|
||||
default: [],
|
||||
description: 'The event to listen to.',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getEvents'
|
||||
},
|
||||
options: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (webhookData.webhookId === undefined) {
|
||||
// No webhook id is set so no webhook can exist
|
||||
return false;
|
||||
}
|
||||
const endpoint = `/notifications/webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await payPalApiRequest.call(this, endpoint, 'GET');
|
||||
} catch (err) {
|
||||
if (err.response && err.response.name === 'INVALID_RESOURCE_ID') {
|
||||
// Webhook does not exist
|
||||
delete webhookData.webhookId;
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Paddle Error: ${err}`);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
let webhook;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const events = this.getNodeParameter('events', []) as string[];
|
||||
const body = {
|
||||
url: webhookUrl,
|
||||
event_types: events.map(event => {
|
||||
return { name: event };
|
||||
}),
|
||||
};
|
||||
const endpoint = '/notifications/webhooks';
|
||||
try {
|
||||
webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (webhook.id === undefined) {
|
||||
return false;
|
||||
}
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
webhookData.webhookId = webhook.id as string;
|
||||
return true;
|
||||
},
|
||||
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (webhookData.webhookId !== undefined) {
|
||||
const endpoint = `/notifications/webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await payPalApiRequest.call(this, endpoint, 'DELETE', {});
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
delete webhookData.webhookId;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
let webhook;
|
||||
const webhookData = this.getWorkflowStaticData('node') as IDataObject;
|
||||
const bodyData = this.getBodyData() as IDataObject;
|
||||
const req = this.getRequestObject();
|
||||
const headerData = this.getHeaderData() as IDataObject;
|
||||
const endpoint = '/notifications/verify-webhook-signature';
|
||||
|
||||
if (headerData['PAYPAL-AUTH-ALGO'] !== undefined
|
||||
&& headerData['PAYPAL-CERT-URL'] !== undefined
|
||||
&& headerData['PAYPAL-TRANSMISSION-ID'] !== undefined
|
||||
&& headerData['PAYPAL-TRANSMISSION-SIG'] !== undefined
|
||||
&& headerData['PAYPAL-TRANSMISSION-TIME'] !== undefined) {
|
||||
const body = {
|
||||
auth_algo: headerData['PAYPAL-AUTH-ALGO'],
|
||||
cert_url: headerData['PAYPAL-CERT-URL'],
|
||||
transmission_id: headerData['PAYPAL-TRANSMISSION-ID'],
|
||||
transmission_sig: headerData['PAYPAL-TRANSMISSION-SIG'],
|
||||
transmission_time: headerData['PAYPAL-TRANSMISSION-TIME'],
|
||||
webhook_id: webhookData.webhookId,
|
||||
webhook_event: bodyData,
|
||||
};
|
||||
try {
|
||||
webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
if (webhook.verification_status !== 'SUCCESS') {
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(req.body)
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
197
packages/nodes-base/nodes/Paddle/PaymentDescription.ts
Normal file
197
packages/nodes-base/nodes/Paddle/PaymentDescription.ts
Normal file
|
@ -0,0 +1,197 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const paymentOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'payment',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all payments.',
|
||||
},
|
||||
{
|
||||
name: 'Reschedule',
|
||||
value: 'reschedule',
|
||||
description: 'Reschedule payment.',
|
||||
}
|
||||
],
|
||||
default: 'getAll',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const paymentFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* payment:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Subscription ID',
|
||||
name: 'subscriptionId',
|
||||
type: 'number',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'A specific user subscription ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Plan',
|
||||
name: 'planId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Filter: The product/plan ID (single or comma-separated values).',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 1,
|
||||
required: true,
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 200
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Number of subscription records to return per page.',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'State',
|
||||
name: 'state',
|
||||
type: 'options',
|
||||
default: 'active',
|
||||
description: 'Filter: The user subscription status. Returns all active, past_due, trialing and paused subscription plans if not specified.',
|
||||
options: [
|
||||
{
|
||||
name: 'Active',
|
||||
value: 'active'
|
||||
},
|
||||
{
|
||||
name: 'Past Due',
|
||||
value: 'past_due'
|
||||
},
|
||||
{
|
||||
name: 'Paused',
|
||||
value: 'paused'
|
||||
},
|
||||
{
|
||||
name: 'Trialing',
|
||||
value: 'trialing'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Is Paid',
|
||||
name: 'isPaid',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Payment is paid.',
|
||||
},
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
type: 'DateTime',
|
||||
default: '',
|
||||
description: 'Payments starting from date.',
|
||||
},
|
||||
{
|
||||
displayName: 'To',
|
||||
name: 'to',
|
||||
type: 'DateTime',
|
||||
default: '',
|
||||
description: 'Payments up until date.',
|
||||
},
|
||||
{
|
||||
displayName: 'One off charge',
|
||||
name: 'isOneOffCharge',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Payment is paid.',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* payment:reschedule */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Payment ID',
|
||||
name: 'paymentId',
|
||||
type: 'number',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The upcoming subscription payment ID.', // Use loadoptions to select payment
|
||||
},
|
||||
{
|
||||
displayName: 'Date',
|
||||
name: 'date',
|
||||
type: 'DateTime',
|
||||
default: '',
|
||||
description: 'Date you want to move the payment to.',
|
||||
},
|
||||
] as INodeProperties[];
|
52
packages/nodes-base/nodes/Paddle/PlanDescription.ts
Normal file
52
packages/nodes-base/nodes/Paddle/PlanDescription.ts
Normal file
|
@ -0,0 +1,52 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const planOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'plan',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all plans.',
|
||||
}
|
||||
],
|
||||
default: 'getAll',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const planFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* plan:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Plan ID',
|
||||
name: 'planId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'plan',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Filter: The subscription plan ID.',
|
||||
},
|
||||
] as INodeProperties[];
|
31
packages/nodes-base/nodes/Paddle/ProductDescription.ts
Normal file
31
packages/nodes-base/nodes/Paddle/ProductDescription.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const productOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'product',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all products.',
|
||||
}
|
||||
],
|
||||
default: 'getAll',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const productFields = [
|
||||
|
||||
] as INodeProperties[];
|
136
packages/nodes-base/nodes/Paddle/UserDescription.ts
Normal file
136
packages/nodes-base/nodes/Paddle/UserDescription.ts
Normal file
|
@ -0,0 +1,136 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const userOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all users',
|
||||
}
|
||||
],
|
||||
default: 'getAll',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const userFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Subscription ID',
|
||||
name: 'subscriptionId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'A specific user subscription ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Plan ID',
|
||||
name: 'planId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Filter: The subscription plan ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 1,
|
||||
required: true,
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 200
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Number of subscription records to return per page.',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'State',
|
||||
name: 'state',
|
||||
type: 'options',
|
||||
default: 'active',
|
||||
description: 'Filter: The user subscription status. Returns all active, past_due, trialing and paused subscription plans if not specified.',
|
||||
options: [
|
||||
{
|
||||
name: 'Active',
|
||||
value: 'active'
|
||||
},
|
||||
{
|
||||
name: 'Past Due',
|
||||
value: 'past_due'
|
||||
},
|
||||
{
|
||||
name: 'Paused',
|
||||
value: 'paused'
|
||||
},
|
||||
{
|
||||
name: 'Trialing',
|
||||
value: 'trialing'
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
BIN
packages/nodes-base/nodes/Paddle/paddle.png
Normal file
BIN
packages/nodes-base/nodes/Paddle/paddle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
|
@ -104,6 +104,7 @@
|
|||
"dist/credentials/OAuth1Api.credentials.js",
|
||||
"dist/credentials/OAuth2Api.credentials.js",
|
||||
"dist/credentials/OpenWeatherMapApi.credentials.js",
|
||||
"dist/credentials/PaddleApi.credentials.js",
|
||||
"dist/credentials/PagerDutyApi.credentials.js",
|
||||
"dist/credentials/PagerDutyOAuth2Api.credentials.js",
|
||||
"dist/credentials/PayPalApi.credentials.js",
|
||||
|
@ -246,6 +247,7 @@
|
|||
"dist/nodes/NextCloud/NextCloud.node.js",
|
||||
"dist/nodes/NoOp.node.js",
|
||||
"dist/nodes/OpenWeatherMap.node.js",
|
||||
"dist/nodes/Paddle/Paddle.node.js",
|
||||
"dist/nodes/PagerDuty/PagerDuty.node.js",
|
||||
"dist/nodes/PayPal/PayPal.node.js",
|
||||
"dist/nodes/PayPal/PayPalTrigger.node.js",
|
||||
|
|
Loading…
Reference in a new issue