refactored orchestrator and callbacks service to use pkg messsaging + envelope factory / handler

This commit is contained in:
Stephan D
2026-02-28 20:56:26 +01:00
parent 363d6474f2
commit 12c67361dd
14 changed files with 316 additions and 311 deletions

View File

@@ -0,0 +1,42 @@
package notifications
import (
"encoding/json"
"strings"
messaging "github.com/tech/sendico/pkg/messaging/envelope"
"github.com/tech/sendico/pkg/model"
nm "github.com/tech/sendico/pkg/model/notification"
"github.com/tech/sendico/pkg/mservice"
)
type PaymentStatusUpdatedNotification struct {
messaging.Envelope
payload model.PaymentStatusUpdated
}
func (psn *PaymentStatusUpdatedNotification) Serialize() ([]byte, error) {
data, err := json.Marshal(psn.payload)
if err != nil {
return nil, err
}
return psn.Envelope.Wrap(data)
}
func paymentStatusUpdatedEvent() model.NotificationEvent {
return model.NewNotification(mservice.PaymentOrchestrator, nm.NAUpdated)
}
func NewPaymentStatusUpdatedEnvelope(sender string, status *model.PaymentStatusUpdated) messaging.Envelope {
payload := model.PaymentStatusUpdated{}
if status != nil {
payload = *status
}
if strings.TrimSpace(payload.Type) == "" {
payload.Type = model.PaymentStatusUpdatedType
}
return &PaymentStatusUpdatedNotification{
Envelope: messaging.CreateEnvelope(sender, paymentStatusUpdatedEvent()),
payload: payload,
}
}