test
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 42s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m52s

This commit is contained in:
matst80
2025-12-04 17:42:51 +01:00
parent fccb0eed06
commit ce81e294f2
2 changed files with 35 additions and 42 deletions

View File

@@ -24,46 +24,40 @@ import (
) )
type SessionRequest struct { type SessionRequest struct {
SessionId string `json:"sessionId"` SessionId *string `json:"sessionId,omitempty"`
SessionResult string `json:"sessionResult"` SessionResult string `json:"sessionResult"`
SessionData string `json:"sessionData,omitempty"` SessionData *string `json:"sessionData,omitempty"`
} }
func (s *CheckoutPoolServer) AdyenSessionHandler(w http.ResponseWriter, r *http.Request, cartId cart.CartId) error { // func (s *CheckoutPoolServer) AdyenSessionHandler(w http.ResponseWriter, r *http.Request, cartId cart.CartId) error {
grain, err := s.Get(r.Context(), uint64(cartId)) // grain, err := s.Get(r.Context(), uint64(cartId))
if err != nil { // if err != nil {
return err // return err
} // }
if r.Method == http.MethodGet { // if r.Method == http.MethodGet {
meta := GetCheckoutMetaFromRequest(r) // service := s.adyenClient.Checkout()
sessionData, err := BuildAdyenCheckoutSession(grain, meta) // req := service.PaymentsApi.GetResultOfPaymentSessionInput(pa).SessionResult(payload.SessionResult)
if err != nil { // res, _, err := service.PaymentsApi.GetResultOfPaymentSession(r.Context(), req)
return err // if err != nil {
} // return err
service := s.adyenClient.Checkout() // }
req := service.PaymentsApi.SessionsInput().CreateCheckoutSessionRequest(*sessionData) // return s.WriteResult(w, res)
res, _, err := service.PaymentsApi.Sessions(r.Context(), req) // } else {
// apply checkout started // payload := &SessionRequest{}
if err != nil { // if err := json.NewDecoder(r.Body).Decode(payload); err != nil {
return err // return err
} // }
return s.WriteResult(w, res) // service := s.adyenClient.Checkout()
} else { // req := service.PaymentsApi.GetResultOfPaymentSessionInput(payload.SessionId).SessionResult(payload.SessionResult)
payload := &SessionRequest{} // res, _, err := service.PaymentsApi.GetResultOfPaymentSession(r.Context(), req)
if err := json.NewDecoder(r.Body).Decode(payload); err != nil { // if err != nil {
return err // return err
} // }
service := s.adyenClient.Checkout() // return s.WriteResult(w, res)
req := service.PaymentsApi.GetResultOfPaymentSessionInput(payload.SessionId).SessionResult(payload.SessionResult) // }
res, _, err := service.PaymentsApi.GetResultOfPaymentSession(r.Context(), req)
if err != nil {
return err
}
return s.WriteResult(w, res)
}
} // }
func getCheckoutIdFromNotificationItem(item webhook.NotificationRequestItem) (uint64, error) { func getCheckoutIdFromNotificationItem(item webhook.NotificationRequestItem) (uint64, error) {
cartId, ok := cart.ParseCartId(item.MerchantReference) cartId, ok := cart.ParseCartId(item.MerchantReference)

View File

@@ -400,18 +400,17 @@ func (s *CheckoutPoolServer) GetPaymentSessionHandler(w http.ResponseWriter, r *
} }
switch payment.Provider { switch payment.Provider {
case "adyen": case "adyen":
var payload *SessionRequest payload := &SessionRequest{
SessionResult: "",
}
if r.Method != http.MethodGet { if r.Method != http.MethodGet {
payload = &SessionRequest{}
if err := json.NewDecoder(r.Body).Decode(payload); err != nil { if err := json.NewDecoder(r.Body).Decode(payload); err != nil {
return err return err
} }
} }
service := s.adyenClient.Checkout() service := s.adyenClient.Checkout()
req := service.PaymentsApi.GetResultOfPaymentSessionInput(paymentId) req := service.PaymentsApi.GetResultOfPaymentSessionInput(paymentId).SessionResult(payload.SessionResult)
if payload != nil {
req = req.SessionResult(payload.SessionResult)
}
res, _, err := service.PaymentsApi.GetResultOfPaymentSession(r.Context(), req) res, _, err := service.PaymentsApi.GetResultOfPaymentSession(r.Context(), req)
if err != nil { if err != nil {
return err return err