Просмотр исходного кода

Merge pull request #28898 from overleaf/ls-send-email-for-tax-exempt-certificate

Send email if tax exempt certificate is required

GitOrigin-RevId: 685fec7dbb129eab19095470e681d09423558e4c
Liangjun Song 1 год назад
Родитель
Сommit
2153fd7fa5

+ 29 - 0
services/web/app/src/Features/Email/EmailBuilder.js

@@ -974,6 +974,35 @@ templates.removeGroupMember = NoCTAEmailTemplate({
   },
 })
 
+templates.taxExemptCertificateRequired = NoCTAEmailTemplate({
+  subject(opts) {
+    return `Action required: Tax exemption verification for Overleaf [${opts.ein}]`
+  },
+  title() {
+    return 'Action required: Tax exemption verification'
+  },
+  greeting() {
+    return ''
+  },
+  message(opts) {
+    return [
+      'Thanks for letting us know your organization is tax exempt. To confirm this, we need some additional verification.',
+      'Please reply to this email with one of the following documents attached:',
+      '<ul>',
+      '<li>Your IRS determination letter (for non-profits and similar organizations)</li>',
+      '<li>Your state resale or exemption certificate</li>',
+      '</ul>',
+      `These should match the EIN you provided:${opts.ein}.`,
+      'If you have any questions, let us know by replying to this email.',
+      '<br/>',
+      'Best wishes,',
+      'Team Overleaf',
+      '<br/>',
+      `Our reference:${opts.stripeCustomerId}`,
+    ]
+  },
+})
+
 function _formatUserNameAndEmail(user, placeholder) {
   if (user.first_name && user.last_name) {
     const fullName = `${user.first_name} ${user.last_name}`

+ 3 - 0
services/web/app/src/Features/Email/EmailSender.js

@@ -104,6 +104,9 @@ async function sendEmail(options, emailType) {
       replyTo: options.replyTo || EMAIL_SETTINGS.replyToAddress,
       socketTimeout: 30 * 1000,
     }
+    if (options.cc) {
+      sendMailOptions.cc = options.cc
+    }
     if (EMAIL_SETTINGS.textEncoding != null) {
       sendMailOptions.textEncoding = EMAIL_SETTINGS.textEncoding
     }

+ 51 - 0
services/web/test/unit/src/Email/EmailBuilderTests.js

@@ -880,6 +880,57 @@ describe('EmailBuilder', function () {
           })
         })
       })
+
+      describe('taxExemptCertificateRequired', function () {
+        beforeEach(function () {
+          this.emailAddress = 'customer@example.com'
+          this.opts = {
+            to: this.emailAddress,
+            ein: '12-3456789',
+            stripeCustomerId: 'cus_123456789',
+          }
+          this.email = this.EmailBuilder.buildEmail(
+            'taxExemptCertificateRequired',
+            this.opts
+          )
+          this.dom = cheerio.load(this.email.html)
+        })
+
+        it('should build the email', function () {
+          expect(this.email.html).to.exist
+          expect(this.email.text).to.exist
+        })
+
+        describe('HTML email', function () {
+          it('should include the EIN', function () {
+            expect(this.email.html).to.contain(this.opts.ein)
+          })
+
+          it('should include the Stripe customer ID', function () {
+            expect(this.email.html).to.contain(this.opts.stripeCustomerId)
+          })
+
+          it('should include tax exemption verification text', function () {
+            expect(this.email.html).to.contain('tax exempt')
+            expect(this.email.html).to.contain('verification')
+          })
+        })
+
+        describe('plain text email', function () {
+          it('should include the EIN', function () {
+            expect(this.email.text).to.contain(this.opts.ein)
+          })
+
+          it('should include the Stripe customer ID', function () {
+            expect(this.email.text).to.contain(this.opts.stripeCustomerId)
+          })
+
+          it('should include tax exemption verification text', function () {
+            expect(this.email.text).to.contain('tax exempt')
+            expect(this.email.text).to.contain('verification')
+          })
+        })
+      })
     })
   })
 })