controller

package
v3.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CheckoutErrorFlashKey is the flash key that stores error infos that are shown on the checkout form page
	CheckoutErrorFlashKey = "checkout.error.data"
	// CheckoutSuccessFlashKey is the flash key that stores the order infos which are used on the checkout success page
	CheckoutSuccessFlashKey = "checkout.success.data"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIController added in v3.3.0

type APIController struct {
	// contains filtered or unexported fields
}

APIController for checkout rest api

func (*APIController) CancelPlaceOrderAction added in v3.3.0

func (c *APIController) CancelPlaceOrderAction(ctx context.Context, r *web.Request) web.Result

CancelPlaceOrderAction cancels a running place order process @Summary Cancels a running place order process @Tags Checkout @Produce json @Success 200 {boolean} boolean @Failure 500 {object} errorResponse @Router /api/v1/checkout/placeorder/cancel [post]

func (*APIController) ClearPlaceOrderAction added in v3.3.0

func (c *APIController) ClearPlaceOrderAction(ctx context.Context, r *web.Request) web.Result

ClearPlaceOrderAction clears the last place order if in final state @Summary Clears the last placed order if in final state @Tags Checkout @Produce json @Success 200 {boolean} boolean @Failure 500 {object} errorResponse @Router /api/v1/checkout/placeorder [delete]

func (*APIController) CurrentPlaceOrderContextAction added in v3.3.0

func (c *APIController) CurrentPlaceOrderContextAction(ctx context.Context, _ *web.Request) web.Result

CurrentPlaceOrderContextAction returns the last saved context @Summary Returns the last saved context @Tags Checkout @Produce json @Success 200 {object} placeOrderContext @Failure 500 {object} errorResponse @Router /api/v1/checkout/placeorder [get]

func (*APIController) Inject added in v3.3.0

func (c *APIController) Inject(
	responder *web.Responder,
	placeorderHandler *placeorder.Handler,
	cartService *cartApplication.CartService,
	decoratedCartFactory *decorator.DecoratedCartFactory,
	logger flamingo.Logger,
)

Inject dependencies

func (*APIController) RefreshPlaceOrderAction added in v3.3.0

func (c *APIController) RefreshPlaceOrderAction(ctx context.Context, _ *web.Request) web.Result

RefreshPlaceOrderAction returns the current place order context and proceeds the process in a non blocking way @Summary Returns the current place order context and proceeds the process in a non blocking way @Tags Checkout @Produce json @Success 200 {object} placeOrderContext @Failure 500 {object} errorResponse @Router /api/v1/checkout/placeorder/refresh [post]

func (*APIController) RefreshPlaceOrderBlockingAction added in v3.3.0

func (c *APIController) RefreshPlaceOrderBlockingAction(ctx context.Context, _ *web.Request) web.Result

RefreshPlaceOrderBlockingAction proceeds the process and returns the place order context afterwards (blocking) @Summary Proceeds the process and returns the place order context afterwards (blocking) @Description This is useful to get the most recent place order context, for example after returning from an external payment provider @Tags Checkout @Produce json @Success 200 {object} placeOrderContext @Failure 500 {object} errorResponse @Router /api/v1/checkout/placeorder/refresh-blocking [post]

func (*APIController) StartPlaceOrderAction added in v3.3.0

func (c *APIController) StartPlaceOrderAction(ctx context.Context, r *web.Request) web.Result

StartPlaceOrderAction starts a new process @Summary Starts the place order process, which is a background process handling payment and rollbacks if required. @Tags Checkout @Produce json @Success 201 {object} startPlaceOrderResult "201 if new process was started" @Failure 500 {object} errorResponse @Failure 400 {object} errorResponse @Param returnURL query string true "the returnURL that should be used after an external payment flow" @Router /api/v1/checkout/placeorder [put]

type CheckoutController

type CheckoutController struct {
	// contains filtered or unexported fields
}

CheckoutController represents the checkout controller with its injections

func (*CheckoutController) ExpiredAction

func (cc *CheckoutController) ExpiredAction(ctx context.Context, _ *web.Request) web.Result

ExpiredAction handles the expired cart action

func (*CheckoutController) Inject

