Documentation
¶
Overview ¶
Package checkout represents abstraction of business layer checkout object
Index ¶
- Constants
- Variables
- func RegisterPaymentMethod(paymentMethod InterfacePaymentMethod) error
- func RegisterPriceAdjustment(priceAdjustment InterfacePriceAdjustment) error
- func RegisterShippingMethod(shippingMethod InterfaceShippingMethod) error
- func SetCurrentCheckout(context api.InterfaceApplicationContext, checkout InterfaceCheckout) error
- func ValidateAddress(address interface{}) (visitor.InterfaceVisitorAddress, error)
- type InterfaceCheckout
- type InterfacePaymentMethod
- type InterfacePriceAdjustment
- type InterfaceShippingMethod
- type StructPriceAdjustment
- type StructShippingRate
Constants ¶
const ( ConstCheckoutModelName = "Checkout" ConstConfigPathGroup = "general.checkout" ConstConfigPathConfirmationEmail = "general.checkout.order_confirmation_email" ConstConfigPathSendOrderConfirmEmailToMerchant = "general.checkout.send_order_confirm_email_to_merchant" ConstConfigPathOversell = "general.checkout.oversell" ConstConfigPathShippingGroup = "shipping" ConstConfigPathShippingOriginGroup = "shipping.origin" ConstConfigPathShippingOriginCountry = "shipping.origin.country" ConstConfigPathShippingOriginState = "shipping.origin.state" ConstConfigPathShippingOriginCity = "shipping.origin.city" ConstConfigPathShippingOriginAddressline1 = "shipping.origin.addressline1" ConstConfigPathShippingOriginAddressline2 = "shipping.origin.addressline2" ConstConfigPathShippingOriginZip = "shipping.origin.zip" ConstConfigPathPaymentGroup = "payment" ConstConfigPathPaymentOriginGroup = "payment.origin" ConstConfigPathPaymentOriginCountry = "payment.origin.country" ConstConfigPathPaymentOriginState = "payment.origin.state" ConstConfigPathPaymentOriginCity = "payment.origin.city" ConstConfigPathPaymentOriginAddressline1 = "payment.origin.addressline1" ConstConfigPathPaymentOriginAddressline2 = "payment.origin.addressline2" ConstConfigPathPaymentOriginZip = "payment.origin.zip" ConstPaymentActionTypeKey = "actionType" ConstPaymentActionTypeCreateToken = "createToken" ConstPaymentActionTypeUseToken = "useToken" ConstPaymentTypeSimple = "simple" ConstPaymentTypeCreditCard = "cc" ConstPaymentTypeRemote = "remote" ConstPaymentTypePost = "post" ConstPaymentTypePostCC = "post_cc" ConstPaymentErrorDeclined = "Payment declined" ConstPaymentErrorTechnical = "Technical error" ConstCalculateTargetSubtotal = 1.0 ConstCalculateTargetShipping = 2.0 ConstCalculateTargetGrandTotal = 3.0 ConstLabelSubtotal = "ST" ConstLabelShipping = "SP" ConstLabelGrandTotal = "GT" ConstLabelGiftCard = "GC" ConstLabelGiftCardAdjustment = "GCA" ConstLabelSalePriceAdjustment = "SPA" ConstLabelDiscount = "D" ConstLabelTax = "T" ConstDiscountObjectCart = "cart" ConstSessionKeyCurrentCheckout = "Checkout" ConstErrorModule = "checkout" ConstErrorLevel = env.ConstErrorLevelModel )
Package global constants
Variables ¶
var GiftCardSkuElement = "gift-card"
GiftCardSkuElement is a constant to provide a key to identify gift cards
Functions ¶
func RegisterPaymentMethod ¶
func RegisterPaymentMethod(paymentMethod InterfacePaymentMethod) error
RegisterPaymentMethod registers given payment method in system
func RegisterPriceAdjustment ¶
func RegisterPriceAdjustment(priceAdjustment InterfacePriceAdjustment) error
RegisterPriceAdjustment registers given discount calculator in system
func RegisterShippingMethod ¶
func RegisterShippingMethod(shippingMethod InterfaceShippingMethod) error
RegisterShippingMethod registers given shipping method in system
func SetCurrentCheckout ¶
func SetCurrentCheckout(context api.InterfaceApplicationContext, checkout InterfaceCheckout) error
SetCurrentCheckout assigns given checkout to current session
func ValidateAddress ¶
func ValidateAddress(address interface{}) (visitor.InterfaceVisitorAddress, error)
ValidateAddress makes checkout related address validation
Types ¶
type InterfaceCheckout ¶
type InterfaceCheckout interface {
SetShippingAddress(address visitor.InterfaceVisitorAddress) error
GetShippingAddress() visitor.InterfaceVisitorAddress
SetBillingAddress(address visitor.InterfaceVisitorAddress) error
GetBillingAddress() visitor.InterfaceVisitorAddress
SetPaymentMethod(paymentMethod InterfacePaymentMethod) error
GetPaymentMethod() InterfacePaymentMethod
SetInfo(key string, value interface{}) error
GetInfo(key string) interface{}
SetShippingMethod(shippingMethod InterfaceShippingMethod) error
GetShippingMethod() InterfaceShippingMethod
SetShippingRate(shippingRate StructShippingRate) error
GetShippingRate() *StructShippingRate
// positions in array are not equals to index used for specific total
GetItems() []cart.InterfaceCartItem
GetDiscountableItems() []cart.InterfaceCartItem
// GetItemSpecificTotal allows to obtain current item grand total
// idx - int or string of item index, 0 - cart
GetItemSpecificTotal(idx interface{}, label string) float64
GetPriceAdjustments(label string) []StructPriceAdjustment
GetTaxes() []StructPriceAdjustment
GetTaxAmount() float64
GetDiscounts() []StructPriceAdjustment
GetDiscountAmount() float64
GetSubtotal() float64
GetShippingAmount() float64
CalculateAmount(calculateTarget float64) float64
GetGrandTotal() float64
SetCart(checkoutCart cart.InterfaceCart) error
GetCart() cart.InterfaceCart
SetVisitor(checkoutVisitor visitor.InterfaceVisitor) error
GetVisitor() visitor.InterfaceVisitor
SetSession(api.InterfaceSession) error
GetSession() api.InterfaceSession
SetOrder(checkoutOrder order.InterfaceOrder) error
GetOrder() order.InterfaceOrder
CheckoutSuccess(checkoutOrder order.InterfaceOrder, session api.InterfaceSession) error
SendOrderConfirmationEmail() error
IsSubscription() bool
Submit() (interface{}, error)
SubmitFinish(map[string]interface{}) (interface{}, error)
models.InterfaceModel
models.InterfaceObject
}
InterfaceCheckout represents interface to access business layer implementation of checkout object
func GetCheckoutModel ¶
func GetCheckoutModel() (InterfaceCheckout, error)
GetCheckoutModel retrieves current InterfaceCheckout model implementation
func GetCurrentCheckout ¶
func GetCurrentCheckout(context api.InterfaceApplicationContext, bindToSession bool) (InterfaceCheckout, error)
GetCurrentCheckout returns checkout for current session or creates new one
type InterfacePaymentMethod ¶
type InterfacePaymentMethod interface {
GetCode() string
GetInternalName() string
GetName() string
GetType() string
IsAllowed(checkoutInstance InterfaceCheckout) bool
IsTokenable(checkoutInstance InterfaceCheckout) bool
Authorize(orderInstance order.InterfaceOrder, paymentInfo map[string]interface{}) (interface{}, error)
DeleteSavedCard(token visitor.InterfaceVisitorCard) (interface{}, error)
Capture(orderInstance order.InterfaceOrder, paymentInfo map[string]interface{}) (interface{}, error)
Refund(orderInstance order.InterfaceOrder, paymentInfo map[string]interface{}) (interface{}, error)
Void(orderInstance order.InterfaceOrder, paymentInfo map[string]interface{}) (interface{}, error)
}
InterfacePaymentMethod represents interface to access business layer implementation of checkout payment method
func GetPaymentMethodByCode ¶
func GetPaymentMethodByCode(code string) InterfacePaymentMethod
GetPaymentMethodByCode retrieves payment method for given unique code or nil if no payment method with such code
func GetRegisteredPaymentMethods ¶
func GetRegisteredPaymentMethods() []InterfacePaymentMethod
GetRegisteredPaymentMethods returns list of registered payment methods
type InterfacePriceAdjustment ¶
type InterfacePriceAdjustment interface {
GetName() string
GetCode() string
GetPriority() []float64
Calculate(checkoutInstance InterfaceCheckout, currentPriority float64) []StructPriceAdjustment
}
InterfacePriceAdjustment represents interface to access business layer implementation of checkout calculation elements
func GetRegisteredPriceAdjustments ¶
func GetRegisteredPriceAdjustments() []InterfacePriceAdjustment
GetRegisteredPriceAdjustments returns list of registered price adjustments
type InterfaceShippingMethod ¶
type InterfaceShippingMethod interface {
GetName() string
GetCode() string
IsAllowed(checkoutInstance InterfaceCheckout) bool
GetRates(checkoutInstance InterfaceCheckout) []StructShippingRate
GetAllRates() []StructShippingRate
}
InterfaceShippingMethod represents interface to access business layer implementation of checkout shipping method
func GetRegisteredShippingMethods ¶
func GetRegisteredShippingMethods() []InterfaceShippingMethod
GetRegisteredShippingMethods returns list of registered shipping methods
func GetShippingMethodByCode ¶
func GetShippingMethodByCode(code string) InterfaceShippingMethod
GetShippingMethodByCode retrieves shipping method for given unique code or nil if no shipping method with such code
type StructPriceAdjustment ¶
type StructPriceAdjustment struct {
Code string `json:"Code"`
Name string `json:"Name"`
Priority float64 `json:"Priority"`
Amount float64 `json:"Amount"`
IsPercent bool `json:"IsPercent,bool"`
Labels []string `json:"Labels"`
PerItem map[string]float64 `json:"PerItem,string"`
}
StructPriceAdjustment represents type to hold information generated by implementation of InterfacePriceAdjustment (calculating entities of checkout)
type StructShippingRate ¶
StructShippingRate represents type to hold shipping rate information generated by implementation of InterfaceShippingMethod