(
    request: AuthedHttpRequest, team_id: str
)
return HttpResponse(status=204)
Endpoint to allow users to update Stripe customer info.
Endpoint to allow users to update Stripe customer info.
Endpoint to allow users to update Stripe customer info .
def update_stripe_customer_info(
    request: AuthedHttpRequest, team_id: str
) -> HttpResponse:
    """
    Endpoint to allow users to update Stripe customer info.
    """
    account = get_account_or_404(team_id=team_id, user=request.user)
    payload = UpdateBillingInfoModel.parse_raw(request.body)
    if payload.limitBillingAccessToOwners is not None:
        if not request.user.is_admin(account):
            raise PermissionDenied
        account.limit_billing_access_to_owners = payload.limitBillingAccessToOwners
        account.save()

    if payload.contactEmails is not None:
        if not request.user.can_edit_subscription(account):
            raise PermissionDenied
        account.contact_emails = payload.contactEmails
        account.save()

    if (
        payload.email is not None
        or payload.name is not None
        or payload.address is not None
    ):
        if not request.user.can_edit_subscription(account):
            raise PermissionDenied
        account.update_billing_info(
            email=payload.email,
            name=payload.name,
            address=(
                Address(
                    line1=payload.address.line1,
                    city=payload.address.city,
                    country=payload.address.country,
                    line2=payload.address.line2,
                    postal_code=payload.address.postalCode,
                    state=payload.address.state,
                )
                if payload.address is not None
                else None
            ),
        )
    return HttpResponse(status=204)
def update_stripe_customer_info ( request : AuthedHttpRequest , team_id : str ) -> HttpResponse : account = get_account_or_404 ( team_id = team_id , user = request . user ) payload = UpdateBillingInfoModel . parse_raw ( request . body ) if payload . limitBillingAccessToOwners is not None : if not request . user . is_admin ( account ) : raise PermissionDenied account . limit_billing_access_to_owners = payload . limitBillingAccessToOwners account . save ( ) if payload . contactEmails is not None : if not request . user . can_edit_subscription ( account ) : raise PermissionDenied account . contact_emails = payload . contactEmails account . save ( ) if ( payload . email is not None or payload . name is not None or payload . address is not None ) : if not request . user . can_edit_subscription ( account ) : raise PermissionDenied account . update_billing_info ( email = payload . email , name = payload . name , address = ( Address ( line1 = payload . address . line1 , city = payload . address . city , country = payload . address . country , line2 = payload . address . line2 , postal_code = payload . address . postalCode , state = payload . address . state , ) if payload . address is not None else None ) , ) return HttpResponse ( status = 204 )