(event)
Handle updates to payment_method objects
    :param event:
    :return:

    Docs for:
    - payment_method: https://stripe.com/docs/api/payment_methods
Handle updates to payment_method objects
    :param event:
    :return:
Handle updates to payment_method objects : param event : : return :
def payment_method_handler(event):
    """
    Handle updates to payment_method objects
    :param event:
    :return:

    Docs for:
    - payment_method: https://stripe.com/docs/api/payment_methods
    """
    # will recieve all events of the type payment_method.X.Y so
    # need to ensure the data object is related to PaymentMethod Object
    target_object_type = event.data.get("object", {}).get("object", {})

    if target_object_type == "payment_method":
        id_ = event.data.get("object", {}).get("id", None)

        if (
            event.parts == ["payment_method", "detached"]
            and id_
            and id_.startswith("card_")
        ):
            # Special case to handle a quirk in stripe's wrapping of legacy "card" objects
            # with payment_methods - card objects are deleted on detach, so treat this as
            # a delete event
            _handle_crud_like_event(
                target_cls=models.PaymentMethod,
                event=event,
                crud_type=CrudType.DELETED,
            )
        else:
            _handle_crud_like_event(target_cls=models.PaymentMethod, event=event)
def payment_method_handler ( event ) : # will recieve all events of the type payment_method.X.Y so # need to ensure the data object is related to PaymentMethod Object target_object_type = event . data . get ( "object" , { } ) . get ( "object" , { } ) if target_object_type == "payment_method" : id_ = event . data . get ( "object" , { } ) . get ( "id" , None ) if ( event . parts == [ "payment_method" , "detached" ] and id_ and id_ . startswith ( "card_" ) ) : # Special case to handle a quirk in stripe's wrapping of legacy "card" objects # with payment_methods - card objects are deleted on detach, so treat this as # a delete event _handle_crud_like_event ( target_cls = models . PaymentMethod , event = event , crud_type = CrudType . DELETED , ) else : _handle_crud_like_event ( target_cls = models . PaymentMethod , event = event )