(metadata, customer_id, subscriber_key)
A helper function that updates customer's subscriber and metadata fields
A helper function that updates customer's subscriber and metadata fields
A helper function that updates customer s subscriber and metadata fields
def update_customer_helper(metadata, customer_id, subscriber_key):
    """
    A helper function that updates customer's subscriber and metadata fields
    """

    # only update customer.subscriber if both the customer and subscriber already exist
    if (
        subscriber_key not in ("", None)
        and metadata.get(subscriber_key, "")
        and customer_id
    ):
        try:
            subscriber = djstripe_settings.get_subscriber_model().objects.get(
                id=metadata.get(subscriber_key, "")
            )
            customer = models.Customer.objects.get(id=customer_id)
            customer.subscriber = subscriber
            customer.metadata = metadata
            customer.save()

        except ObjectDoesNotExist:
            pass
def update_customer_helper ( metadata , customer_id , subscriber_key ) : # only update customer.subscriber if both the customer and subscriber already exist if ( subscriber_key not in ( "" , None ) and metadata . get ( subscriber_key , "" ) and customer_id ) : try : subscriber = djstripe_settings . get_subscriber_model ( ) . objects . get ( id = metadata . get ( subscriber_key , "" ) ) customer = models . Customer . objects . get ( id = customer_id ) customer . subscriber = subscriber customer . metadata = metadata customer . save ( ) except ObjectDoesNotExist : pass