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, RetrieveParams, 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

#==, #[], #[]=, 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.



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

def api_version
  @api_version
end

#applicationObject (readonly)

The ID of the associated Connect application.



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

def application
  @application
end

#createdObject (readonly)

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



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

def created
  @created
end

#deletedObject (readonly)

Always true for a deleted object



143
144
145
# File 'lib/stripe/resources/webhook_endpoint.rb', line 143

def deleted
  @deleted
end

#descriptionObject (readonly)

An optional description of what the webhook is used for.



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

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.



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

def enabled_events
  @enabled_events
end

#idObject (readonly)

Unique identifier for the object.



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

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.



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

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.



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

def 
  @metadata
end

#objectObject (readonly)

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



135
136
137
# File 'lib/stripe/resources/webhook_endpoint.rb', line 135

def object
  @object
end

#secretObject (readonly)

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



137
138
139
# File 'lib/stripe/resources/webhook_endpoint.rb', line 137

def secret
  @secret
end

#statusObject (readonly)

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



139
140
141
# File 'lib/stripe/resources/webhook_endpoint.rb', line 139

def status
  @status
end

#urlObject (readonly)

The URL of the webhook endpoint.



141
142
143
# File 'lib/stripe/resources/webhook_endpoint.rb', line 141

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.



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

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.



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

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

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

Returns a list of your webhook endpoints.



176
177
178
# File 'lib/stripe/resources/webhook_endpoint.rb', line 176

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.



181
182
183
184
185
186
187
188
# File 'lib/stripe/resources/webhook_endpoint.rb', line 181

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.



166
167
168
169
170
171
172
173
# File 'lib/stripe/resources/webhook_endpoint.rb', line 166

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