Files
go-cart-actor/pkg/cart/mutation_payment_declined.go
matst80 c227870f13
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 37s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m10s
add more payment related shit
2025-12-01 18:35:32 +01:00

27 lines
481 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
return nil
}