strange
This commit is contained in:
@@ -279,11 +279,6 @@ func (s *CheckoutPoolServer) WriteResult(w http.ResponseWriter, result any) erro
|
||||
}
|
||||
|
||||
func (s *CheckoutPoolServer) CreateOrUpdateCheckout(r *http.Request, grain *checkout.CheckoutGrain, orderId *string) (*CheckoutOrder, error) {
|
||||
// Get cart state from cart service
|
||||
// cartGrain, err := s.Get(r.Context(), uint64(id))
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
meta := GetCheckoutMetaFromRequest(r)
|
||||
|
||||
@@ -292,10 +287,6 @@ func (s *CheckoutPoolServer) CreateOrUpdateCheckout(r *http.Request, grain *chec
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// grain, err := s.Get(r.Context(), uint64(id))
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
var payment *checkout.Payment
|
||||
if orderId != nil {
|
||||
payment, _ = grain.FindPayment(*orderId)
|
||||
@@ -320,26 +311,6 @@ func (s *CheckoutPoolServer) ApplyKlarnaPaymentStarted(ctx context.Context, klar
|
||||
})
|
||||
}
|
||||
|
||||
// func (s *CheckoutPoolServer) CheckoutHandler(fn func(order *CheckoutOrder, w http.ResponseWriter) error) func(w http.ResponseWriter, r *http.Request) {
|
||||
// return CheckoutIdHandler(s.ProxyHandler(func(w http.ResponseWriter, r *http.Request, checkoutId checkout.CheckoutId) error {
|
||||
// orderId := r.URL.Query().Get("order_id")
|
||||
// if orderId == "" {
|
||||
// order, err := s.CreateOrUpdateCheckout(r, checkoutId)
|
||||
// if err != nil {
|
||||
// logger.Error("unable to create klarna session", "error", err)
|
||||
// return err
|
||||
// }
|
||||
// s.ApplyKlarnaPaymentStarted(r.Context(), order, checkoutId)
|
||||
// return fn(order, w)
|
||||
// }
|
||||
// order, err := s.klarnaClient.GetOrder(r.Context(), orderId)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// return fn(order, w)
|
||||
// }))
|
||||
// }
|
||||
|
||||
var (
|
||||
tracer = otel.Tracer(name)
|
||||
hmacKey = os.Getenv("ADYEN_HMAC")
|
||||
@@ -415,6 +386,19 @@ func (s *CheckoutPoolServer) GetPaymentSessionHandler(w http.ResponseWriter, r *
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if res.Status != nil && *res.Status == "completed" {
|
||||
_, err := s.ApplyLocal(r.Context(), checkoutId, &messages.PaymentCompleted{
|
||||
PaymentId: paymentId,
|
||||
Status: *res.Status,
|
||||
ProcessorReference: res.Id,
|
||||
CompletedAt: timestamppb.Now(),
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("unable to apply payment started mutation", "error", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return s.WriteResult(w, res)
|
||||
case "klarna":
|
||||
current, err := s.klarnaClient.GetOrder(r.Context(), paymentId)
|
||||
|
||||
Reference in New Issue
Block a user