klarna and checkouts
Build and Publish / BuildAndDeployAmd64 (push) Failing after 4s
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s

This commit is contained in:
2026-06-26 15:41:55 +02:00
parent c0c5a8bc0f
commit 0252893de5
3 changed files with 71 additions and 24 deletions
+11 -7
View File
@@ -183,16 +183,20 @@ func (s *CheckoutPoolServer) KlarnaPushHandler(w http.ResponseWriter, r *http.Re
if s.inventoryService != nil {
inventoryRequests := getInventoryRequests(grain.CartState.Items)
err = s.inventoryService.ReserveInventory(r.Context(), inventoryRequests...)
if err != nil {
logger.WarnContext(r.Context(), "placeorder inventory reservation failed")
w.WriteHeader(http.StatusNotAcceptable)
return
invStatus := "success"
if err = s.inventoryService.ReserveInventory(r.Context(), inventoryRequests...); err != nil {
// The payment is already settled at Klarna (checkout_complete), so the
// order MUST be created. Inventory is best-effort at this point — a
// reservation failure (unstocked / drop-ship / non-tracked items)
// must not block order creation. Log it and flag the grain so
// fulfillment can reconcile.
logger.WarnContext(r.Context(), "klarna push: inventory reservation failed; creating order anyway",
"err", err, "checkoutId", grain.Id.String())
invStatus = "failed"
}
s.Apply(r.Context(), uint64(grain.Id), &messages.InventoryReserved{
Id: grain.Id.String(),
Status: "success",
Status: invStatus,
})
}