fix docker and deployment
This commit is contained in:
@@ -71,6 +71,12 @@ RUN go build -trimpath -ldflags="-s -w \
|
||||
-X main.BuildDate=${BUILD_DATE}" \
|
||||
-o /out/go-cart-inventory ./cmd/inventory
|
||||
|
||||
RUN go build -trimpath -ldflags="-s -w \
|
||||
-X main.Version=${VERSION} \
|
||||
-X main.GitCommit=${GIT_COMMIT} \
|
||||
-X main.BuildDate=${BUILD_DATE}" \
|
||||
-o /out/go-checkout-actor ./cmd/checkout
|
||||
|
||||
############################
|
||||
# Runtime Stage
|
||||
############################
|
||||
@@ -79,6 +85,7 @@ FROM gcr.io/distroless/static-debian12:nonroot AS runtime
|
||||
WORKDIR /
|
||||
|
||||
COPY --from=build /out/go-cart-actor /go-cart-actor
|
||||
COPY --from=build /out/go-checkout-actor /go-checkout-actor
|
||||
COPY --from=build /out/go-cart-backoffice /go-cart-backoffice
|
||||
COPY --from=build /out/go-cart-inventory /go-cart-inventory
|
||||
|
||||
|
||||
@@ -115,9 +115,9 @@ func BuildCheckoutOrderPayload(grain *checkout.CheckoutGrain, meta *CheckoutMeta
|
||||
Terms: fmt.Sprintf("%s/terms", meta.SiteUrl),
|
||||
Checkout: fmt.Sprintf("%s/checkout?order_id={checkout.order.id}", meta.SiteUrl),
|
||||
Confirmation: fmt.Sprintf("%s/confirmation/{checkout.order.id}", meta.SiteUrl),
|
||||
Notification: "https://cart.k6n.net/notification",
|
||||
Validation: "https://cart.k6n.net/validate",
|
||||
Push: "https://cart.k6n.net/push?order_id={checkout.order.id}",
|
||||
Notification: "https://cart.k6n.net/payment/klarna/notification",
|
||||
Validation: "https://cart.k6n.net/payment/klarna/validate",
|
||||
Push: "https://cart.k6n.net/payment/klarna/push?order_id={checkout.order.id}",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ func BuildAdyenCheckoutSession(grain *checkout.CheckoutGrain, meta *CheckoutMeta
|
||||
MerchantAccount: "ElgigantenECOM",
|
||||
Channel: common.PtrString("Web"),
|
||||
ShopperIP: common.PtrString(meta.ClientIp),
|
||||
ReturnUrl: fmt.Sprintf("%s/adyen-return", meta.SiteUrl),
|
||||
ReturnUrl: fmt.Sprintf("%s/payment/adyen/return", meta.SiteUrl),
|
||||
LineItems: lineItems,
|
||||
}, nil
|
||||
|
||||
|
||||
@@ -4,14 +4,12 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.k6n.net/go-cart-actor/pkg/actor"
|
||||
"git.k6n.net/go-cart-actor/pkg/cart"
|
||||
"git.k6n.net/go-cart-actor/pkg/checkout"
|
||||
messages "git.k6n.net/go-cart-actor/proto/checkout"
|
||||
|
||||
@@ -170,6 +168,30 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CheckoutPoolServer) applyAnywhere(ctx context.Context, id uint64, msgs ...proto.Message) error {
|
||||
host, found := s.OwnerHost(id)
|
||||
if !found {
|
||||
_, err := s.Apply(ctx, id, msgs...)
|
||||
return err
|
||||
}
|
||||
_, err := host.Apply(ctx, id, msgs...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *CheckoutPoolServer) getAnywhere(ctx context.Context, id uint64) (*checkout.CheckoutGrain, error) {
|
||||
host, found := s.OwnerHost(id)
|
||||
if !found {
|
||||
grain, err := s.Get(ctx, id)
|
||||
return grain, err
|
||||
}
|
||||
ret := &checkout.CheckoutGrain{}
|
||||
err := host.Get(ctx, id, ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (s *CheckoutPoolServer) Serve(mux *http.ServeMux) {
|
||||
handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) {
|
||||
attr := attribute.String("http.route", pattern)
|
||||
@@ -190,6 +212,7 @@ func (s *CheckoutPoolServer) Serve(mux *http.ServeMux) {
|
||||
//handleFunc("/payment/adyen/cancel", s.AdyenCancelHandler)
|
||||
|
||||
handleFunc("/payment/klarna/validate", s.KlarnaValidationHandler)
|
||||
handleFunc("/payment/klarna/push", s.KlarnaPushHandler)
|
||||
handleFunc("/payment/klarna/notification", s.KlarnaNotificationHandler)
|
||||
|
||||
conn, err := amqp.Dial(amqpUrl)
|
||||
@@ -204,34 +227,4 @@ func (s *CheckoutPoolServer) Serve(mux *http.ServeMux) {
|
||||
|
||||
handleFunc("GET /confirmation/{order_id}", s.KlarnaConfirmationHandler)
|
||||
|
||||
// handleFunc("GET /checkout", s.CheckoutHandler(func(order *CheckoutOrder, w http.ResponseWriter) error {
|
||||
// w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
// w.Header().Set("Permissions-Policy", "payment=(self \"https://js.stripe.com\" \"https://m.stripe.network\" \"https://js.playground.kustom.co\")")
|
||||
// w.WriteHeader(http.StatusOK)
|
||||
// _, err := fmt.Fprintf(w, tpl, order.HTMLSnippet)
|
||||
// return err
|
||||
// }))
|
||||
|
||||
handleFunc("GET /confirmation/{order_id}", func(w http.ResponseWriter, r *http.Request) {
|
||||
orderId := r.PathValue("order_id")
|
||||
order, err := s.klarnaClient.GetOrder(r.Context(), orderId)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// Apply ConfirmationViewed to checkout
|
||||
checkoutId := checkout.CheckoutId(cart.MustNewCartId()) // Need to resolve from order
|
||||
s.Apply(r.Context(), uint64(checkoutId), &messages.ConfirmationViewed{})
|
||||
|
||||
// Callback to cart
|
||||
|
||||
// cartId := cart.CartId(checkoutId) // Assuming same
|
||||
// s.cartClient.ApplyMutation(cartId, &messages.OrderCreated{OrderId: order.ID, Status: order.Status})
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprintf(w, tpl, order.HTMLSnippet)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -396,9 +396,10 @@ spec:
|
||||
server: 10.10.1.10
|
||||
serviceAccountName: default
|
||||
containers:
|
||||
- image: registry.k6n.net/go-checkout-actor-amd64:latest
|
||||
- image: registry.k6n.net/go-cart-actor:latest
|
||||
name: checkout-actor-amd64
|
||||
imagePullPolicy: Always
|
||||
command: ["/go-checkout-actor"]
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
|
||||
Reference in New Issue
Block a user