Files
go-cart-actor/pkg/cart/mutation_create_checkout_order.go
Mats Törnberg 374bd4272b
Some checks failed
Build and Publish / BuildAndDeployAmd64 (push) Failing after 10s
Build and Publish / BuildAndDeployArm64 (push) Failing after 11s
update
2025-11-25 19:34:39 +01:00

23 lines
526 B
Go

package cart
import (
"errors"
messages "git.k6n.net/go-cart-actor/pkg/messages"
"github.com/google/uuid"
)
func CreateCheckoutOrder(grain *CartGrain, req *messages.CreateCheckoutOrder) error {
if len(grain.Items) == 0 {
return errors.New("cannot checkout empty cart")
}
if req.Terms != "accepted" {
return errors.New("terms must be accepted")
}
// Validate other fields as needed
grain.CheckoutOrderId = uuid.New().String()
grain.CheckoutStatus = "pending"
grain.CheckoutCountry = req.Country
return nil
}