From 3b00c1828f14f89e089f8728b78353425e268b0f Mon Sep 17 00:00:00 2001 From: Robert Allen Date: Mon, 13 Oct 2025 11:22:44 +0300 Subject: [PATCH 1/2] DV-3540: added new receipt email template support --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 4 ++-- internal/service/notification_sender/mail_sender/handlers.go | 2 ++ internal/service/notify/types.go | 2 ++ internal/service/templater/payload.go | 5 +++++ internal/service/transactions/event_handler.go | 2 ++ 7 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 261e7fb..211bffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - fix: sort currency order for form without api key [DV-3529] - chore: reuse errors across multiple exchange clients [DV-3544] - fix: exclude unconfirmed transactions for tx-find [DV-3528] +- feat: added new receipt email mustache template support [DV-3540] ## [0.9.7] - 2025-09-22 - Fix rename ResetPasswordCode to Code for consistency in user notifications [DV-3403] diff --git a/go.mod b/go.mod index a95d5d7..78394ca 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/cbroglie/mustache v1.4.0 github.com/dv-net/dv-processing v0.9.5-RC01 github.com/dv-net/dv-proto v0.5.1 - github.com/dv-net/email-template v0.1.4 + github.com/dv-net/email-template v0.1.5-0.20251010104137-d269cfd03a5f github.com/dv-net/go-bip39 v1.1.1 github.com/dv-net/mx v0.1.1 github.com/dv-net/xconfig v0.1.0 diff --git a/go.sum b/go.sum index 3e6cc18..27c1567 100644 --- a/go.sum +++ b/go.sum @@ -193,8 +193,8 @@ github.com/dv-net/dv-processing v0.9.5-RC01 h1:vw0YDcn8CYuhvk+vFqln3irMINgdqU6Ak github.com/dv-net/dv-processing v0.9.5-RC01/go.mod h1:8qz80xHkRHLeS9vWts/zagz6po3lRvHHLvuq1Ki97I8= github.com/dv-net/dv-proto v0.5.1 h1:SUmKb2ja7qyMz6g4z0Jw/y+US7F0zq4qUYq1kFoSv2M= github.com/dv-net/dv-proto v0.5.1/go.mod h1:X8D+6FZu/YX0hL+Tb2LhozNUdVcQgcLMsmTW9MrZl5o= -github.com/dv-net/email-template v0.1.4 h1:LjHE8lYHqrk9WuumNCH/QfDVCC7YDr/qBwHO7IfbmDc= -github.com/dv-net/email-template v0.1.4/go.mod h1:Qbt8pjxHwdOb1XUWDhLjtEPIODWDOYdt6Y10SOAdTBw= +github.com/dv-net/email-template v0.1.5-0.20251010104137-d269cfd03a5f h1:DHSMVb05JLHqf0NJQjkmTExZXtUTAqOInQOUpxqoDow= +github.com/dv-net/email-template v0.1.5-0.20251010104137-d269cfd03a5f/go.mod h1:Qbt8pjxHwdOb1XUWDhLjtEPIODWDOYdt6Y10SOAdTBw= github.com/dv-net/go-bip39 v1.1.1 h1:KRJwVNjgJPipMfwVN0qbAJG17fMu4BvjDD/tnP35ers= github.com/dv-net/go-bip39 v1.1.1/go.mod h1:zbcC/5LED0EfiNZdvDoLgcyl+9mfMH/bEQdxTn4hj/Q= github.com/dv-net/mx v0.1.1 h1:+Y02hBmGY2JRxUR/kHM+TPbs8863CVnxrYsukXDR8CI= diff --git a/internal/service/notification_sender/mail_sender/handlers.go b/internal/service/notification_sender/mail_sender/handlers.go index 7b974d8..e082bd9 100644 --- a/internal/service/notification_sender/mail_sender/handlers.go +++ b/internal/service/notification_sender/mail_sender/handlers.go @@ -376,6 +376,8 @@ func (svc *Service) handleUserCryptoReceipt(_ context.Context, email string, enc NetworkFeeAmount: pBody.NetworkFeeAmount, NetworkFeeCurrency: pBody.NetworkFeeCurrency, NetworkFeeUSD: pBody.NetworkFeeUSD, + StoreName: pBody.StoreName, + StoreUserID: pBody.StoreUserID, } body, err := svc.templateSvc.AssembleEmail(emailParams) diff --git a/internal/service/notify/types.go b/internal/service/notify/types.go index 4c5d3e5..530742c 100644 --- a/internal/service/notify/types.go +++ b/internal/service/notify/types.go @@ -332,6 +332,8 @@ type UserCryptoReceiptNotificationData struct { PlatformFeeAmount string `json:"platform_fee_amount"` PlatformFeeUSD string `json:"platform_fee_usd"` PlatformFeeCurrency string `json:"platform_fee_currency"` + StoreUserID string `json:"store_user_id"` + StoreName string `json:"store_name"` } func (d *UserCryptoReceiptNotificationData) Encode() ([]byte, error) { diff --git a/internal/service/templater/payload.go b/internal/service/templater/payload.go index 92a3946..d53aa22 100644 --- a/internal/service/templater/payload.go +++ b/internal/service/templater/payload.go @@ -424,6 +424,7 @@ type CryptoReceiptI18N struct { Subject string `json:"subject"` } `json:"email"` TitleLabel string `json:"title_label"` + TokenLabel string `json:"token_label"` PaymentStatus struct { Pending string `json:"pending"` Completed string `json:"completed"` @@ -439,6 +440,8 @@ type CryptoReceiptI18N struct { PaymentTypeLabel string `json:"payment_type_label"` PaymentBlockchainLabel string `json:"payment_blockchain_label"` TransactionHashLabel string `json:"transaction_hash_label"` + StoreNameLabel string `json:"store_name_label"` + StoreUserIdLabel string `json:"store_user_id_label"` //nolint:revive Payment struct { AmountLabel string `json:"amount_label"` NetworkLabelPrefix string `json:"network_label_prefix"` @@ -482,6 +485,8 @@ type UserCryptoReceiptPayload struct { PlatformFeeAmount string `json:"platform_fee_amount"` PlatformFeeUSD string `json:"platform_fee_usd"` PlatformFeeCurrency string `json:"platform_fee_currency"` + StoreName string `json:"store_name"` + StoreUserID string `json:"store_user_id"` //nolint:revive } // Simple methods for dynamic text resolution (called by mustache as simple methods) diff --git a/internal/service/transactions/event_handler.go b/internal/service/transactions/event_handler.go index dc8b56f..8ebf88a 100644 --- a/internal/service/transactions/event_handler.go +++ b/internal/service/transactions/event_handler.go @@ -62,6 +62,8 @@ func (s *Service) handleDepositReceiptSent(ev event.IEvent) error { PlatformFeeAmount: decimal.Zero.String(), PlatformFeeUSD: decimal.Zero.String(), PlatformFeeCurrency: currency.Code, + StoreName: storeData.Name, + StoreUserID: convertedEv.GetStoreExternalID(), }, &models.NotificationArgs{ StoreID: util.Pointer(storeData.ID), }) From c8948a411c9c60d3205618813d06e0018a62ce14 Mon Sep 17 00:00:00 2001 From: Robert Allen Date: Mon, 13 Oct 2025 11:43:56 +0300 Subject: [PATCH 2/2] DV-3450: linter fix --- internal/service/templater/payload.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/templater/payload.go b/internal/service/templater/payload.go index d53aa22..4dd3783 100644 --- a/internal/service/templater/payload.go +++ b/internal/service/templater/payload.go @@ -486,7 +486,7 @@ type UserCryptoReceiptPayload struct { PlatformFeeUSD string `json:"platform_fee_usd"` PlatformFeeCurrency string `json:"platform_fee_currency"` StoreName string `json:"store_name"` - StoreUserID string `json:"store_user_id"` //nolint:revive + StoreUserID string `json:"store_user_id"` } // Simple methods for dynamic text resolution (called by mustache as simple methods)