n8n/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts

915 lines
30 KiB
TypeScript
Raw Normal View History

import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import {
IDataObject,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
NodeApiError,
NodeOperationError,
} from 'n8n-workflow';
import {
stripeApiRequest,
} from './helpers';
export class StripeTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'Stripe Trigger',
2020-05-12 06:08:19 -07:00
name: 'stripeTrigger',
icon: 'file:stripe.svg',
group: ['trigger'],
version: 1,
description: 'Handle Stripe events via webhooks',
defaults: {
name: 'Stripe Trigger',
},
inputs: [],
outputs: ['main'],
credentials: [
{
name: 'stripeApi',
required: true,
2020-10-22 06:46:03 -07:00
},
],
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',
options: [
{
name: '*',
value: '*',
description: 'Any time any event is triggered (Wildcard Event)',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Account Updated',
'value': 'account.updated',
'description': 'Occurs whenever an account status or property has changed.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Account Application.authorized',
'value': 'account.application.authorized',
'description': 'Occurs whenever a user authorizes an application. Sent to the related application only.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Account Application.deauthorized',
'value': 'account.application.deauthorized',
'description': 'Occurs whenever a user deauthorizes an application. Sent to the related application only.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Account External_account.created',
'value': 'account.external_account.created',
'description': 'Occurs whenever an external account is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Account External_account.deleted',
'value': 'account.external_account.deleted',
'description': 'Occurs whenever an external account is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Account External_account.updated',
'value': 'account.external_account.updated',
'description': 'Occurs whenever an external account is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Application Fee.created',
'value': 'application_fee.created',
'description': 'Occurs whenever an application fee is created on a charge.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Application Fee.refunded',
'value': 'application_fee.refunded',
'description': 'Occurs whenever an application fee is refunded, whether from refunding a charge or from refunding the application fee directly. This includes partial refunds.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Application Fee.refund.updated',
'value': 'application_fee.refund.updated',
'description': 'Occurs whenever an application fee refund is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Balance Available',
'value': 'balance.available',
'description': 'Occurs whenever your Stripe balance has been updated (e.g., when a charge is available to be paid out). By default, Stripe automatically transfers funds in your balance to your bank account on a daily basis.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Capability Updated',
'value': 'capability.updated',
'description': 'Occurs whenever a capability has new requirements or a new status.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Captured',
'value': 'charge.captured',
'description': 'Occurs whenever a previously uncaptured charge is captured.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Expired',
'value': 'charge.expired',
'description': 'Occurs whenever an uncaptured charge expires.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Failed',
'value': 'charge.failed',
'description': 'Occurs whenever a failed charge attempt occurs.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Pending',
'value': 'charge.pending',
'description': 'Occurs whenever a pending charge is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Refunded',
'value': 'charge.refunded',
'description': 'Occurs whenever a charge is refunded, including partial refunds.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Succeeded',
'value': 'charge.succeeded',
'description': 'Occurs whenever a new charge is created and is successful.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Updated',
'value': 'charge.updated',
'description': 'Occurs whenever a charge description or metadata is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Dispute.closed',
'value': 'charge.dispute.closed',
'description': 'Occurs when a dispute is closed and the dispute status changes to lost, warning_closed, or won.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Dispute.created',
'value': 'charge.dispute.created',
'description': 'Occurs whenever a customer disputes a charge with their bank.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Dispute.funds_reinstated',
'value': 'charge.dispute.funds_reinstated',
'description': 'Occurs when funds are reinstated to your account after a dispute is closed. This includes partially refunded payments.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Dispute.funds_withdrawn',
'value': 'charge.dispute.funds_withdrawn',
'description': 'Occurs when funds are removed from your account due to a dispute.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Dispute.updated',
'value': 'charge.dispute.updated',
'description': 'Occurs when the dispute is updated (usually with evidence).',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Charge Refund.updated',
'value': 'charge.refund.updated',
'description': 'Occurs whenever a refund is updated, on selected payment methods.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Checkout Session.completed',
'value': 'checkout.session.completed',
'description': 'Occurs when a Checkout Session has been successfully completed.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Coupon Created',
'value': 'coupon.created',
'description': 'Occurs whenever a coupon is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Coupon Deleted',
'value': 'coupon.deleted',
'description': 'Occurs whenever a coupon is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Coupon Updated',
'value': 'coupon.updated',
'description': 'Occurs whenever a coupon is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Credit Note.created',
'value': 'credit_note.created',
'description': 'Occurs whenever a credit note is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Credit Note.updated',
'value': 'credit_note.updated',
'description': 'Occurs whenever a credit note is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Credit Note.voided',
'value': 'credit_note.voided',
'description': 'Occurs whenever a credit note is voided.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Created',
'value': 'customer.created',
'description': 'Occurs whenever a new customer is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Deleted',
'value': 'customer.deleted',
'description': 'Occurs whenever a customer is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Updated',
'value': 'customer.updated',
'description': 'Occurs whenever any property of a customer changes.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Discount.created',
'value': 'customer.discount.created',
'description': 'Occurs whenever a coupon is attached to a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Discount.deleted',
'value': 'customer.discount.deleted',
'description': 'Occurs whenever a coupon is removed from a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Discount.updated',
'value': 'customer.discount.updated',
'description': 'Occurs whenever a customer is switched from one coupon to another.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Source.created',
'value': 'customer.source.created',
'description': 'Occurs whenever a new source is created for a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Source.deleted',
'value': 'customer.source.deleted',
'description': 'Occurs whenever a source is removed from a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Source.expiring',
'value': 'customer.source.expiring',
'description': 'Occurs whenever a card or source will expire at the end of the month.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Source.updated',
'value': 'customer.source.updated',
'description': 'Occurs whenever a source\'s details are changed.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Subscription.created',
'value': 'customer.subscription.created',
'description': 'Occurs whenever a customer is signed up for a new plan.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Subscription.deleted',
'value': 'customer.subscription.deleted',
'description': 'Occurs whenever a customer\'s subscription ends.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Subscription.trial_will_end',
'value': 'customer.subscription.trial_will_end',
'description': 'Occurs three days before a subscription\'s trial period is scheduled to end, or when a trial is ended immediately (using trial_end=now).',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Subscription.updated',
'value': 'customer.subscription.updated',
'description': 'Occurs whenever a subscription changes (e.g., switching from one plan to another, or changing the status from trial to active).',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Tax_id.created',
'value': 'customer.tax_id.created',
'description': 'Occurs whenever a tax ID is created for a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Tax_id.deleted',
'value': 'customer.tax_id.deleted',
'description': 'Occurs whenever a tax ID is deleted from a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Customer Tax_id.updated',
'value': 'customer.tax_id.updated',
'description': 'Occurs whenever a customer\'s tax ID is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'File Created',
'value': 'file.created',
'description': 'Occurs whenever a new Stripe-generated file is available for your account.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Created',
'value': 'invoice.created',
'description': 'Occurs whenever a new invoice is created. To learn how webhooks can be used with this event, and how they can affect it, see Using Webhooks with Subscriptions.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Deleted',
'value': 'invoice.deleted',
'description': 'Occurs whenever a draft invoice is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Finalized',
'value': 'invoice.finalized',
'description': 'Occurs whenever a draft invoice is finalized and updated to be an open invoice.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Marked_uncollectible',
'value': 'invoice.marked_uncollectible',
'description': 'Occurs whenever an invoice is marked uncollectible.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Payment_action_required',
'value': 'invoice.payment_action_required',
'description': 'Occurs whenever an invoice payment attempt requires further user action to complete.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Payment_failed',
'value': 'invoice.payment_failed',
'description': 'Occurs whenever an invoice payment attempt fails, due either to a declined payment or to the lack of a stored payment method.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Payment_succeeded',
'value': 'invoice.payment_succeeded',
'description': 'Occurs whenever an invoice payment attempt succeeds.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Sent',
'value': 'invoice.sent',
'description': 'Occurs whenever an invoice email is sent out.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Upcoming',
'value': 'invoice.upcoming',
'description': 'Occurs X number of days before a subscription is scheduled to create an invoice that is automatically charged—where X is determined by your subscriptions settings. Note: The received Invoice object will not have an invoice ID.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Updated',
'value': 'invoice.updated',
'description': 'Occurs whenever an invoice changes (e.g., the invoice amount).',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoice Voided',
'value': 'invoice.voided',
'description': 'Occurs whenever an invoice is voided.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoiceitem Created',
'value': 'invoiceitem.created',
'description': 'Occurs whenever an invoice item is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoiceitem Deleted',
'value': 'invoiceitem.deleted',
'description': 'Occurs whenever an invoice item is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Invoiceitem Updated',
'value': 'invoiceitem.updated',
'description': 'Occurs whenever an invoice item is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Authorization.created',
'value': 'issuing_authorization.created',
'description': 'Occurs whenever an authorization is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Authorization.request',
'value': 'issuing_authorization.request',
'description': 'Represents a synchronous request for authorization, see Using your integration to handle authorization requests.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Authorization.updated',
'value': 'issuing_authorization.updated',
'description': 'Occurs whenever an authorization is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Card.created',
'value': 'issuing_card.created',
'description': 'Occurs whenever a card is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Card.updated',
'value': 'issuing_card.updated',
'description': 'Occurs whenever a card is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Cardholder.created',
'value': 'issuing_cardholder.created',
'description': 'Occurs whenever a cardholder is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Cardholder.updated',
'value': 'issuing_cardholder.updated',
'description': 'Occurs whenever a cardholder is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Dispute.created',
'value': 'issuing_dispute.created',
'description': 'Occurs whenever a dispute is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Dispute.updated',
'value': 'issuing_dispute.updated',
'description': 'Occurs whenever a dispute is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Settlement.created',
'value': 'issuing_settlement.created',
'description': 'Occurs whenever an issuing settlement is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Settlement.updated',
'value': 'issuing_settlement.updated',
'description': 'Occurs whenever an issuing settlement is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Transaction.created',
'value': 'issuing_transaction.created',
'description': 'Occurs whenever an issuing transaction is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Issuing Transaction.updated',
'value': 'issuing_transaction.updated',
'description': 'Occurs whenever an issuing transaction is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Order Created',
'value': 'order.created',
'description': 'Occurs whenever an order is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Order Payment_failed',
'value': 'order.payment_failed',
'description': 'Occurs whenever an order payment attempt fails.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Order Payment_succeeded',
'value': 'order.payment_succeeded',
'description': 'Occurs whenever an order payment attempt succeeds.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Order Updated',
'value': 'order.updated',
'description': 'Occurs whenever an order is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Order Return.created',
'value': 'order_return.created',
'description': 'Occurs whenever an order return is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Intent.amount_capturable_updated',
'value': 'payment_intent.amount_capturable_updated',
'description': 'Occurs when a PaymentIntent has funds to be captured. Check the amount_capturable property on the PaymentIntent to determine the amount that can be captured. You may capture the PaymentIntent with an amount_to_capture value up to the specified amount. Learn more about capturing PaymentIntents.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Intent.canceled',
'value': 'payment_intent.canceled',
'description': 'Occurs when a PaymentIntent is canceled.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Intent.created',
'value': 'payment_intent.created',
'description': 'Occurs when a new PaymentIntent is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Intent.payment_failed',
'value': 'payment_intent.payment_failed',
'description': 'Occurs when a PaymentIntent has failed the attempt to create a source or a payment.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Intent.succeeded',
'value': 'payment_intent.succeeded',
'description': 'Occurs when a PaymentIntent has been successfully fulfilled.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Method.attached',
'value': 'payment_method.attached',
'description': 'Occurs whenever a new payment method is attached to a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Method.card_automatically_updated',
'value': 'payment_method.card_automatically_updated',
'description': 'Occurs whenever a card payment method\'s details are automatically updated by the network.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Method.detached',
'value': 'payment_method.detached',
'description': 'Occurs whenever a payment method is detached from a customer.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payment Method.updated',
'value': 'payment_method.updated',
'description': 'Occurs whenever a payment method is updated via the PaymentMethod update API.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payout Canceled',
'value': 'payout.canceled',
'description': 'Occurs whenever a payout is canceled.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payout Created',
'value': 'payout.created',
'description': 'Occurs whenever a payout is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payout Failed',
'value': 'payout.failed',
'description': 'Occurs whenever a payout attempt fails.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payout Paid',
'value': 'payout.paid',
'description': 'Occurs whenever a payout is expected to be available in the destination account. If the payout fails, a payout.failed notification is also sent, at a later time.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Payout Updated',
'value': 'payout.updated',
'description': 'Occurs whenever a payout is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Person Created',
'value': 'person.created',
'description': 'Occurs whenever a person associated with an account is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Person Deleted',
'value': 'person.deleted',
'description': 'Occurs whenever a person associated with an account is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Person Updated',
'value': 'person.updated',
'description': 'Occurs whenever a person associated with an account is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Plan Created',
'value': 'plan.created',
'description': 'Occurs whenever a plan is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Plan Deleted',
'value': 'plan.deleted',
'description': 'Occurs whenever a plan is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Plan Updated',
'value': 'plan.updated',
'description': 'Occurs whenever a plan is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Product Created',
'value': 'product.created',
'description': 'Occurs whenever a product is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Product Deleted',
'value': 'product.deleted',
'description': 'Occurs whenever a product is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Product Updated',
'value': 'product.updated',
'description': 'Occurs whenever a product is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Radar Early_fraud_warning.created',
'value': 'radar.early_fraud_warning.created',
'description': 'Occurs whenever an early fraud warning is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Radar Early_fraud_warning.updated',
'value': 'radar.early_fraud_warning.updated',
'description': 'Occurs whenever an early fraud warning is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Recipient Created',
'value': 'recipient.created',
'description': 'Occurs whenever a recipient is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Recipient Deleted',
'value': 'recipient.deleted',
'description': 'Occurs whenever a recipient is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Recipient Updated',
'value': 'recipient.updated',
'description': 'Occurs whenever a recipient is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Reporting Report_run.failed',
'value': 'reporting.report_run.failed',
'description': 'Occurs whenever a requested **ReportRun** failed to complete.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Reporting Report_run.succeeded',
'value': 'reporting.report_run.succeeded',
'description': 'Occurs whenever a requested **ReportRun** completed succesfully.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Reporting Report_type.updated',
'value': 'reporting.report_type.updated',
'description': 'Occurs whenever a **ReportType** is updated (typically to indicate that a new day\'s data has come available).',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Review Closed',
'value': 'review.closed',
'description': 'Occurs whenever a review is closed. The review\'s reason field indicates why: approved, disputed, refunded, or refunded_as_fraud.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Review Opened',
'value': 'review.opened',
'description': 'Occurs whenever a review is opened.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Setup Intent.canceled',
'value': 'setup_intent.canceled',
'description': 'Occurs when a SetupIntent is canceled.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Setup Intent.created',
'value': 'setup_intent.created',
'description': 'Occurs when a new SetupIntent is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Setup Intent.setup_failed',
'value': 'setup_intent.setup_failed',
'description': 'Occurs when a SetupIntent has failed the attempt to setup a payment method.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Setup Intent.succeeded',
'value': 'setup_intent.succeeded',
'description': 'Occurs when an SetupIntent has successfully setup a payment method.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Sigma Scheduled_query_run.created',
'value': 'sigma.scheduled_query_run.created',
'description': 'Occurs whenever a Sigma scheduled query run finishes.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Sku Created',
'value': 'sku.created',
'description': 'Occurs whenever a SKU is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Sku Deleted',
'value': 'sku.deleted',
'description': 'Occurs whenever a SKU is deleted.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Sku Updated',
'value': 'sku.updated',
'description': 'Occurs whenever a SKU is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Source Canceled',
'value': 'source.canceled',
'description': 'Occurs whenever a source is canceled.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Source Chargeable',
'value': 'source.chargeable',
'description': 'Occurs whenever a source transitions to chargeable.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Source Failed',
'value': 'source.failed',
'description': 'Occurs whenever a source fails.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Source Mandate_notification',
'value': 'source.mandate_notification',
'description': 'Occurs whenever a source mandate notification method is set to manual.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Source Refund_attributes_required',
'value': 'source.refund_attributes_required',
'description': 'Occurs whenever the refund attributes are required on a receiver source to process a refund or a mispayment.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Source Transaction.created',
'value': 'source.transaction.created',
'description': 'Occurs whenever a source transaction is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Source Transaction.updated',
'value': 'source.transaction.updated',
'description': 'Occurs whenever a source transaction is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Subscription Schedule.aborted',
'value': 'subscription_schedule.aborted',
'description': 'Occurs whenever a subscription schedule is canceled due to the underlying subscription being canceled because of delinquency.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Subscription Schedule.canceled',
'value': 'subscription_schedule.canceled',
'description': 'Occurs whenever a subscription schedule is canceled.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Subscription Schedule.completed',
'value': 'subscription_schedule.completed',
'description': 'Occurs whenever a new subscription schedule is completed.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Subscription Schedule.created',
'value': 'subscription_schedule.created',
'description': 'Occurs whenever a new subscription schedule is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Subscription Schedule.expiring',
'value': 'subscription_schedule.expiring',
'description': 'Occurs 7 days before a subscription schedule will expire.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Subscription Schedule.released',
'value': 'subscription_schedule.released',
'description': 'Occurs whenever a new subscription schedule is released.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Subscription Schedule.updated',
'value': 'subscription_schedule.updated',
'description': 'Occurs whenever a subscription schedule is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Tax Rate.created',
'value': 'tax_rate.created',
'description': 'Occurs whenever a new tax rate is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Tax Rate.updated',
'value': 'tax_rate.updated',
'description': 'Occurs whenever a tax rate is updated.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Topup Canceled',
'value': 'topup.canceled',
'description': 'Occurs whenever a top-up is canceled.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Topup Created',
'value': 'topup.created',
'description': 'Occurs whenever a top-up is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Topup Failed',
'value': 'topup.failed',
'description': 'Occurs whenever a top-up fails.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Topup Reversed',
'value': 'topup.reversed',
'description': 'Occurs whenever a top-up is reversed.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Topup Succeeded',
'value': 'topup.succeeded',
'description': 'Occurs whenever a top-up succeeds.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Transfer Created',
'value': 'transfer.created',
'description': 'Occurs whenever a transfer is created.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Transfer Failed',
'value': 'transfer.failed',
'description': 'Occurs whenever a transfer failed.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Transfer Paid',
'value': 'transfer.paid',
'description': 'Occurs after a transfer is paid. For Instant Payouts, the event will be sent on the next business day, although the funds should be received well beforehand.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Transfer Reversed',
'value': 'transfer.reversed',
'description': 'Occurs whenever a transfer is reversed, including partial reversals.',
},
{
2021-01-13 11:20:30 -08:00
'name': 'Transfer Updated',
'value': 'transfer.updated',
'description': 'Occurs whenever a transfer\'s description or metadata is updated.',
2020-10-22 06:46:03 -07:00
},
],
},
],
};
// @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;
}
// Webhook got created before so check if it still exists
const endpoint = `/webhook_endpoints/${webhookData.webhookId}`;
try {
await stripeApiRequest.call(this, 'GET', endpoint, {});
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
} catch (error) {
if (error.httpCode === '404' || error.message.includes('resource_missing')) {
// Webhook does not exist
delete webhookData.webhookId;
delete webhookData.webhookEvents;
delete webhookData.webhookSecret;
return false;
}
// Some error occured
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw error;
}
// If it did not error then the webhook exists
return true;
},
async create(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const events = this.getNodeParameter('events', []);
const endpoint = '/webhook_endpoints';
const body = {
url: webhookUrl,
enabled_events: events,
};
let responseData;
try {
responseData = await stripeApiRequest.call(this, 'POST', endpoint, body);
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
} catch (error) {
throw error;
}
if (responseData.id === undefined || responseData.secret === undefined || responseData.status !== 'enabled') {
// Required data is missing so was not successful
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeApiError(this.getNode(), responseData, { message: 'Stripe webhook creation response did not contain the expected data.' });
}
const webhookData = this.getWorkflowStaticData('node');
webhookData.webhookId = responseData.id as string;
webhookData.webhookEvents = responseData.enabled_events as string[];
webhookData.webhookSecret = responseData.secret as string;
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
if (webhookData.webhookId !== undefined) {
const endpoint = `/webhook_endpoints/${webhookData.webhookId}`;
const body = {};
try {
await stripeApiRequest.call(this, 'DELETE', endpoint, body);
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
} catch (error) {
return false;
}
// Remove from the static workflow data so that it is clear
// that no webhooks are registred anymore
delete webhookData.webhookId;
delete webhookData.webhookEvents;
delete webhookData.webhookSecret;
}
return true;
},
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const bodyData = this.getBodyData() as IDataObject;
const req = this.getRequestObject();
const events = this.getNodeParameter('events', []) as string[];
const eventType = bodyData.type as string | undefined;
if (eventType === undefined || !events.includes('*') && !events.includes(eventType)) {
// If not eventType is defined or when one is defined but we are not
// listening to it do not start the workflow.
return {};
}
return {
workflowData: [
2020-10-22 06:46:03 -07:00
this.helpers.returnJsonArray(req.body),
],
};
}
}