improved logging + autotests

This commit is contained in:
Stephan D
2025-12-26 12:26:28 +01:00
parent 5191336a49
commit 171d90b3f7
20 changed files with 1282 additions and 56 deletions

View File

@@ -24,7 +24,7 @@ func (c *Client) sendCardPayout(ctx context.Context, req CardPayoutRequest) (*Ca
maskedPAN := MaskPAN(req.Card.PAN)
return c.send(ctx, &req, "/v2/payment/card/payout",
func() {
c.logger.Info("dispatching Monetix card payout",
c.logger.Info("Dispatching Monetix card payout",
zap.String("payout_id", req.General.PaymentID),
zap.Int64("amount_minor", req.Payment.Amount),
zap.String("currency", req.Payment.Currency),
@@ -47,7 +47,7 @@ func (c *Client) sendCardPayout(ctx context.Context, req CardPayoutRequest) (*Ca
func (c *Client) sendCardTokenPayout(ctx context.Context, req CardTokenPayoutRequest) (*CardPayoutSendResult, error) {
return c.send(ctx, &req, "/v2/payment/card/payout/token",
func() {
c.logger.Info("dispatching Monetix card token payout",
c.logger.Info("Dispatching Monetix card token payout",
zap.String("payout_id", req.General.PaymentID),
zap.Int64("amount_minor", req.Payment.Amount),
zap.String("currency", req.Payment.Currency),
@@ -101,7 +101,7 @@ func (c *Client) sendTokenization(ctx context.Context, req CardTokenizeRequest)
httpReq.Header.Set("Content-Type", "application/json")
httpReq.Header.Set("Accept", "application/json")
c.logger.Info("dispatching Monetix card tokenization",
c.logger.Info("Dispatching Monetix card tokenization",
zap.String("request_id", req.General.PaymentID),
zap.String("masked_pan", MaskPAN(req.Card.PAN)),
)
@@ -111,7 +111,7 @@ func (c *Client) sendTokenization(ctx context.Context, req CardTokenizeRequest)
duration := time.Since(start)
if err != nil {
observeRequest(outcomeNetworkError, duration)
c.logger.Warn("monetix tokenization request failed", zap.Error(err))
c.logger.Warn("Monetix tokenization request failed", zap.Error(err))
return nil, merrors.Internal("monetix tokenization request failed: " + err.Error())
}
defer resp.Body.Close()
@@ -133,7 +133,7 @@ func (c *Client) sendTokenization(ctx context.Context, req CardTokenizeRequest)
var apiResp APIResponse
if len(body) > 0 {
if err := json.Unmarshal(body, &apiResp); err != nil {
c.logger.Warn("failed to decode Monetix tokenization response", zap.String("request_id", req.General.PaymentID), zap.Int("status_code", resp.StatusCode), zap.Error(err))
c.logger.Warn("Failed to decode Monetix tokenization response", zap.String("request_id", req.General.PaymentID), zap.Int("status_code", resp.StatusCode), zap.Error(err))
} else {
var tokenData struct {
Token string `json:"token"`
@@ -245,7 +245,7 @@ func (c *Client) send(ctx context.Context, req any, path string, dispatchLog fun
var apiResp APIResponse
if len(body) > 0 {
if err := json.Unmarshal(body, &apiResp); err != nil {
c.logger.Warn("failed to decode Monetix response", zap.Int("status_code", resp.StatusCode), zap.Error(err))
c.logger.Warn("Failed to decode Monetix response", zap.Int("status_code", resp.StatusCode), zap.Error(err))
}
}