Files
go-cart-actor/pkg/checkout/mutation_payment_declined.go
Mats Törnberg ee5f54f0dd
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 59s
Build and Publish / BuildAndDeployArm64 (push) Successful in 5m40s
refactor/checkout (#8)
Co-authored-by: matst80 <mats.tornberg@gmail.com>
Reviewed-on: #8
Co-authored-by: Mats Törnberg <mats@tornberg.me>
Co-committed-by: Mats Törnberg <mats@tornberg.me>
2025-12-03 09:45:48 +01:00

29 lines
498 B
Go

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