Description
User Story
As a new user signing up for Paycrest
I want to receive a welcome email after successful registration
So that I can feel welcomed and understand what type of account I've created
Acceptance Criteria
-
GIVEN a user successfully registers on Paycrest
WHEN the registration process completes
THEN a welcome email should be sent to their email address -
GIVEN a user registers with either sender or provider scope
WHEN the welcome email is received
THEN it should contain information specific to their account type -
GIVEN a user registers in any environment (production/non-production)
WHEN the registration is successful
THEN the welcome email should be sent regardless of email verification status
Tech Details
-
Create new SendGrid template for welcome emails with dynamic data:
first_name
: User's first nameemail
: User's email addressscopes
: User's account scopes (sender/provider)
-
Add new method to
EmailService
:
func (m *EmailService) SendWelcomeEmail(ctx context.Context, email, firstName string, scopes []string) (types.SendEmailResponse, error) {
payload := types.SendEmailPayload{
FromAddress: _DefaultFromAddress,
ToAddress: email,
DynamicData: map[string]interface{}{
"first_name": firstName,
"email": email,
"scopes": scopes,
},
}
return SendTemplateEmail(payload, "WELCOME_EMAIL_TEMPLATE_ID")
}
-
Modify
Register
function incontrollers/accounts/auth.go
to send welcome email after successful user creation but before verification email. -
Add unit tests in
services/email_test.go
and integration tests incontrollers/accounts/auth_test.go
.
Notes/Assumptions
- The welcome email should be sent after user creation but before verification email
- If welcome email fails to send, it should be logged but not block registration
- Existing email service infrastructure (SendGrid) will be used
- Welcome email template will be created in SendGrid before implementation
- The feature should not affect existing email verification flow