Class: Stripe::WebhookEndpoint

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
Includes:
APIOperations::Delete, APIOperations::Save
Defined in:
lib/stripe/resources/webhook_endpoint.rb

Overview

You can configure [webhook endpoints](docs.stripe.com/webhooks/) via the API to be notified about events that happen in your Stripe account or connected accounts.

Most users configure webhooks from [the dashboard](dashboard.stripe.com/webhooks), which provides a user interface for registering and testing your webhook endpoints.

Related guide: [Setting up webhooks](docs.stripe.com/webhooks/configure)

Defined Under Namespace

Classes: CreateParams, DeleteParams, ListParams, UpdateParams

Constant Summary collapse

OBJECT_NAME =
"webhook_endpoint"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #save

Methods included from APIOperations::Delete

included

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#api_versionObject (readonly)

The API version events are rendered as for this webhook endpoint.



109
110
111
# File 'lib/stripe/resources/webhook_endpoint.rb', line 109

def api_version
  @api_version
end

#applicationObject (readonly)

The ID of the associated Connect application.



111
112
113
# File 'lib/stripe/resources/webhook_endpoint.rb', line 111

def application
  @application
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



113
114
115
# File 'lib/stripe/resources/webhook_endpoint.rb', line 113

def created
  @created
end

#deletedObject (readonly)

Always true for a deleted object



133
134
135
# File 'lib/stripe/resources/webhook_endpoint.rb', line 133

def deleted
  @deleted
end

#descriptionObject (readonly)

An optional description of what the webhook is used for.



115
116
117
# File 'lib/stripe/resources/webhook_endpoint.rb', line 115

def description
  @description
end

#enabled_eventsObject (readonly)

The list of events to enable for this endpoint. ‘[’*‘]` indicates that all events are enabled, except those that require explicit selection.



117
118
119
# File 'lib/stripe/resources/webhook_endpoint.rb', line 117

def enabled_events
  @enabled_events
end

#idObject (readonly)

Unique identifier for the object.



119
120
121
# File 'lib/stripe/resources/webhook_endpoint.rb', line 119

def id
  @id
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



121
122
123
# File 'lib/stripe/resources/webhook_endpoint.rb', line 121

def livemode
  @livemode
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



123
124
125
# File 'lib/stripe/resources/webhook_endpoint.rb', line 123

def 
  @metadata
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



125
126
127
# File 'lib/stripe/resources/webhook_endpoint.rb', line 125

def object
  @object
end

#secretObject (readonly)

The endpoint’s secret, used to generate [webhook signatures](docs.stripe.com/webhooks/signatures). Only returned at creation.



127
128
129
# File 'lib/stripe/resources/webhook_endpoint.rb', line 127

def secret
  @secret
end

#statusObject (readonly)

The status of the webhook. It can be ‘enabled` or `disabled`.



129
130
131
# File 'lib/stripe/resources/webhook_endpoint.rb', line 129

def status
  @status
end

#urlObject (readonly)

The URL of the webhook endpoint.



131
132
133
# File 'lib/stripe/resources/webhook_endpoint.rb', line 131

def url
  @url
end

Class Method Details

.create(params = {}, opts = {}) ⇒ Object

A webhook endpoint must have a url and a list of enabled_events. You may optionally specify the Boolean connect parameter. If set to true, then a Connect webhook endpoint that notifies the specified url about events from all connected accounts is created; otherwise an account webhook endpoint that notifies the specified url only about events from your account is created. You can also create webhook endpoints in the [webhooks settings](dashboard.stripe.com/account/webhooks) section of the Dashboard.



136
137
138
139
140
141
142
143
# File 'lib/stripe/resources/webhook_endpoint.rb', line 136

def self.create(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: "/v1/webhook_endpoints",
    params: params,
    opts: opts
  )
end

.delete(webhook_endpoint, params = {}, opts = {}) ⇒ Object

You can also delete webhook endpoints via the [webhook endpoint management](dashboard.stripe.com/account/webhooks) page of the Stripe dashboard.



146
147
148
149
150
151
152
153
# File 'lib/stripe/resources/webhook_endpoint.rb', line 146

def self.delete(webhook_endpoint, params = {}, opts = {})
  request_stripe_object(
    method: :delete,
    path: format("/v1/webhook_endpoints/%<webhook_endpoint>s", { webhook_endpoint: CGI.escape(webhook_endpoint) }),
    params: params,
    opts: opts
  )
end

.field_remappingsObject



184
185
186
# File 'lib/stripe/resources/webhook_endpoint.rb', line 184

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



180
181
182
# File 'lib/stripe/resources/webhook_endpoint.rb', line 180

def self.inner_class_types
  @inner_class_types = {}
end

.list(params = {}, opts = {}) ⇒ Object

Returns a list of your webhook endpoints.



166
167
168
# File 'lib/stripe/resources/webhook_endpoint.rb', line 166

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/webhook_endpoints", params: params, opts: opts)
end

.object_nameObject



19
20
21
# File 'lib/stripe/resources/webhook_endpoint.rb', line 19

def self.object_name
  "webhook_endpoint"
end

.update(webhook_endpoint, params = {}, opts = {}) ⇒ Object

Updates the webhook endpoint. You may edit the url, the list of enabled_events, and the status of your endpoint.



171
172
173
174
175
176
177
178
# File 'lib/stripe/resources/webhook_endpoint.rb', line 171

def self.update(webhook_endpoint, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/webhook_endpoints/%<webhook_endpoint>s", { webhook_endpoint: CGI.escape(webhook_endpoint) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

#delete(params = {}, opts = {}) ⇒ Object

You can also delete webhook endpoints via the [webhook endpoint management](dashboard.stripe.com/account/webhooks) page of the Stripe dashboard.



156
157
158
159
160
161
162
163
# File 'lib/stripe/resources/webhook_endpoint.rb', line 156

def delete(params = {}, opts = {})
  request_stripe_object(
    method: :delete,
    path: format("/v1/webhook_endpoints/%<webhook_endpoint>s", { webhook_endpoint: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end