Files
go-cart-actor/pkg/cart/mutation_payment_declined.go
matst80 060b3dfbf0
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 36s
Build and Publish / BuildAndDeployArm64 (push) Successful in 3m59s
more changes
2025-12-01 20:15:48 +01:00

28 lines
508 B
Go

package cart
import (
"errors"
"time"
messages "git.k6n.net/go-cart-actor/pkg/messages"
)
func asPointer[T any](value T) *T {
return &value
}
var ErrPaymentNotFound = errors.New("payment not found")
func PaymentDeclined(grain *CartGrain, req *messages.PaymentDeclined) error {
payment, found := grain.FindPayment(req.PaymentId)
if !found {
return ErrPaymentNotFound
}
payment.CompletedAt = asPointer(time.Now())
payment.Status = PaymentStatusFailed
grain.PaymentInProgress--
return nil
}