(self, domain)
Sends an email to the new autopayer for this account telling them they are now the autopayer
Sends an email to the new autopayer for this account telling them they are now the autopayer
Sends an email to the new autopayer for this account telling them they are now the autopayer
def _send_autopay_card_added_email(self, domain):
        """Sends an email to the new autopayer for this account telling them they are now the autopayer"""
        from corehq.apps.domain.views.accounting import EditExistingBillingAccountView
        subject = _("Your card is being used to auto-pay for {billing_account}").format(
            billing_account=self.name)
        web_user = WebUser.get_by_username(self.auto_pay_user)
        new_user_name = web_user.first_name if web_user else self.auto_pay_user
        email = web_user.get_email() if web_user else self.auto_pay_user
        try:
            last_4 = self.autopay_card.last4
        except StripePaymentMethod.DoesNotExist:
            last_4 = None

        context = {
            'name': new_user_name,
            'username': web_user.username if web_user else self.auto_pay_user,
            'domain': domain,
            'last_4': last_4,
            'billing_account_name': self.name,
            'billing_info_url': absolute_reverse(EditExistingBillingAccountView.urlname,
                                                 args=[domain]),
            'invoicing_contact_email': settings.INVOICING_CONTACT_EMAIL,
        }

        send_html_email_async(
            subject,
            email,
            render_to_string('accounting/email/invoice_autopay_setup.html', context),
            text_content=strip_tags(render_to_string('accounting/email/invoice_autopay_setup.html', context)),
        )
def _send_autopay_card_added_email ( self , domain ) : from corehq . apps . domain . views . accounting import EditExistingBillingAccountView subject = _ ( "Your card is being used to auto-pay for {billing_account}" ) . format ( billing_account = self . name ) web_user = WebUser . get_by_username ( self . auto_pay_user ) new_user_name = web_user . first_name if web_user else self . auto_pay_user email = web_user . get_email ( ) if web_user else self . auto_pay_user try : last_4 = self . autopay_card . last4 except StripePaymentMethod . DoesNotExist : last_4 = None context = { 'name' : new_user_name , 'username' : web_user . username if web_user else self . auto_pay_user , 'domain' : domain , 'last_4' : last_4 , 'billing_account_name' : self . name , 'billing_info_url' : absolute_reverse ( EditExistingBillingAccountView . urlname , args = [ domain ] ) , 'invoicing_contact_email' : settings . INVOICING_CONTACT_EMAIL , } send_html_email_async ( subject , email , render_to_string ( 'accounting/email/invoice_autopay_setup.html' , context ) , text_content = strip_tags ( render_to_string ( 'accounting/email/invoice_autopay_setup.html' , context ) ) , )