test
This commit is contained in:
@@ -24,46 +24,40 @@ import (
|
||||
)
|
||||
|
||||
type SessionRequest struct {
|
||||
SessionId string `json:"sessionId"`
|
||||
SessionResult string `json:"sessionResult"`
|
||||
SessionData string `json:"sessionData,omitempty"`
|
||||
SessionId *string `json:"sessionId,omitempty"`
|
||||
SessionResult string `json:"sessionResult"`
|
||||
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))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if r.Method == http.MethodGet {
|
||||
meta := GetCheckoutMetaFromRequest(r)
|
||||
sessionData, err := BuildAdyenCheckoutSession(grain, meta)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
service := s.adyenClient.Checkout()
|
||||
req := service.PaymentsApi.SessionsInput().CreateCheckoutSessionRequest(*sessionData)
|
||||
res, _, err := service.PaymentsApi.Sessions(r.Context(), req)
|
||||
// apply checkout started
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.WriteResult(w, res)
|
||||
} else {
|
||||
payload := &SessionRequest{}
|
||||
if err := json.NewDecoder(r.Body).Decode(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
service := s.adyenClient.Checkout()
|
||||
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)
|
||||
}
|
||||
// grain, err := s.Get(r.Context(), uint64(cartId))
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// if r.Method == http.MethodGet {
|
||||
// service := s.adyenClient.Checkout()
|
||||
// req := service.PaymentsApi.GetResultOfPaymentSessionInput(pa).SessionResult(payload.SessionResult)
|
||||
// res, _, err := service.PaymentsApi.GetResultOfPaymentSession(r.Context(), req)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// return s.WriteResult(w, res)
|
||||
// } else {
|
||||
// payload := &SessionRequest{}
|
||||
// if err := json.NewDecoder(r.Body).Decode(payload); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// service := s.adyenClient.Checkout()
|
||||
// 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) {
|
||||
cartId, ok := cart.ParseCartId(item.MerchantReference)
|
||||
|
||||
@@ -400,18 +400,17 @@ func (s *CheckoutPoolServer) GetPaymentSessionHandler(w http.ResponseWriter, r *
|
||||
}
|
||||
switch payment.Provider {
|
||||
case "adyen":
|
||||
var payload *SessionRequest
|
||||
payload := &SessionRequest{
|
||||
SessionResult: "",
|
||||
}
|
||||
if r.Method != http.MethodGet {
|
||||
payload = &SessionRequest{}
|
||||
if err := json.NewDecoder(r.Body).Decode(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
service := s.adyenClient.Checkout()
|
||||
req := service.PaymentsApi.GetResultOfPaymentSessionInput(paymentId)
|
||||
if payload != nil {
|
||||
req = req.SessionResult(payload.SessionResult)
|
||||
}
|
||||
req := service.PaymentsApi.GetResultOfPaymentSessionInput(paymentId).SessionResult(payload.SessionResult)
|
||||
|
||||
res, _, err := service.PaymentsApi.GetResultOfPaymentSession(r.Context(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user