Add webhook for subscription creation#604
Conversation
|
I apologize for the messy diffs in a few files, this was caused by alphabetizing based on method/class name 😅 |
| "payload": payload, | ||
| } | ||
| event_id = ( | ||
| slugify(str(subscription.customer)) |
There was a problem hiding this comment.
I'm not sure which of the subscription fields would be appropriate for the event_id, so I just picked a couple.
There was a problem hiding this comment.
A good one could be subscription_record_id (a UUID field)... unfortunately we created subscriptions when we had a slightly different model structure in the backend so they're referred to as subscription records everywhere.
|
@diego-escobedo I'm having some trouble trying to update the documentation. Does that command need to executed inside one of the docker containers? |
- Set left margin to 0px for subscription created webhook checkbox
|
That's awesome! I'll take note of this perhaps a good idea to add to the developer section in case people want a bit of an easier workflow than doing it all through docker. I'll throw it on our todos. 🪷🪷 |
|
I've updated the docs so this PR should be ready for review/testing! |
| type. | ||
| For `customer.created`, the response will be a [customer](../api-reference/customers/retrieve-customer). | ||
| For `invoice.*`, the response will be an [invoice](../api-reference/invoices/get-invoice). | ||
| For `subscription.created`, the response will be a [subscription](../api-reference/subscriptions/list-subscriptions). |
There was a problem hiding this comment.
When browsing the api reference page, I couldn't find a request for getting a single subscription so I used the /api/subscriptions/ endpoint instead.
There was a problem hiding this comment.
Perfect @djanda97 . It can just be an object of a subscription. The api/subscriptions is just a list of these subscriptions.
There was a problem hiding this comment.
Looks good. Here is the payload I'm getting
{ "attempt": 5, "created_at": "2023-03-07 04:12:44.938810+00:00", "properties": { "event_type": "subscription.created", "payload": { "addons": [], "auto_renew": true, "billing_plan": { "plan_id": "plan_77af5f277e2347048d313ca1c4843251", "plan_name": "Events + Recordings - Pro", "version": 1, "version_id": "plan_version_399d3c5b9da9439a8d9412c70866d459" }, "customer": { "customer_id": "cust_deef1bed569343d2bc3e4614dc0e49ff", "customer_name": "MediumCompany 9cb1fc", "email": "3cc9e9350ae7458c8dfdf92f01478629@aca92ffe6ae84ce2ba961ddeadae0d03.com" }, "end_date": "2023-04-06T23:59:59.999999+00:00", "fully_billed": false, "is_new": true, "start_date": "2023-03-07T04:12:44.158000+00:00", "subscription_filters": [] } } }


Fixes #590
Tasks: