2019-10-14 17:43:19 -07:00
import {
2020-05-11 15:06:51 -07:00
IHookFunctions ,
IWebhookFunctions ,
2019-10-14 17:43:19 -07:00
} from 'n8n-core' ;
import {
2020-05-11 15:06:51 -07:00
IDataObject ,
INodeType ,
2020-10-01 05:01:39 -07:00
INodeTypeDescription ,
2020-05-11 15:06:51 -07:00
IWebhookResponseData ,
2019-10-14 17:43:19 -07:00
} from 'n8n-workflow' ;
2019-10-15 05:46:42 -07:00
import {
2020-05-11 15:06:51 -07:00
stripeApiRequest ,
2019-10-15 05:46:42 -07:00
} from './helpers' ;
2019-10-14 17:43:19 -07:00
export class StripeTrigger implements INodeType {
2020-05-11 15:06:51 -07:00
description : INodeTypeDescription = {
displayName : 'Stripe Trigger' ,
2020-05-12 06:08:19 -07:00
name : 'stripeTrigger' ,
2020-05-11 15:06:51 -07:00
icon : 'file:stripe.png' ,
group : [ 'trigger' ] ,
version : 1 ,
description : 'Handle Stripe events via webhooks' ,
defaults : {
name : 'Stripe Trigger' ,
color : '#32325d' ,
} ,
inputs : [ ] ,
outputs : [ 'main' ] ,
credentials : [
2019-10-15 05:46:42 -07:00
{
name : 'stripeApi' ,
required : true ,
2020-10-22 06:46:03 -07:00
} ,
2019-10-15 05:46:42 -07:00
] ,
2020-05-11 15:06:51 -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).' ,
} ,
{
"name" : "Account Updated" ,
"value" : "account.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an account status or property has changed." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Account Application.authorized" ,
"value" : "account.application.authorized" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a user authorizes an application. Sent to the related application only." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Account Application.deauthorized" ,
"value" : "account.application.deauthorized" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a user deauthorizes an application. Sent to the related application only." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Account External_account.created" ,
"value" : "account.external_account.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an external account is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Account External_account.deleted" ,
"value" : "account.external_account.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an external account is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Account External_account.updated" ,
"value" : "account.external_account.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an external account is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Application Fee.created" ,
"value" : "application_fee.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an application fee is created on a charge." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Application Fee.refunded" ,
"value" : "application_fee.refunded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an application fee is refunded, whether from refunding a charge or from refunding the application fee directly. This includes partial refunds." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Application Fee.refund.updated" ,
"value" : "application_fee.refund.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an application fee refund is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Balance Available" ,
"value" : "balance.available" ,
2020-10-22 06:46:03 -07:00
"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." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Capability Updated" ,
"value" : "capability.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a capability has new requirements or a new status." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Captured" ,
"value" : "charge.captured" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a previously uncaptured charge is captured." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Expired" ,
"value" : "charge.expired" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an uncaptured charge expires." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Failed" ,
"value" : "charge.failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a failed charge attempt occurs." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Pending" ,
"value" : "charge.pending" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a pending charge is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Refunded" ,
"value" : "charge.refunded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a charge is refunded, including partial refunds." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Succeeded" ,
"value" : "charge.succeeded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new charge is created and is successful." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Updated" ,
"value" : "charge.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a charge description or metadata is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Dispute.closed" ,
"value" : "charge.dispute.closed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a dispute is closed and the dispute status changes to lost, warning_closed, or won." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Dispute.created" ,
"value" : "charge.dispute.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a customer disputes a charge with their bank." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Dispute.funds_reinstated" ,
"value" : "charge.dispute.funds_reinstated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when funds are reinstated to your account after a dispute is closed. This includes partially refunded payments." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Dispute.funds_withdrawn" ,
"value" : "charge.dispute.funds_withdrawn" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when funds are removed from your account due to a dispute." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Dispute.updated" ,
"value" : "charge.dispute.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when the dispute is updated (usually with evidence)." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Charge Refund.updated" ,
"value" : "charge.refund.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a refund is updated, on selected payment methods." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Checkout Session.completed" ,
"value" : "checkout.session.completed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a Checkout Session has been successfully completed." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Coupon Created" ,
"value" : "coupon.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a coupon is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Coupon Deleted" ,
"value" : "coupon.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a coupon is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Coupon Updated" ,
"value" : "coupon.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a coupon is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Credit Note.created" ,
"value" : "credit_note.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a credit note is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Credit Note.updated" ,
"value" : "credit_note.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a credit note is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Credit Note.voided" ,
"value" : "credit_note.voided" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a credit note is voided." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Created" ,
"value" : "customer.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new customer is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Deleted" ,
"value" : "customer.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a customer is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Updated" ,
"value" : "customer.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever any property of a customer changes." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Discount.created" ,
"value" : "customer.discount.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a coupon is attached to a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Discount.deleted" ,
"value" : "customer.discount.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a coupon is removed from a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Discount.updated" ,
"value" : "customer.discount.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a customer is switched from one coupon to another." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Source.created" ,
"value" : "customer.source.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new source is created for a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Source.deleted" ,
"value" : "customer.source.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source is removed from a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Source.expiring" ,
"value" : "customer.source.expiring" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a card or source will expire at the end of the month." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Source.updated" ,
"value" : "customer.source.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source's details are changed." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Subscription.created" ,
"value" : "customer.subscription.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a customer is signed up for a new plan." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Subscription.deleted" ,
"value" : "customer.subscription.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a customer's subscription ends." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Subscription.trial_will_end" ,
"value" : "customer.subscription.trial_will_end" ,
2020-10-22 06:46:03 -07:00
"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)." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Subscription.updated" ,
"value" : "customer.subscription.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a subscription changes (e.g., switching from one plan to another, or changing the status from trial to active)." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Tax_id.created" ,
"value" : "customer.tax_id.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a tax ID is created for a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Tax_id.deleted" ,
"value" : "customer.tax_id.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a tax ID is deleted from a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Customer Tax_id.updated" ,
"value" : "customer.tax_id.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a customer's tax ID is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "File Created" ,
"value" : "file.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new Stripe-generated file is available for your account." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Created" ,
"value" : "invoice.created" ,
2020-10-22 06:46:03 -07:00
"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." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Deleted" ,
"value" : "invoice.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a draft invoice is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Finalized" ,
"value" : "invoice.finalized" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a draft invoice is finalized and updated to be an open invoice." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Marked_uncollectible" ,
"value" : "invoice.marked_uncollectible" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice is marked uncollectible." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Payment_action_required" ,
"value" : "invoice.payment_action_required" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice payment attempt requires further user action to complete." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Payment_failed" ,
"value" : "invoice.payment_failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice payment attempt fails, due either to a declined payment or to the lack of a stored payment method." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Payment_succeeded" ,
"value" : "invoice.payment_succeeded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice payment attempt succeeds." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Sent" ,
"value" : "invoice.sent" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice email is sent out." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Upcoming" ,
"value" : "invoice.upcoming" ,
2020-10-22 06:46:03 -07:00
"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." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Updated" ,
"value" : "invoice.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice changes (e.g., the invoice amount)." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoice Voided" ,
"value" : "invoice.voided" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice is voided." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoiceitem Created" ,
"value" : "invoiceitem.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice item is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoiceitem Deleted" ,
"value" : "invoiceitem.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice item is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Invoiceitem Updated" ,
"value" : "invoiceitem.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an invoice item is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Authorization.created" ,
"value" : "issuing_authorization.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an authorization is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Authorization.request" ,
"value" : "issuing_authorization.request" ,
2020-10-22 06:46:03 -07:00
"description" : "Represents a synchronous request for authorization, see Using your integration to handle authorization requests." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Authorization.updated" ,
"value" : "issuing_authorization.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an authorization is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Card.created" ,
"value" : "issuing_card.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a card is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Card.updated" ,
"value" : "issuing_card.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a card is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Cardholder.created" ,
"value" : "issuing_cardholder.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a cardholder is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Cardholder.updated" ,
"value" : "issuing_cardholder.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a cardholder is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Dispute.created" ,
"value" : "issuing_dispute.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a dispute is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Dispute.updated" ,
"value" : "issuing_dispute.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a dispute is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Settlement.created" ,
"value" : "issuing_settlement.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an issuing settlement is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Settlement.updated" ,
"value" : "issuing_settlement.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an issuing settlement is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Transaction.created" ,
"value" : "issuing_transaction.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an issuing transaction is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Issuing Transaction.updated" ,
"value" : "issuing_transaction.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an issuing transaction is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Order Created" ,
"value" : "order.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an order is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Order Payment_failed" ,
"value" : "order.payment_failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an order payment attempt fails." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Order Payment_succeeded" ,
"value" : "order.payment_succeeded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an order payment attempt succeeds." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Order Updated" ,
"value" : "order.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an order is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Order Return.created" ,
"value" : "order_return.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an order return is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Intent.amount_capturable_updated" ,
"value" : "payment_intent.amount_capturable_updated" ,
2020-10-22 06:46:03 -07:00
"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." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Intent.canceled" ,
"value" : "payment_intent.canceled" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a PaymentIntent is canceled." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Intent.created" ,
"value" : "payment_intent.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a new PaymentIntent is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Intent.payment_failed" ,
"value" : "payment_intent.payment_failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a PaymentIntent has failed the attempt to create a source or a payment." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Intent.succeeded" ,
"value" : "payment_intent.succeeded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a PaymentIntent has been successfully fulfilled." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Method.attached" ,
"value" : "payment_method.attached" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new payment method is attached to a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Method.card_automatically_updated" ,
"value" : "payment_method.card_automatically_updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a card payment method's details are automatically updated by the network." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Method.detached" ,
"value" : "payment_method.detached" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a payment method is detached from a customer." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payment Method.updated" ,
"value" : "payment_method.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a payment method is updated via the PaymentMethod update API." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payout Canceled" ,
"value" : "payout.canceled" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a payout is canceled." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payout Created" ,
"value" : "payout.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a payout is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payout Failed" ,
"value" : "payout.failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a payout attempt fails." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payout Paid" ,
"value" : "payout.paid" ,
2020-10-22 06:46:03 -07:00
"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." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Payout Updated" ,
"value" : "payout.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a payout is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Person Created" ,
"value" : "person.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a person associated with an account is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Person Deleted" ,
"value" : "person.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a person associated with an account is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Person Updated" ,
"value" : "person.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a person associated with an account is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Plan Created" ,
"value" : "plan.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a plan is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Plan Deleted" ,
"value" : "plan.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a plan is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Plan Updated" ,
"value" : "plan.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a plan is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Product Created" ,
"value" : "product.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a product is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Product Deleted" ,
"value" : "product.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a product is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Product Updated" ,
"value" : "product.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a product is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Radar Early_fraud_warning.created" ,
"value" : "radar.early_fraud_warning.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an early fraud warning is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Radar Early_fraud_warning.updated" ,
"value" : "radar.early_fraud_warning.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever an early fraud warning is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Recipient Created" ,
"value" : "recipient.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a recipient is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Recipient Deleted" ,
"value" : "recipient.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a recipient is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Recipient Updated" ,
"value" : "recipient.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a recipient is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Reporting Report_run.failed" ,
"value" : "reporting.report_run.failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a requested **ReportRun** failed to complete." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Reporting Report_run.succeeded" ,
"value" : "reporting.report_run.succeeded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a requested **ReportRun** completed succesfully." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Reporting Report_type.updated" ,
"value" : "reporting.report_type.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a **ReportType** is updated (typically to indicate that a new day's data has come available)." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Review Closed" ,
"value" : "review.closed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a review is closed. The review's reason field indicates why: approved, disputed, refunded, or refunded_as_fraud." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Review Opened" ,
"value" : "review.opened" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a review is opened." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Setup Intent.canceled" ,
"value" : "setup_intent.canceled" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a SetupIntent is canceled." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Setup Intent.created" ,
"value" : "setup_intent.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a new SetupIntent is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Setup Intent.setup_failed" ,
"value" : "setup_intent.setup_failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when a SetupIntent has failed the attempt to setup a payment method." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Setup Intent.succeeded" ,
"value" : "setup_intent.succeeded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs when an SetupIntent has successfully setup a payment method." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Sigma Scheduled_query_run.created" ,
"value" : "sigma.scheduled_query_run.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a Sigma scheduled query run finishes." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Sku Created" ,
"value" : "sku.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a SKU is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Sku Deleted" ,
"value" : "sku.deleted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a SKU is deleted." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Sku Updated" ,
"value" : "sku.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a SKU is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Source Canceled" ,
"value" : "source.canceled" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source is canceled." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Source Chargeable" ,
"value" : "source.chargeable" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source transitions to chargeable." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Source Failed" ,
"value" : "source.failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source fails." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Source Mandate_notification" ,
"value" : "source.mandate_notification" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source mandate notification method is set to manual." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Source Refund_attributes_required" ,
"value" : "source.refund_attributes_required" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever the refund attributes are required on a receiver source to process a refund or a mispayment." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Source Transaction.created" ,
"value" : "source.transaction.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source transaction is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Source Transaction.updated" ,
"value" : "source.transaction.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a source transaction is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Subscription Schedule.aborted" ,
"value" : "subscription_schedule.aborted" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a subscription schedule is canceled due to the underlying subscription being canceled because of delinquency." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Subscription Schedule.canceled" ,
"value" : "subscription_schedule.canceled" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a subscription schedule is canceled." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Subscription Schedule.completed" ,
"value" : "subscription_schedule.completed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new subscription schedule is completed." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Subscription Schedule.created" ,
"value" : "subscription_schedule.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new subscription schedule is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Subscription Schedule.expiring" ,
"value" : "subscription_schedule.expiring" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs 7 days before a subscription schedule will expire." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Subscription Schedule.released" ,
"value" : "subscription_schedule.released" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new subscription schedule is released." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Subscription Schedule.updated" ,
"value" : "subscription_schedule.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a subscription schedule is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Tax Rate.created" ,
"value" : "tax_rate.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a new tax rate is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Tax Rate.updated" ,
"value" : "tax_rate.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a tax rate is updated." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Topup Canceled" ,
"value" : "topup.canceled" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a top-up is canceled." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Topup Created" ,
"value" : "topup.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a top-up is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Topup Failed" ,
"value" : "topup.failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a top-up fails." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Topup Reversed" ,
"value" : "topup.reversed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a top-up is reversed." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Topup Succeeded" ,
"value" : "topup.succeeded" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a top-up succeeds." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Transfer Created" ,
"value" : "transfer.created" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a transfer is created." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Transfer Failed" ,
"value" : "transfer.failed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a transfer failed." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Transfer Paid" ,
"value" : "transfer.paid" ,
2020-10-22 06:46:03 -07:00
"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." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Transfer Reversed" ,
"value" : "transfer.reversed" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a transfer is reversed, including partial reversals." ,
2020-05-11 15:06:51 -07:00
} ,
{
"name" : "Transfer Updated" ,
"value" : "transfer.updated" ,
2020-10-22 06:46:03 -07:00
"description" : "Occurs whenever a transfer's description or metadata is updated." ,
} ,
] ,
} ,
2020-05-11 15:06:51 -07:00
] ,
} ;
2019-10-14 17:43:19 -07:00
2020-05-11 15:06:51 -07:00
// @ts-ignore (because of request)
2019-10-15 05:46:42 -07:00
webhookMethods = {
default : {
async checkExists ( this : IHookFunctions ) : Promise < boolean > {
2020-05-11 15:06:51 -07:00
const webhookData = this . getWorkflowStaticData ( 'node' ) ;
2019-10-15 05:46:42 -07:00
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 , { } ) ;
} catch ( e ) {
2020-12-28 08:57:19 -08:00
if ( e . message . includes ( 'resource_missing' ) ) {
2019-10-15 05:46:42 -07:00
// Webhook does not exist
delete webhookData . webhookId ;
2020-05-11 15:06:51 -07:00
delete webhookData . webhookEvents ;
delete webhookData . webhookSecret ;
2019-10-15 05:46:42 -07:00
return false ;
}
// Some error occured
throw e ;
}
// If it did not error then the webhook exists
return true ;
} ,
async create ( this : IHookFunctions ) : Promise < boolean > {
const webhookUrl = this . getNodeWebhookUrl ( 'default' ) ;
2020-05-11 15:06:51 -07:00
const events = this . getNodeParameter ( 'events' , [ ] ) ;
2019-10-15 05:46:42 -07:00
const endpoint = '/webhook_endpoints' ;
const body = {
url : webhookUrl ,
enabled_events : events ,
} ;
let responseData ;
try {
responseData = await stripeApiRequest . call ( this , 'POST' , endpoint , body ) ;
} catch ( e ) {
throw e ;
}
if ( responseData . id === undefined || responseData . secret === undefined || responseData . status !== 'enabled' ) {
// Required data is missing so was not successful
throw new Error ( 'Stripe webhook creation response did not contain the expected data.' ) ;
}
const webhookData = this . getWorkflowStaticData ( 'node' ) ;
webhookData . webhookId = responseData . id as string ;
2020-05-11 15:06:51 -07:00
webhookData . webhookEvents = responseData . enabled_events as string [ ] ;
webhookData . webhookSecret = responseData . secret as string ;
2019-10-15 05:46:42 -07:00
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 ) ;
} catch ( e ) {
return false ;
}
// Remove from the static workflow data so that it is clear
// that no webhooks are registred anymore
delete webhookData . webhookId ;
2020-05-11 15:06:51 -07:00
delete webhookData . webhookEvents ;
delete webhookData . webhookSecret ;
2019-10-15 05:46:42 -07:00
}
return true ;
} ,
} ,
} ;
2020-05-11 15:06:51 -07:00
async webhook ( this : IWebhookFunctions ) : Promise < IWebhookResponseData > {
const bodyData = this . getBodyData ( ) as IDataObject ;
2019-10-14 17:43:19 -07:00
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 ) ,
2019-10-14 17:43:19 -07:00
] ,
} ;
2020-05-11 15:06:51 -07:00
}
2019-10-14 17:43:19 -07:00
}