Documentation ¶
Overview ¶
Package checkout is a default implementation of interfaces declared in "github.com/ottemo/commerce/app/models/checkout" package
Index ¶
- Constants
- func APIGetCheckout(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetPaymentMethods(context api.InterfaceApplicationContext) (interface{}, error)
- func APIGetShippingMethods(context api.InterfaceApplicationContext) (interface{}, error)
- func APISetBillingAddress(context api.InterfaceApplicationContext) (interface{}, error)
- func APISetCheckoutInfo(context api.InterfaceApplicationContext) (interface{}, error)
- func APISetPaymentMethod(context api.InterfaceApplicationContext) (interface{}, error)
- func APISetShippingAddress(context api.InterfaceApplicationContext) (interface{}, error)
- func APISetShippingMethod(context api.InterfaceApplicationContext) (interface{}, error)
- func APISubmitCheckout(context api.InterfaceApplicationContext) (interface{}, error)
- type DefaultCheckout
- func (it *DefaultCheckout) CalculateAmount(calculateTarget float64) float64
- func (it *DefaultCheckout) CheckoutSuccess(checkoutOrder order.InterfaceOrder, session api.InterfaceSession) error
- func (it *DefaultCheckout) FromHashMap(input map[string]interface{}) error
- func (it *DefaultCheckout) Get(attribute string) interface{}
- func (it *DefaultCheckout) GetAttributesInfo() []models.StructAttributeInfo
- func (it *DefaultCheckout) GetBillingAddress() visitor.InterfaceVisitorAddress
- func (it *DefaultCheckout) GetCart() cart.InterfaceCart
- func (it *DefaultCheckout) GetDiscountAmount() float64
- func (it *DefaultCheckout) GetDiscountableItems() []cart.InterfaceCartItem
- func (it *DefaultCheckout) GetDiscounts() []checkout.StructPriceAdjustment
- func (it *DefaultCheckout) GetGrandTotal() float64
- func (it *DefaultCheckout) GetImplementationName() string
- func (it *DefaultCheckout) GetInfo(key string) interface{}
- func (it *DefaultCheckout) GetItemSpecificTotal(idx interface{}, label string) float64
- func (it *DefaultCheckout) GetItems() []cart.InterfaceCartItem
- func (it *DefaultCheckout) GetModelName() string
- func (it *DefaultCheckout) GetOrder() order.InterfaceOrder
- func (it *DefaultCheckout) GetPaymentMethod() checkout.InterfacePaymentMethod
- func (it *DefaultCheckout) GetPriceAdjustments(label string) []checkout.StructPriceAdjustment
- func (it *DefaultCheckout) GetSession() api.InterfaceSession
- func (it *DefaultCheckout) GetShippingAddress() visitor.InterfaceVisitorAddress
- func (it *DefaultCheckout) GetShippingAmount() float64
- func (it *DefaultCheckout) GetShippingMethod() checkout.InterfaceShippingMethod
- func (it *DefaultCheckout) GetShippingRate() *checkout.StructShippingRate
- func (it *DefaultCheckout) GetSubtotal() float64
- func (it *DefaultCheckout) GetTaxAmount() float64
- func (it *DefaultCheckout) GetTaxes() []checkout.StructPriceAdjustment
- func (it *DefaultCheckout) GetVisitor() visitor.InterfaceVisitor
- func (it *DefaultCheckout) IsSubscription() bool
- func (it *DefaultCheckout) New() (models.InterfaceModel, error)
- func (it *DefaultCheckout) SendOrderConfirmationEmail() error
- func (it *DefaultCheckout) Set(attribute string, value interface{}) error
- func (it *DefaultCheckout) SetBillingAddress(address visitor.InterfaceVisitorAddress) error
- func (it *DefaultCheckout) SetCart(checkoutCart cart.InterfaceCart) error
- func (it *DefaultCheckout) SetInfo(key string, value interface{}) error
- func (it *DefaultCheckout) SetOrder(checkoutOrder order.InterfaceOrder) error
- func (it *DefaultCheckout) SetPaymentMethod(paymentMethod checkout.InterfacePaymentMethod) error
- func (it *DefaultCheckout) SetSession(checkoutSession api.InterfaceSession) error
- func (it *DefaultCheckout) SetShippingAddress(address visitor.InterfaceVisitorAddress) error
- func (it *DefaultCheckout) SetShippingMethod(shippingMethod checkout.InterfaceShippingMethod) error
- func (it *DefaultCheckout) SetShippingRate(shippingRate checkout.StructShippingRate) error
- func (it *DefaultCheckout) SetVisitor(checkoutVisitor visitor.InterfaceVisitor) error
- func (it *DefaultCheckout) Submit() (interface{}, error)
- func (it *DefaultCheckout) SubmitFinish(paymentInfo map[string]interface{}) (interface{}, error)
- func (it *DefaultCheckout) ToHashMap() map[string]interface{}
Constants ¶
const ( ConstErrorModule = "checkout" ConstErrorLevel = env.ConstErrorLevelActor )
Package global constants
Variables ¶
This section is empty.
Functions ¶
func APIGetCheckout ¶
func APIGetCheckout(context api.InterfaceApplicationContext) (interface{}, error)
APIGetCheckout returns information related to current checkkout
func APIGetPaymentMethods ¶
func APIGetPaymentMethods(context api.InterfaceApplicationContext) (interface{}, error)
APIGetPaymentMethods returns currently available payment methods
func APIGetShippingMethods ¶
func APIGetShippingMethods(context api.InterfaceApplicationContext) (interface{}, error)
APIGetShippingMethods returns currently available shipping methods
func APISetBillingAddress ¶
func APISetBillingAddress(context api.InterfaceApplicationContext) (interface{}, error)
APISetBillingAddress specifies billing address for a current checkout
func APISetCheckoutInfo ¶
func APISetCheckoutInfo(context api.InterfaceApplicationContext) (interface{}, error)
APISetCheckoutInfo allows to specify and assign to checkout extra information
func APISetPaymentMethod ¶
func APISetPaymentMethod(context api.InterfaceApplicationContext) (interface{}, error)
APISetPaymentMethod assigns payment method to current checkout
- "method" argument specifies requested payment method (it should be available for a meaning time)
func APISetShippingAddress ¶
func APISetShippingAddress(context api.InterfaceApplicationContext) (interface{}, error)
APISetShippingAddress specifies shipping address for a current checkout
func APISetShippingMethod ¶
func APISetShippingMethod(context api.InterfaceApplicationContext) (interface{}, error)
APISetShippingMethod assigns shipping method and shipping rate to current checkout
- "method" argument specifies requested shipping method (it should be available for a meaning time)
- "rate" argument specifies requested shipping rate (it should be available and belongs to shipping method)
func APISubmitCheckout ¶
func APISubmitCheckout(context api.InterfaceApplicationContext) (interface{}, error)
APISubmitCheckout submits current checkout and creates a new order base on it
Types ¶
type DefaultCheckout ¶
type DefaultCheckout struct { CartID string VisitorID string OrderID string SessionID string ShippingAddress map[string]interface{} BillingAddress map[string]interface{} PaymentMethodCode string ShippingMethodCode string ShippingRate checkout.StructShippingRate Info map[string]interface{} // contains filtered or unexported fields }
DefaultCheckout is a default implementer of InterfaceCheckout
func (*DefaultCheckout) CalculateAmount ¶
func (it *DefaultCheckout) CalculateAmount(calculateTarget float64) float64
CalculateAmount do a calculation of all amounts for checkout TODO: make function use calculateTarget as a limit for priority to where it need to be calculated
func (*DefaultCheckout) CheckoutSuccess ¶
func (it *DefaultCheckout) CheckoutSuccess(checkoutOrder order.InterfaceOrder, session api.InterfaceSession) error
CheckoutSuccess will save the order and clear the shopping in the session.
func (*DefaultCheckout) FromHashMap ¶
func (it *DefaultCheckout) FromHashMap(input map[string]interface{}) error
FromHashMap fills object attributes from map[string]interface{}
func (*DefaultCheckout) Get ¶
func (it *DefaultCheckout) Get(attribute string) interface{}
Get returns object attribute value or nil
func (*DefaultCheckout) GetAttributesInfo ¶
func (it *DefaultCheckout) GetAttributesInfo() []models.StructAttributeInfo
GetAttributesInfo returns information about object attributes
func (*DefaultCheckout) GetBillingAddress ¶
func (it *DefaultCheckout) GetBillingAddress() visitor.InterfaceVisitorAddress
GetBillingAddress returns checkout billing address
func (*DefaultCheckout) GetCart ¶
func (it *DefaultCheckout) GetCart() cart.InterfaceCart
GetCart returns a shopping cart
func (*DefaultCheckout) GetDiscountAmount ¶
func (it *DefaultCheckout) GetDiscountAmount() float64
GetDiscountAmount returns total amount of discounts applied for current checkout
func (*DefaultCheckout) GetDiscountableItems ¶
func (it *DefaultCheckout) GetDiscountableItems() []cart.InterfaceCartItem
GetDiscountableItems returns current cart items that can be discounted (not a gift cards)
func (*DefaultCheckout) GetDiscounts ¶
func (it *DefaultCheckout) GetDiscounts() []checkout.StructPriceAdjustment
GetDiscounts collects discounts applied for current checkout
func (*DefaultCheckout) GetGrandTotal ¶
func (it *DefaultCheckout) GetGrandTotal() float64
GetGrandTotal returns grand total for current checkout
func (*DefaultCheckout) GetImplementationName ¶
func (it *DefaultCheckout) GetImplementationName() string
GetImplementationName returns name of current model implementation
func (*DefaultCheckout) GetInfo ¶
func (it *DefaultCheckout) GetInfo(key string) interface{}
GetInfo returns additional checkout info value or nil,
- use "*" as a key to get all keys and values currently set
func (*DefaultCheckout) GetItemSpecificTotal ¶
func (it *DefaultCheckout) GetItemSpecificTotal(idx interface{}, label string) float64
GetItemSpecificTotal return current amount value for given item index and label (0 is a cart)
func (*DefaultCheckout) GetItems ¶
func (it *DefaultCheckout) GetItems() []cart.InterfaceCartItem
GetItems returns current cart items
func (*DefaultCheckout) GetModelName ¶
func (it *DefaultCheckout) GetModelName() string
GetModelName returns model name we have implementation for
func (*DefaultCheckout) GetOrder ¶
func (it *DefaultCheckout) GetOrder() order.InterfaceOrder
GetOrder returns current checkout related order or nil if not created yet
func (*DefaultCheckout) GetPaymentMethod ¶
func (it *DefaultCheckout) GetPaymentMethod() checkout.InterfacePaymentMethod
GetPaymentMethod returns checkout payment method
func (*DefaultCheckout) GetPriceAdjustments ¶
func (it *DefaultCheckout) GetPriceAdjustments(label string) []checkout.StructPriceAdjustment
GetPriceAdjustments collects price adjustments applied for current checkout
func (*DefaultCheckout) GetSession ¶
func (it *DefaultCheckout) GetSession() api.InterfaceSession
GetSession return checkout session
func (*DefaultCheckout) GetShippingAddress ¶
func (it *DefaultCheckout) GetShippingAddress() visitor.InterfaceVisitorAddress
GetShippingAddress returns checkout shipping address
func (*DefaultCheckout) GetShippingAmount ¶
func (it *DefaultCheckout) GetShippingAmount() float64
GetShippingAmount returns shipping price for current checkout
func (*DefaultCheckout) GetShippingMethod ¶
func (it *DefaultCheckout) GetShippingMethod() checkout.InterfaceShippingMethod
GetShippingMethod returns a checkout shipping method
func (*DefaultCheckout) GetShippingRate ¶
func (it *DefaultCheckout) GetShippingRate() *checkout.StructShippingRate
GetShippingRate returns a checkout shipping rate
func (*DefaultCheckout) GetSubtotal ¶
func (it *DefaultCheckout) GetSubtotal() float64
GetSubtotal returns subtotal total for current checkout
func (*DefaultCheckout) GetTaxAmount ¶
func (it *DefaultCheckout) GetTaxAmount() float64
GetTaxAmount returns total amount of taxes for current checkout
func (*DefaultCheckout) GetTaxes ¶
func (it *DefaultCheckout) GetTaxes() []checkout.StructPriceAdjustment
GetTaxes collects taxes applied for current checkout
func (*DefaultCheckout) GetVisitor ¶
func (it *DefaultCheckout) GetVisitor() visitor.InterfaceVisitor
GetVisitor return checkout visitor
func (*DefaultCheckout) IsSubscription ¶
func (it *DefaultCheckout) IsSubscription() bool
IsSubscription provide a flag if there subscription items in it
func (*DefaultCheckout) New ¶
func (it *DefaultCheckout) New() (models.InterfaceModel, error)
New makes new instance of model
func (*DefaultCheckout) SendOrderConfirmationEmail ¶
func (it *DefaultCheckout) SendOrderConfirmationEmail() error
SendOrderConfirmationEmail sends an order confirmation email
func (*DefaultCheckout) Set ¶
func (it *DefaultCheckout) Set(attribute string, value interface{}) error
Set sets attribute value to object or returns error
func (*DefaultCheckout) SetBillingAddress ¶
func (it *DefaultCheckout) SetBillingAddress(address visitor.InterfaceVisitorAddress) error
SetBillingAddress sets billing address for checkout
func (*DefaultCheckout) SetCart ¶
func (it *DefaultCheckout) SetCart(checkoutCart cart.InterfaceCart) error
SetCart sets cart for checkout
func (*DefaultCheckout) SetInfo ¶
func (it *DefaultCheckout) SetInfo(key string, value interface{}) error
SetInfo sets additional info for checkout - any values related to checkout process
func (*DefaultCheckout) SetOrder ¶
func (it *DefaultCheckout) SetOrder(checkoutOrder order.InterfaceOrder) error
SetOrder sets order for current checkout
func (*DefaultCheckout) SetPaymentMethod ¶
func (it *DefaultCheckout) SetPaymentMethod(paymentMethod checkout.InterfacePaymentMethod) error
SetPaymentMethod sets payment method for checkout
func (*DefaultCheckout) SetSession ¶
func (it *DefaultCheckout) SetSession(checkoutSession api.InterfaceSession) error
SetSession sets visitor for checkout
func (*DefaultCheckout) SetShippingAddress ¶
func (it *DefaultCheckout) SetShippingAddress(address visitor.InterfaceVisitorAddress) error
SetShippingAddress sets shipping address for checkout
func (*DefaultCheckout) SetShippingMethod ¶
func (it *DefaultCheckout) SetShippingMethod(shippingMethod checkout.InterfaceShippingMethod) error
SetShippingMethod sets payment method for checkout
func (*DefaultCheckout) SetShippingRate ¶
func (it *DefaultCheckout) SetShippingRate(shippingRate checkout.StructShippingRate) error
SetShippingRate sets shipping rate for checkout
func (*DefaultCheckout) SetVisitor ¶
func (it *DefaultCheckout) SetVisitor(checkoutVisitor visitor.InterfaceVisitor) error
SetVisitor sets visitor for checkout
func (*DefaultCheckout) Submit ¶
func (it *DefaultCheckout) Submit() (interface{}, error)
Submit creates the order with provided information
func (*DefaultCheckout) SubmitFinish ¶
func (it *DefaultCheckout) SubmitFinish(paymentInfo map[string]interface{}) (interface{}, error)
SubmitFinish finishes processing of submit (required for payment methods to finish with this call?)
func (*DefaultCheckout) ToHashMap ¶
func (it *DefaultCheckout) ToHashMap() map[string]interface{}
ToHashMap represents object as map[string]interface{}