djstripe.event_handlers
Webhook event handlers for the various models Stripe docs for Events: https://stripe.com/docs/api/events Stripe docs for Webhooks: https://stripe.com/docs/webhooks TODO: Implement webhook event handlers for all the models that need to respond to webhook events. NOTE: Event data is not guaranteed to be in the correct API version format. See #116. When writing a webhook handler, make sure to first re-retrieve the object you wish to process.
CrudType
Bases: Enum
Helper object to determine CRUD-like event state.
DELETED
attribute DELETED
UPDATED
attribute UPDATED
determine
determine(cls, event, verb = None)
Determine if the event verb is a crud_type (without the 'R') event.
:param event: :type event: models.Event :param verb: The event verb to examine. :type verb: str :returns: The CrudType state object. :rtype: CrudType
djstripe_receiver
djstripe_receiver(signal_names)
A wrapper around django's receiver to do some error checking.
Ultimately connects event handlers to Django signals.
Usage: Apply this decorator to a function, providing the 'signal_names.' It connects the function to the specified signal if 'signal_name' is enabled.
Parameters:
- signal_names (list or tuple or str): List or tuple of event names or just the event name itself.
Example: @djstripe_receiver("my_signal") def my_event_handler(sender, event, **kwargs): # Custom event handling logic here
@djstripe_receiver(["my_signal_1", "my_signal_2"]) def my_event_handler(sender, event, **kwargs): # Custom event handling logic here
handle_account_external_account_event
handle_account_external_account_event(sender, event, **kwargs)
Handles updates to Connected Accounts External Accounts
handle_account_updated_event
handle_account_updated_event(sender, event, **kwargs)
Handles updates to Connected Accounts - account: https://stripe.com/docs/api/accounts
handle_charge_dispute_event
handle_charge_dispute_event(sender, event, **kwargs)
Handle updates to Dispute objects
- dispute: https://stripe.com/docs/api/disputes
handle_charge_event
handle_charge_event(sender, event, **kwargs)
Handle updates to Charge objects
handle_customer_entitlements_event
handle_customer_entitlements_event(sender, event, **kwargs)
Handle entitlements.active_entitlement_summary.updated events.
This event tracks changes to a customer's active entitlements. We sync the Customer object to update the entitlements data stored in stripe_data.
handle_customer_event
handle_customer_event(sender, event, **kwargs)
Handle updates to customer objects.
First determines the crud_type and then handles the event if a customer exists locally. As customers are tied to local users, djstripe will not create customers that do not already exist locally.
And updates to the subscriber model and metadata fields of customer if present in checkout.sessions metadata key.
Docs and an example customer webhook response: https://stripe.com/docs/api#customer_object
handle_customer_subscription_event
handle_customer_subscription_event(sender, event, **kwargs)
Handle updates to customer subscription objects.
Docs an example subscription webhook response: https://stripe.com/docs/api#subscription_object
handle_customer_tax_id_event
handle_customer_tax_id_event(sender, event, **kwargs)
Handle updates to customer tax ID objects.
handle_identity_verification_session_event
handle_identity_verification_session_event(sender, event, **kwargs)
Handle updates to Stripe Identity Verification Session objects.
Docs: https://stripe.com/docs/api/identity/verification_sessions
handle_other_event
handle_other_event(sender, event, **kwargs)
Handle updates to checkout, coupon, file, invoice, invoiceitem, payment_intent, plan, product, setup_intent, subscription_schedule, tax_rate, promotion_code and transfer objects.
Docs for:
- checkout: https://stripe.com/docs/api/checkout/sessions
- coupon: https://stripe.com/docs/api/coupons
- file: https://stripe.com/docs/api/files
- invoice: https://stripe.com/docs/api/invoices
- invoiceitem: https://stripe.com/docs/api/invoiceitems
- order: https://stripe.com/docs/api/orders_v2
- payment_intent: https://stripe.com/docs/api/payment_intents
- payout: https://stripe.com/docs/api/payouts
- price: https://stripe.com/docs/api/prices
- product: https://stripe.com/docs/api/products
- setup_intent: https://stripe.com/docs/api/setup_intents
- subscription_schedule: https://stripe.com/docs/api/subscription_schedules
- tax_rate: https://stripe.com/docs/api/tax_rates/
- transfer: https://stripe.com/docs/api/transfers
- promotion_code: https://docs.stripe.com/api/promotion_codes
handle_payment_method_event
handle_payment_method_event(sender, event, **kwargs)
Handle updates to payment_method objects :param event: :return:
Docs for:
- payment_method: https://stripe.com/docs/api/payment_methods
update_customer_helper
update_customer_helper(metadata, customer_id, subscriber_key)
A helper function that updates customer's subscriber and metadata fields