Skip to content

Commit 78ed04a

Browse files
committed
Add documentation for Stripe webhooks
1 parent 7382509 commit 78ed04a

File tree

3 files changed

+63
-9
lines changed

3 files changed

+63
-9
lines changed

blueprint/api.apib

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,6 +2354,56 @@ This endpoint allows you to check whether a username is valid (by running a vali
23542354

23552355
+ Attributes (Unprocessable Entity Response)
23562356

2357+
# Group Webhooks - Stripe
2358+
2359+
Code Corps responds to [Stripe webhooks](https://stripe.com/docs/webhooks).
2360+
2361+
Since Code Corps is a platform, we have two separate webhook endpoints for dealing with both Stripe Connect (the managed accounts) and the platform (shared data across customers).
2362+
2363+
## Stripe Connect Webhook [/webhooks/stripe/connect]
2364+
2365+
Handles Stripe Connect events for managed accounts for projects on the Code Corps platform.
2366+
2367+
This endpoint provides information about the actual payments and subscriptions that occur on the managed accounts.
2368+
2369+
### Stripe Connect Webhook [POST]
2370+
2371+
+ Request
2372+
2373+
+ Attributes
2374+
2375+
+ object - The Stripe object.
2376+
2377+
+ Headers
2378+
2379+
Content-Type: application/vnd.api+json
2380+
2381+
+ Response 200 (application/vnd.api+json; charset=utf-8)
2382+
2383+
+ Response 400 (application/vnd.api+json; charset=utf-8)
2384+
2385+
## Stripe Platform Webhook [/webhooks/stripe/platform]
2386+
2387+
Handles Stripe events for the Code Corps platform itself.
2388+
2389+
The platform stores Stripe customers and cards so they can be reused across different projects, and fan out updates to all the managed Stripe accounts.
2390+
2391+
### Stripe Platform Webhook [POST]
2392+
2393+
+ Request
2394+
2395+
+ Attributes
2396+
2397+
+ object - The Stripe object.
2398+
2399+
+ Headers
2400+
2401+
Content-Type: application/vnd.api+json
2402+
2403+
+ Response 200 (application/vnd.api+json; charset=utf-8)
2404+
2405+
+ Response 400 (application/vnd.api+json; charset=utf-8)
2406+
23572407
# Data Structures
23582408

23592409
## Category Attributes (object)

lib/code_corps/stripe_service/webhook_processing/connect_event_handler.ex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
defmodule CodeCorps.StripeService.WebhookProcessing.ConnectEventHandler do
22
@moduledoc """
3-
In charge of handling Stripe Connect webhooks
3+
Handler for Stripe Connect webhooks.
44
"""
55

66
alias CodeCorps.StripeService.Events
77

88
@doc """
9-
Handles Stripe Connect webhooks
9+
Handles Stripe Connect webhook events.
1010
1111
## Returns
12-
* The result of calling the specific handlers `handle/1` function. This result ought ot be a tupple,
13-
in which the first member is `:ok`, followed by one or more other elements, usually modified records.
14-
* `{:ok, :unhandled_event}` if the specific event is not supported yet or at all
12+
* The result of calling the specific handlers `handle/1` function. This
13+
result should be a tuple, in which the first member is `:ok`, followed by
14+
one or more other elements, usually modified records.
15+
* `{:ok, :unhandled_event}` if the specific event is not supported yet
16+
or at all
1517
"""
1618
def handle_event(%{type: type} = attributes), do: do_handle(type, attributes)
1719

lib/code_corps/stripe_service/webhook_processing/platform_event_handler.ex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
defmodule CodeCorps.StripeService.WebhookProcessing.PlatformEventHandler do
22
@moduledoc """
3-
In charge of handling Stripe Platform webhooks
3+
Handler for Stripe Platform webhooks.
44
"""
55

66
alias CodeCorps.StripeService.Events
@@ -9,9 +9,11 @@ defmodule CodeCorps.StripeService.WebhookProcessing.PlatformEventHandler do
99
Handles Stripe Platform webhooks
1010
1111
## Returns
12-
* The result of calling the specific handlers `handle/1` function. This result ought ot be a tupple,
13-
in which the first member is `:ok`, followed by one or more other elements, usually modified records.
14-
* `{:ok, :unhandled_event}` if the specific event is not supported yet or at all
12+
* The result of calling the specific handlers `handle/1` function. This
13+
result should be a tuple, in which the first member is `:ok`, followed by
14+
one or more other elements, usually modified records.
15+
* `{:ok, :unhandled_event}` if the specific event is not supported yet
16+
or at all
1517
"""
1618
def handle_event(%{type: type} = attributes), do: do_handle(type, attributes)
1719

0 commit comments

Comments
 (0)