func (cc *CheckoutController) Inject(
	responder *web.Responder,
	router *web.Router,
	orderService *application.OrderService,
	decoratedCartFactory *decorator.DecoratedCartFactory,
	applicationCartService *cartApplication.CartService,
	applicationCartReceiverService *cartApplication.CartReceiverService,
	webIdentityService *auth.WebIdentityService,
	logger flamingo.Logger,
	checkoutFormController *forms.CheckoutFormController,
	config *struct {
		SkipStartAction                 bool `inject:"config:commerce.checkout.skipStartAction,optional"`
		SkipReviewAction                bool `inject:"config:commerce.checkout.skipReviewAction,optional"`
		ShowReviewStepAfterPaymentError bool `inject:"config:commerce.checkout.showReviewStepAfterPaymentError,optional"`
		ShowEmptyCartPageIfNoItems      bool `inject:"config:commerce.checkout.showEmptyCartPageIfNoItems,optional"`
		RedirectToCartOnInvalideCart    bool `inject:"config:commerce.checkout.redirectToCartOnInvalidCart,optional"`
		PrivacyPolicyRequired           bool `inject:"config:commerce.checkout.privacyPolicyRequired,optional"`
		DevMode                         bool `inject:"config:debug.mode,optional"`
	},
)

Inject dependencies

func (*CheckoutController) PaymentAction

func (cc *CheckoutController) PaymentAction(ctx context.Context, r *web.Request) web.Result

PaymentAction asks the payment adapter about the current payment status and handle it

func (*CheckoutController) PlaceOrderAction

func (cc *CheckoutController) PlaceOrderAction(ctx context.Context, r *web.Request) web.Result

PlaceOrderAction functions as a return/notification URL for Payment Providers

func (*CheckoutController) ReviewAction

func (cc *CheckoutController) ReviewAction(ctx context.Context, r *web.Request) web.Result

ReviewAction handles the cart review action

func (*CheckoutController) StartAction

func (cc *CheckoutController) StartAction(ctx context.Context, r *web.Request) web.Result

StartAction handles the checkout start action

func (*CheckoutController) SubmitCheckoutAction

func (cc *CheckoutController) SubmitCheckoutAction(ctx context.Context, r *web.Request) web.Result

SubmitCheckoutAction handles the main checkout

func (*CheckoutController) SuccessAction

func (cc *CheckoutController) SuccessAction(ctx context.Context, r *web.Request) web.Result

SuccessAction handles the order success action

type CheckoutViewData

type CheckoutViewData struct {
	DecoratedCart        decorator.DecoratedCart
	Form                 forms.CheckoutFormComposite
	CartValidationResult validation.Result
	ErrorInfos           ViewErrorInfos
	AvailablePayments    map[string][]paymentDomain.Method
	CustomerLoggedIn     bool
}

CheckoutViewData represents the checkout view data

type EmptyCartInfo

type EmptyCartInfo struct {
	CartExpired bool
}

EmptyCartInfo struct defines the data info on empty carts

type PaymentStepViewData

type PaymentStepViewData struct {
	FlowStatus paymentDomain.FlowStatus
	ErrorInfos ViewErrorInfos
}

PaymentStepViewData represents the payment flow view data

type PlaceOrderFlashData

type PlaceOrderFlashData struct {
	PlacedOrderInfos placeorder.PlacedOrderInfos
	Email            string
	PaymentInfos     []application.PlaceOrderPaymentInfo
	PlacedCart       cart.Cart
}

PlaceOrderFlashData represents the data passed to the success page - they need to be "glob"able

type ReviewStepViewData

type ReviewStepViewData struct {
	DecoratedCart decorator.DecoratedCart
	ErrorInfos    ViewErrorInfos
}

ReviewStepViewData represents the success view data

type SuccessViewData

type SuccessViewData struct {
	PaymentInfos        []application.PlaceOrderPaymentInfo
	PlacedOrderInfos    placeorder.PlacedOrderInfos
	Email               string
	PlacedDecoratedCart decorator.DecoratedCart
}

SuccessViewData represents the success view data

type ViewErrorInfos

type ViewErrorInfos struct {
	// HasError  indicates that an general error happened
	HasError bool
	// If there is a general error this field is filled and can be used in the template
	ErrorMessage string
	// if the Error happens during processing payment (can be used in template to behave special in case of payment errors)
	HasPaymentError bool
	// if payment error occurred holds additional infos
	PaymentErrorCode string
}

ViewErrorInfos defines the error info struct of the checkout controller views

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL