(cls, request, stripe_account=None)
return obj
Create, validate and process a WebhookEventTrigger given a Django
        request object.

        The process is three-fold:
        1. Create a WebhookEventTrigger object from a Django request.
        2. Validate the WebhookEventTrigger as a Stripe event using the API.
        3. If valid, process it into an Event object (and child resource).
Create, validate and process a WebhookEventTrigger given a Django
        request object.
Create validate and process a WebhookEventTrigger given a Django request object .
def from_request(cls, request, stripe_account=None):
        """
        Create, validate and process a WebhookEventTrigger given a Django
        request object.

        The process is three-fold:
        1. Create a WebhookEventTrigger object from a Django request.
        2. Validate the WebhookEventTrigger as a Stripe event using the API.
        3. If valid, process it into an Event object (and child resource).
        """

        try:
            body = request.body.decode(request.encoding or "utf-8")
        except Exception:
            body = "(error decoding body)"

        ip = get_remote_ip(request)

        try:
            data = json.loads(body)
        except ValueError:
            data = {}

        if stripe_account is None:
            stripe_account = StripeModel._find_owner_account(data=data)

        obj = cls.objects.create(
            headers=dict(request.headers),
            body=body,
            remote_ip=ip,
            stripe_trigger_account=stripe_account,
        )

        try:
            obj.valid = obj.validate()
            if obj.valid:
                if djstripe_settings.WEBHOOK_EVENT_CALLBACK:
                    # If WEBHOOK_EVENT_CALLBACK, pass it for processing
                    djstripe_settings.WEBHOOK_EVENT_CALLBACK(obj)
                else:
                    # Process the item (do not save it, it'll get saved below)
                    obj.process(save=False)
        except Exception as e:
            max_length = WebhookEventTrigger._meta.get_field("exception").max_length
            obj.exception = str(e)[:max_length]
            obj.traceback = format_exc()

            # Send the exception as the webhook_processing_error signal
            webhook_processing_error.send(
                sender=WebhookEventTrigger,
                exception=e,
                data=getattr(e, "http_body", ""),
            )

            # re-raise the exception so Django sees it
            raise e
        finally:
            obj.save()

        return obj
def from_request ( cls , request , stripe_account = None ) : try : body = request . body . decode ( request . encoding or "utf-8" ) except Exception : body = "(error decoding body)" ip = get_remote_ip ( request ) try : data = json . loads ( body ) except ValueError : data = { } if stripe_account is None : stripe_account = StripeModel . _find_owner_account ( data = data ) obj = cls . objects . create ( headers = dict ( request . headers ) , body = body , remote_ip = ip , stripe_trigger_account = stripe_account , ) try : obj . valid = obj . validate ( ) if obj . valid : if djstripe_settings . WEBHOOK_EVENT_CALLBACK : # If WEBHOOK_EVENT_CALLBACK, pass it for processing djstripe_settings . WEBHOOK_EVENT_CALLBACK ( obj ) else : # Process the item (do not save it, it'll get saved below) obj . process ( save = False ) except Exception as e : max_length = WebhookEventTrigger . _meta . get_field ( "exception" ) . max_length obj . exception = str ( e ) [ : max_length ] obj . traceback = format_exc ( ) # Send the exception as the webhook_processing_error signal webhook_processing_error . send ( sender = WebhookEventTrigger , exception = e , data = getattr ( e , "http_body" , "" ) , ) # re-raise the exception so Django sees it raise e finally : obj . save ( ) return obj