update
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 44s
Build and Publish / BuildAndDeployArm64 (push) Successful in 5m3s

This commit is contained in:
matst80
2025-11-20 21:20:35 +01:00
parent 1c8e9cc974
commit 60cd6cfd51
21 changed files with 1432 additions and 203 deletions

View File

@@ -0,0 +1,21 @@
package cart
import (
"errors"
"github.com/google/uuid"
messages "git.tornberg.me/go-cart-actor/pkg/messages"
)
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
}