Documentation ¶
Index ¶
- Constants
- Variables
- type AddRequest
- type AdditionalData
- type AdditionalDeliverInfo
- type Address
- type AppliedCouponCodes
- type AppliedDiscount
- type AppliedDiscounts
- type AppliedGiftCard
- type AppliedGiftCards
- type Builder
- func (b *Builder) AddAppliedCouponCode(code CouponCode) *Builder
- func (b *Builder) AddDelivery(d Delivery) *Builder
- func (b *Builder) AddTotalitem(totali Totalitem) *Builder
- func (b *Builder) Build() (*Cart, error)
- func (b *Builder) SetAdditionalData(d AdditionalData) *Builder
- func (b *Builder) SetAppliedGiftCards(gc []AppliedGiftCard) *Builder
- func (b *Builder) SetAuthenticatedUserID(id string) *Builder
- func (b *Builder) SetBelongsToAuthenticatedUser(v bool) *Builder
- func (b *Builder) SetBillingAddress(a Address) *Builder
- func (b *Builder) SetDefaultCurrency(d string) *Builder
- func (b *Builder) SetIds(id string, entityID string) *Builder
- func (b *Builder) SetPaymentSelection(d PaymentSelection) *Builder
- func (b *Builder) SetPurchaser(p Person) *Builder
- func (b *Builder) SetReservedOrderID(id string) *Builder
- type BuilderProvider
- type Cart
- func (c Cart) AllShippingTitles() []string
- func (c Cart) GetAllPaymentRequiredItems() PricedItems
- func (c Cart) GetByExternalReference(ref string) (*Item, error)
- func (c Cart) GetByItemID(itemID string) (*Item, error)
- func (c Cart) GetCartTeaser() *Teaser
- func (c Cart) GetDeliveryByCode(deliveryCode string) (*Delivery, bool)
- func (c Cart) GetDeliveryByCodeWithoutBool(deliveryCode string) *Delivery
- func (c Cart) GetDeliveryByItemID(itemID string) (*Delivery, error)
- func (c Cart) GetDeliveryCodes() []string
- func (c Cart) GetMainShippingEMail() string
- func (c Cart) GetPaymentReference() string
- func (c Cart) GetTotalItemsByType(typeCode string) []Totalitem
- func (c Cart) GetTotalQty(marketPlaceCode string, variantCode string) int
- func (c Cart) GetVoucherSavings() domain.Price
- func (c Cart) GrandTotal() domain.Price
- func (c Cart) GrandTotalCharges() domain.Charges
- func (c Cart) HasAppliedCouponCode() bool
- func (c *Cart) HasAppliedDiscounts() (bool, error)
- func (c Cart) HasAppliedGiftCards() bool
- func (c Cart) HasDeliveryForCode(deliveryCode string) bool
- func (c Cart) HasRemainingGiftCards() bool
- func (c Cart) HasShippingCosts() bool
- func (c Cart) IsEmpty() bool
- func (c Cart) IsPaymentSelected() bool
- func (c Cart) ItemCount() int
- func (c *Cart) MergeDiscounts() (AppliedDiscounts, error)
- func (c Cart) ProductCount() int
- func (c Cart) ProductCountUnique() int
- func (c Cart) SubTotalGross() domain.Price
- func (c Cart) SubTotalGrossWithDiscounts() domain.Price
- func (c Cart) SubTotalNet() domain.Price
- func (c Cart) SubTotalNetWithDiscounts() domain.Price
- func (c Cart) SumAppliedGiftCards() (domain.Price, error)
- func (c Cart) SumGrandTotalWithGiftCards() (domain.Price, error)
- func (c Cart) SumItemRelatedDiscountAmount() domain.Price
- func (c Cart) SumNonItemRelatedDiscountAmount() domain.Price
- func (c Cart) SumShippingNet() domain.Price
- func (c Cart) SumShippingNetWithDiscounts() domain.Price
- func (c Cart) SumTaxes() Taxes
- func (c Cart) SumTotalDiscountAmount() domain.Price
- func (c Cart) SumTotalTaxAmount() domain.Price
- type CompleteBehaviour
- type CouponCode
- type CustomerCartService
- type DefaultDeliveryInfoBuilder
- type DefaultPaymentSelection
- func (d DefaultPaymentSelection) CartSplit() PaymentSplit
- func (d DefaultPaymentSelection) Gateway() string
- func (d DefaultPaymentSelection) GenerateNewIdempotencyKey() (PaymentSelection, error)
- func (d DefaultPaymentSelection) IdempotencyKey() string
- func (d DefaultPaymentSelection) ItemSplit() PaymentSplitByItem
- func (d DefaultPaymentSelection) MarshalJSON() ([]byte, error)
- func (d DefaultPaymentSelection) MethodByType(chargeType string) string
- func (d DefaultPaymentSelection) TotalValue() price.Price
- type DeferEvents
- type Delivery
- func (d Delivery) GrandTotal() priceDomain.Price
- func (d *Delivery) HasAppliedDiscounts() (bool, error)
- func (d Delivery) HasItems() bool
- func (d *Delivery) MergeDiscounts() (AppliedDiscounts, error)
- func (d Delivery) SubTotalGross() priceDomain.Price
- func (d Delivery) SubTotalGrossWithDiscounts() priceDomain.Price
- func (d Delivery) SubTotalNet() priceDomain.Price
- func (d Delivery) SubTotalNetWithDiscounts() priceDomain.Price
- func (d Delivery) SumItemRelatedDiscountAmount() priceDomain.Price
- func (d Delivery) SumNonItemRelatedDiscountAmount() priceDomain.Price
- func (d Delivery) SumRowTaxes() Taxes
- func (d Delivery) SumTotalDiscountAmount() priceDomain.Price
- func (d Delivery) SumTotalTaxAmount() priceDomain.Price
- type DeliveryBuilder
- func (f *DeliveryBuilder) AddItem(i Item) *DeliveryBuilder
- func (f *DeliveryBuilder) Build() (*Delivery, error)
- func (f *DeliveryBuilder) Copy(d *Delivery) *DeliveryBuilder
- func (f *DeliveryBuilder) SetDeliveryCode(code string) *DeliveryBuilder
- func (f *DeliveryBuilder) SetDeliveryInfo(i DeliveryInfo) *DeliveryBuilder
- func (f *DeliveryBuilder) SetShippingItem(i ShippingItem) *DeliveryBuilder
- type DeliveryBuilderProvider
- type DeliveryInfo
- func (di DeliveryInfo) AdditionalDataKeys() []string
- func (di DeliveryInfo) AdditionalDeliveryInfoKeys() []string
- func (di DeliveryInfo) GetAdditionalData(key string) string
- func (di DeliveryInfo) GetAdditionalDeliveryInfo(key string) json.RawMessage
- func (di *DeliveryInfo) LoadAdditionalInfo(key string, info AdditionalDeliverInfo) error
- type DeliveryInfoBuilder
- type DeliveryInfoUpdateCommand
- type DeliveryLocation
- type ExistingCustomerData
- type GiftCardAndVoucherBehaviour
- type GiftCardBehaviour
- type GuestCartService
- type InvalidateCartEvent
- type Item
- func (i Item) AdditionalDataKeys() []string
- func (i Item) AdditionalDataValues() []string
- func (i Item) GetAdditionalData(key string) string
- func (i Item) HasAdditionalDataKey(key string) bool
- func (i *Item) HasAppliedDiscounts() (bool, error)
- func (i Item) ItemRelatedDiscountAmount() priceDomain.Price
- func (i *Item) MergeDiscounts() (AppliedDiscounts, error)
- func (i Item) NonItemRelatedDiscountAmount() priceDomain.Price
- func (i Item) RowPriceGrossWithDiscount() priceDomain.Price
- func (i Item) RowPriceGrossWithItemRelatedDiscount() priceDomain.Price
- func (i Item) RowPriceNetWithDiscount() priceDomain.Price
- func (i Item) RowPriceNetWithItemRelatedDiscount() priceDomain.Price
- func (i Item) TotalDiscountAmount() priceDomain.Price
- func (i Item) TotalTaxAmount() priceDomain.Price
- type ItemBuilder
- func (f *ItemBuilder) AddDiscount(discount AppliedDiscount) *ItemBuilder
- func (f *ItemBuilder) AddDiscounts(discounts ...AppliedDiscount) *ItemBuilder
- func (f *ItemBuilder) AddTaxInfo(taxType string, taxRate *big.Float, taxAmount *priceDomain.Price) *ItemBuilder
- func (f *ItemBuilder) Build() (*Item, error)
- func (f *ItemBuilder) CalculatePricesAndTax() *ItemBuilder
- func (f *ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceGross() *ItemBuilder
- func (f *ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceNet() *ItemBuilder
- func (f *ItemBuilder) Inject(config ...)
- func (f *ItemBuilder) SetAdditionalData(d map[string]string) *ItemBuilder
- func (f *ItemBuilder) SetByProduct(product domain.BasicProduct) *ItemBuilder
- func (f *ItemBuilder) SetExternalReference(ref string) *ItemBuilder
- func (f *ItemBuilder) SetFromItem(item Item) *ItemBuilder
- func (f *ItemBuilder) SetID(id string) *ItemBuilder
- func (f *ItemBuilder) SetProductData(marketplace string, vc string, name string) *ItemBuilder
- func (f *ItemBuilder) SetQty(q int) *ItemBuilder
- func (f *ItemBuilder) SetSinglePriceGross(grossPrice priceDomain.Price) *ItemBuilder
- func (f *ItemBuilder) SetSinglePriceNet(price priceDomain.Price) *ItemBuilder
- func (f *ItemBuilder) SetSourceID(id string) *ItemBuilder
- func (f *ItemBuilder) SetVariantMarketPlaceCode(id string) *ItemBuilder
- type ItemBuilderProvider
- type ItemSplitter
- type ItemUpdateCommand
- type ModifyBehaviour
- type PaymentSelection
- func NewDefaultPaymentSelection(gateway string, chargeTypeToPaymentMethod map[string]string, cart Cart) (PaymentSelection, error)
- func NewPaymentSelection(gateway string, chargedItems PaymentSplitByItem) PaymentSelection
- func RemoveZeroCharges(selection PaymentSelection, chargeTypeToPaymentMethod map[string]string) PaymentSelection
- type PaymentSplit
- type PaymentSplitByItem
- type PaymentSplitByItemBuilder
- func (pb *PaymentSplitByItemBuilder) AddCartItem(id string, method string, charge price.Charge) *PaymentSplitByItemBuilder
- func (pb *PaymentSplitByItemBuilder) AddShippingItem(deliveryCode string, method string, charge price.Charge) *PaymentSplitByItemBuilder
- func (pb *PaymentSplitByItemBuilder) AddTotalItem(totalType string, method string, charge price.Charge) *PaymentSplitByItemBuilder
- func (pb *PaymentSplitByItemBuilder) Build() PaymentSplitByItem
- type PaymentSplitService
- type Person
- type PersonalDetails
- type PricedItems
- type ShippingItem
- type SplitQualifier
- type Tax
- type Taxes
- type Teaser
- type Totalitem
- type WithDiscount
- type WithGiftCard
Constants ¶
const ( TotalsTypeDiscount = "totals_type_discount" TotalsTypeVoucher = "totals_type_voucher" TotalsTypeTax = "totals_type_tax" TotalsTypeLoyaltypoints = "totals_loyaltypoints" TotalsTypeShipping = "totals_type_shipping" )
Key constants
const ( //DeliveryWorkflowPickup - constant for common delivery workflows DeliveryWorkflowPickup = "pickup" //DeliveryWorkflowDelivery - workflow constant DeliveryWorkflowDelivery = "delivery" //DeliveryWorkflowUnspecified - workflow constant DeliveryWorkflowUnspecified = "unspecified" //DeliverylocationTypeUnspecified - constant DeliverylocationTypeUnspecified = "unspecified" //DeliverylocationTypeCollectionpoint - constant DeliverylocationTypeCollectionpoint = "collection-point" //DeliverylocationTypeStore - constant DeliverylocationTypeStore = "store" //DeliverylocationTypeAddress - constant DeliverylocationTypeAddress = "address" //DeliverylocationTypeFreightstation - constant DeliverylocationTypeFreightstation = "freight-station" )
Variables ¶
var ( // ErrCartNotFound is used if a cart was not found ErrCartNotFound = errors.New("Cart not found") // ErrItemNotFound is used if a item on cart was not found ErrItemNotFound = errors.New("Item not found") // ErrDeliveryCodeNotFound is used if a delivery was not found ErrDeliveryCodeNotFound = errors.New("Delivery not found") )
var ( // ErrSplitNoGiftCards indicates that there are no gift cards given to PaymentSplitWithGiftCards ErrSplitNoGiftCards = errors.New("no gift cards applied") // ErrSplitEmptyGiftCards indicates that there are gift cards given but with 0 applied balance ErrSplitEmptyGiftCards = errors.New("applied gift cards are empty") // ErrSplitGiftCardsExceedTotal indicates that gift card sum exceeds total of prices items ErrSplitGiftCardsExceedTotal = errors.New("gift card amount exceeds total priced items value") // ErrSplitGiftCardsNoChargeTypeMapping indicates that there is no mapping from the gift card charge type to an actual payment method ErrSplitGiftCardsNoChargeTypeMapping = fmt.Errorf("payment method for charge type %q not defined", price.ChargeTypeGiftCard) )
var ( // ErrAdditionalInfosNotFound is returned if the additional infos are not set ErrAdditionalInfosNotFound = errors.New("additional infos not found") )
Functions ¶
This section is empty.
Types ¶
type AddRequest ¶
type AddRequest struct { MarketplaceCode string Qty int VariantMarketplaceCode string AdditionalData map[string]string }
AddRequest defines add to cart request
type AdditionalData ¶
type AdditionalData struct { //CustomAttributes list of key values CustomAttributes map[string]string // ReservedOrderID is an ID already known by the Cart of the future order ID ReservedOrderID string }
AdditionalData defines the supplementary cart data
type AdditionalDeliverInfo ¶
type AdditionalDeliverInfo interface { Marshal() (json.RawMessage, error) Unmarshal(json.RawMessage) error }
AdditionalDeliverInfo is an interface that allows to store "any" additional objects on the cart see DeliveryInfoUpdateCommand
type Address ¶
type Address struct { Vat string Firstname string Lastname string MiddleName string Title string Salutation string Street string StreetNr string AdditionalAddressLines []string Company string City string PostCode string State string RegionCode string Country string CountryCode string Telephone string Email string }
Address defines a cart address
type AppliedCouponCodes ¶ added in v3.0.1
type AppliedCouponCodes []CouponCode
AppliedCouponCodes slice of applied coupon codes
func (AppliedCouponCodes) ContainedIn ¶ added in v3.0.1
func (acc AppliedCouponCodes) ContainedIn(couponCodesToCompare AppliedCouponCodes) bool
ContainedIn - returns if the coupon codes are contained in couponCodesToCompare
type AppliedDiscount ¶
type AppliedDiscount struct { CampaignCode string // unique code of the underlying campaign or rule e.g. "summer-campaign-2018" CouponCode string // code of discount e.g. provided by user "summer2018" Label string // readable name of discount "Super Summer Sale 2018" Applied domain.Price // how much of the discount has been subtracted from cart price, IMPORTANT: always negative Type string // to distinguish between discounts IsItemRelated bool // flag indicating if the discount is applied due to item in cart SortOrder int // indicates in which order discount have been applied, low value has been applied before high value }
AppliedDiscount value object - generic reference for a discount
type AppliedDiscounts ¶
type AppliedDiscounts []AppliedDiscount
AppliedDiscounts represents multiple discounts that are subtracted from total price of cart
func (AppliedDiscounts) ByCampaignCode ¶
func (discounts AppliedDiscounts) ByCampaignCode(campaignCode string) AppliedDiscounts
ByCampaignCode filter AppliedDiscounts based on provided campaign code
func (AppliedDiscounts) ByType ¶
func (discounts AppliedDiscounts) ByType(filterType string) AppliedDiscounts
ByType filter AppliedDiscounts based on type
func (AppliedDiscounts) Items ¶
func (discounts AppliedDiscounts) Items() []AppliedDiscount
Items getter for graphql integration
type AppliedGiftCard ¶
type AppliedGiftCard struct { Code string Applied domain.Price // how much of the gift card has been subtracted from cart price Remaining domain.Price // how much of the gift card is still available CustomAttributes map[string]interface{} // additional custom attributes }
AppliedGiftCard value object represents a gift card (partial payment) on the cart
func (AppliedGiftCard) HasRemaining ¶
func (card AppliedGiftCard) HasRemaining() bool
HasRemaining checks whether gift card has a remaining balance
type AppliedGiftCards ¶
type AppliedGiftCards []AppliedGiftCard
AppliedGiftCards convenience wrapper for array of applied gift cards
func (*AppliedGiftCards) ByRemaining ¶
func (cards *AppliedGiftCards) ByRemaining() AppliedGiftCards
ByRemaining fetches gift cards that still have a remaining value from applied gift cards
func (*AppliedGiftCards) GiftCardByCode ¶
func (cards *AppliedGiftCards) GiftCardByCode(code string) (*AppliedGiftCard, bool)
GiftCardByCode returns a single gift card if the given code matches its code. First return parameter is the gift card if found and the second return parameter is a boolean depicting if a gift card was found
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder - the main builder for a cart
func (*Builder) AddAppliedCouponCode ¶
func (b *Builder) AddAppliedCouponCode(code CouponCode) *Builder
AddAppliedCouponCode - optional - add the coupon that is applied for the cart
func (*Builder) AddDelivery ¶
AddDelivery - add a delivery subobject - use the DeliveryBuilder
func (*Builder) AddTotalitem ¶
AddTotalitem - adds nontaxable extra totals on cartlevel
func (*Builder) SetAdditionalData ¶
func (b *Builder) SetAdditionalData(d AdditionalData) *Builder
SetAdditionalData - to add additional data
func (*Builder) SetAppliedGiftCards ¶
func (b *Builder) SetAppliedGiftCards(gc []AppliedGiftCard) *Builder
SetAppliedGiftCards - optional - sets the applied gift cards
func (*Builder) SetAuthenticatedUserID ¶
SetAuthenticatedUserID - to mark the art as authenticated users cart
func (*Builder) SetBelongsToAuthenticatedUser ¶
SetBelongsToAuthenticatedUser - mark the art as authenticated users cart
func (*Builder) SetBillingAddress ¶
SetBillingAddress - optional
func (*Builder) SetDefaultCurrency ¶
SetDefaultCurrency - sets the default currency
func (*Builder) SetPaymentSelection ¶
func (b *Builder) SetPaymentSelection(d PaymentSelection) *Builder
SetPaymentSelection - to add additional data
func (*Builder) SetPurchaser ¶
SetPurchaser - optional
func (*Builder) SetReservedOrderID ¶
SetReservedOrderID - optional
type BuilderProvider ¶
type BuilderProvider func() *Builder
BuilderProvider should be used to create the cart by using the Builder
type Cart ¶
type Cart struct { //ID is the main identifier of the cart ID string //EntityID is a second identifier that may be used by some backends EntityID string //BillingAddress - the main billing address (relevant for all payments/invoices) BillingAddress *Address //Purchaser - additional infos for the legal contact person in this order Purchaser *Person //Deliveries - list of desired Deliveries (or Shipments) involved in this cart Deliveries []Delivery //AdditionalData can be used for Custom attributes AdditionalData AdditionalData //PaymentSelection - the saved PaymentSelection (saves "how" the customer want to pay) PaymentSelection PaymentSelection //BelongsToAuthenticatedUser - false = Guest Cart true = cart from the authenticated user BelongsToAuthenticatedUser bool AuthenticatedUserID string AppliedCouponCodes []CouponCode DefaultCurrency string //Additional non taxable totals Totalitems []Totalitem //List of applied gift cards AppliedGiftCards []AppliedGiftCard }
Cart Value Object (immutable data - because the cartservice is responsible to return a cart).
func (Cart) AllShippingTitles ¶
AllShippingTitles - returns all ShippingItem titles
func (Cart) GetAllPaymentRequiredItems ¶
func (c Cart) GetAllPaymentRequiredItems() PricedItems
GetAllPaymentRequiredItems - returns all the Items (Cartitem, ShippingItem, TotalItems) that need to be paid with the final gross price
func (Cart) GetByExternalReference ¶
GetByExternalReference gets an item by its external reference
func (Cart) GetByItemID ¶
GetByItemID gets an item by its id
func (Cart) GetDeliveryByCode ¶
GetDeliveryByCode gets a delivery by code
func (Cart) GetDeliveryByCodeWithoutBool ¶
GetDeliveryByCodeWithoutBool TODO: This func needs to be removed as soon as there's a solution for handling of boolean returns when gql expects an err
func (Cart) GetDeliveryByItemID ¶
GetDeliveryByItemID returns a delivery by a given itemID
func (Cart) GetDeliveryCodes ¶
GetDeliveryCodes returns a slice of all delivery codes in cart that have at least one cart item
func (Cart) GetMainShippingEMail ¶
GetMainShippingEMail returns the main shipping address email, empty string if not available
func (Cart) GetPaymentReference ¶
GetPaymentReference - Returns a string that can be used as reference to pass to payment gateway. You may want to use it. It returns either the reserved Order id or the cart id/entityid
func (Cart) GetTotalItemsByType ¶
GetTotalItemsByType gets a slice of all Totalitems by typeCode
func (Cart) GetTotalQty ¶
GetTotalQty for the product in the cart
func (Cart) GetVoucherSavings ¶
GetVoucherSavings returns the savings of all vouchers
func (Cart) GrandTotal ¶
GrandTotal - Final sum (Valued price) that need to be paid: GrandTotal = SubTotal + TaxAmount - DiscountAmount + SOME of Totalitems = (Sum of Items RowTotalWithDiscountInclTax) + SOME of Totalitems
func (Cart) GrandTotalCharges ¶
GrandTotalCharges - Final sum that need to be paid - splitted by the charges that need to be paid
func (Cart) HasAppliedCouponCode ¶
HasAppliedCouponCode checks if a coupon code is applied to the cart
func (*Cart) HasAppliedDiscounts ¶
HasAppliedDiscounts check whether there are any discounts currently applied to the cart
func (Cart) HasAppliedGiftCards ¶
HasAppliedGiftCards checks if a gift card is applied to the cart
func (Cart) HasDeliveryForCode ¶
HasDeliveryForCode checks if a delivery with the given code exists in the cart
func (Cart) HasRemainingGiftCards ¶
HasRemainingGiftCards check whether there are gift cards with remaining balance
func (Cart) HasShippingCosts ¶
HasShippingCosts - returns true if cart HasShippingCosts
func (Cart) IsPaymentSelected ¶
IsPaymentSelected - returns true if a valid payment is selected
func (*Cart) MergeDiscounts ¶
func (c *Cart) MergeDiscounts() (AppliedDiscounts, error)
MergeDiscounts sums up discounts of cart based on its deliveries All discounts with the same campaign code are aggregated and returned as one with a summed price
func (Cart) ProductCount ¶
ProductCount returns the amount of different products, but a product is counted twice if it is in different deliveries
func (Cart) ProductCountUnique ¶ added in v3.1.0
ProductCountUnique returns the amount of unique products across all deliveries
func (Cart) SubTotalGross ¶
SubTotalGross - returns sum price of deliveries SubTotalGross
func (Cart) SubTotalGrossWithDiscounts ¶
SubTotalGrossWithDiscounts - returns sum price of deliveries SubTotalGrossWithDiscounts
func (Cart) SubTotalNet ¶
SubTotalNet - returns sum price of deliveries SubTotalNet
func (Cart) SubTotalNetWithDiscounts ¶
SubTotalNetWithDiscounts - returns sum price of deliveries SubTotalNetWithDiscounts
func (Cart) SumAppliedGiftCards ¶
SumAppliedGiftCards sum up all applied amounts of giftcads price is returned as a payable
func (Cart) SumGrandTotalWithGiftCards ¶
SumGrandTotalWithGiftCards calculate the grand total of the cart minus gift cards
func (Cart) SumItemRelatedDiscountAmount ¶
SumItemRelatedDiscountAmount - returns sum price of deliveries SumItemRelatedDiscountAmount
func (Cart) SumNonItemRelatedDiscountAmount ¶
SumNonItemRelatedDiscountAmount - returns sum price of deliveries SumNonItemRelatedDiscountAmount
func (Cart) SumShippingNet ¶
SumShippingNet - returns net sum price of deliveries ShippingItems
func (Cart) SumShippingNetWithDiscounts ¶
SumShippingNetWithDiscounts - returns net sum price of deliveries ShippingItems with discounts
func (Cart) SumTotalDiscountAmount ¶
SumTotalDiscountAmount - returns sum price of deliveries SumTotalDiscountAmount
func (Cart) SumTotalTaxAmount ¶
SumTotalTaxAmount - returns sum price of deliveries Taxes as total amount
type CompleteBehaviour ¶ added in v3.1.0
type CompleteBehaviour interface { Complete(context.Context, *Cart) (*Cart, DeferEvents, error) // Restore should reopen the cart while maintaining the previously used cart id Restore(context.Context, *Cart) (*Cart, DeferEvents, error) }
CompleteBehaviour can be implemented by a cart service. Complete is normally called before the cart is placed This can for example be used to invalidate gift cards
type CouponCode ¶
type CouponCode struct { Code string // CustomAttributes can hold additional data for coupon code - keys and values are project specific CustomAttributes map[string]interface{} }
CouponCode value object
type CustomerCartService ¶
type CustomerCartService interface { // GetModifyBehaviour gets the behaviour for the customer cart service GetModifyBehaviour(context.Context, domain.Auth) (ModifyBehaviour, error) GetCart(ctx context.Context, auth domain.Auth, cartID string) (*Cart, error) // RestoreCart restores a previously used customer cart with all its content. // Depending on the used adapter this can lead to a new Cart.ID // Deprecated: Implement CompleteBehaviour instead RestoreCart(ctx context.Context, auth domain.Auth, cart Cart) (*Cart, error) }
CustomerCartService interface - Secondary PORT
type DefaultDeliveryInfoBuilder ¶
type DefaultDeliveryInfoBuilder struct {
// contains filtered or unexported fields
}
DefaultDeliveryInfoBuilder defines the default delivery info builder used
func (*DefaultDeliveryInfoBuilder) BuildByDeliveryCode ¶
func (b *DefaultDeliveryInfoBuilder) BuildByDeliveryCode(deliverycode string) (*DeliveryInfo, error)
BuildByDeliveryCode builds a (initial) DeliveryInfo by deliveryCode Convention that is used in this factory is to split infos in the build deliveryinfo by "_" like this:
- workflow_locationtype_locationdetail_method_anythingelse
- not all parts are required
- to "skip" parts in between use "-"
type DefaultPaymentSelection ¶
type DefaultPaymentSelection struct { //GatewayProp - the selected Gateway GatewayProp string ChargedItemsProp PaymentSplitByItem IdempotencyKeyUUID string }
DefaultPaymentSelection value object - that implements the PaymentSelection interface
func (DefaultPaymentSelection) CartSplit ¶
func (d DefaultPaymentSelection) CartSplit() PaymentSplit
CartSplit - the selected split per ChargeType and PaymentMethod
func (DefaultPaymentSelection) Gateway ¶
func (d DefaultPaymentSelection) Gateway() string
Gateway - returns the selected Gateway code
func (DefaultPaymentSelection) GenerateNewIdempotencyKey ¶ added in v3.0.1
func (d DefaultPaymentSelection) GenerateNewIdempotencyKey() (PaymentSelection, error)
GenerateNewIdempotencyKey updates the Idempotency-Key to a new value
func (DefaultPaymentSelection) IdempotencyKey ¶ added in v3.0.1
func (d DefaultPaymentSelection) IdempotencyKey() string
IdempotencyKey returns the Idempotency-Key for this payment selection
func (DefaultPaymentSelection) ItemSplit ¶
func (d DefaultPaymentSelection) ItemSplit() PaymentSplitByItem
ItemSplit - the selected split per ChargeType and PaymentMethod
func (DefaultPaymentSelection) MarshalJSON ¶ added in v3.0.1
func (d DefaultPaymentSelection) MarshalJSON() ([]byte, error)
MarshalJSON adds the Idempotency-Key to the payment selection json
func (DefaultPaymentSelection) MethodByType ¶
func (d DefaultPaymentSelection) MethodByType(chargeType string) string
MethodByType returns the payment method by charge type
func (DefaultPaymentSelection) TotalValue ¶
func (d DefaultPaymentSelection) TotalValue() price.Price
TotalValue - returns Valued price sum
type DeferEvents ¶
DeferEvents represents events that should be dispatched after a cart modify call
type Delivery ¶
type Delivery struct { //DeliveryInfo - The details for this delivery - normally completed during checkout DeliveryInfo DeliveryInfo //Cartitems - list of cartitems Cartitems []Item //ShippingItem - The Shipping Costs that may be involved in this delivery ShippingItem ShippingItem }
Delivery - represents the DeliveryInfo and the assigned Items
func (Delivery) GrandTotal ¶
func (d Delivery) GrandTotal() priceDomain.Price
GrandTotal - returns SubTotalGross including shipping and discounts - for the Delivery
func (*Delivery) HasAppliedDiscounts ¶
HasAppliedDiscounts check whether there are any discounts currently applied to the delivery
func (*Delivery) MergeDiscounts ¶
func (d *Delivery) MergeDiscounts() (AppliedDiscounts, error)
MergeDiscounts sums up discounts of a delivery based on its single item discounts All discounts with the same campaign code are aggregated and returned as one with a summed price
func (Delivery) SubTotalGross ¶
func (d Delivery) SubTotalGross() priceDomain.Price
SubTotalGross - returns SubTotalGross
func (Delivery) SubTotalGrossWithDiscounts ¶
func (d Delivery) SubTotalGrossWithDiscounts() priceDomain.Price
SubTotalGrossWithDiscounts returns SubTotalGrossWithDiscounts
func (Delivery) SubTotalNet ¶
func (d Delivery) SubTotalNet() priceDomain.Price
SubTotalNet - returns SubTotalNet
func (Delivery) SubTotalNetWithDiscounts ¶
func (d Delivery) SubTotalNetWithDiscounts() priceDomain.Price
SubTotalNetWithDiscounts - returns SubTotalNet With Discounts
func (Delivery) SumItemRelatedDiscountAmount ¶
func (d Delivery) SumItemRelatedDiscountAmount() priceDomain.Price
SumItemRelatedDiscountAmount - returns SumItemRelatedDiscountAmount
func (Delivery) SumNonItemRelatedDiscountAmount ¶
func (d Delivery) SumNonItemRelatedDiscountAmount() priceDomain.Price
SumNonItemRelatedDiscountAmount returns SumNonItemRelatedDiscountAmount
func (Delivery) SumRowTaxes ¶
SumRowTaxes - returns SumRowTaxes
func (Delivery) SumTotalDiscountAmount ¶
func (d Delivery) SumTotalDiscountAmount() priceDomain.Price
SumTotalDiscountAmount - returns SumTotalDiscountAmount
func (Delivery) SumTotalTaxAmount ¶
func (d Delivery) SumTotalTaxAmount() priceDomain.Price
SumTotalTaxAmount - returns SumTotalTaxAmount
type DeliveryBuilder ¶
type DeliveryBuilder struct {
// contains filtered or unexported fields
}
DeliveryBuilder - the Builder (factory) to build new deliveries by making sure the invariants are ok
func (*DeliveryBuilder) AddItem ¶
func (f *DeliveryBuilder) AddItem(i Item) *DeliveryBuilder
AddItem adds an item to the delivery
func (*DeliveryBuilder) Build ¶
func (f *DeliveryBuilder) Build() (*Delivery, error)
Build - main Factory method
func (*DeliveryBuilder) Copy ¶
func (f *DeliveryBuilder) Copy(d *Delivery) *DeliveryBuilder
Copy - use to set the values for the new delivery from an existing delivery by copying it
func (*DeliveryBuilder) SetDeliveryCode ¶
func (f *DeliveryBuilder) SetDeliveryCode(code string) *DeliveryBuilder
SetDeliveryCode - sets the deliverycode (dont need to be called if SetDeliveryInfo has a code set already)
func (*DeliveryBuilder) SetDeliveryInfo ¶
func (f *DeliveryBuilder) SetDeliveryInfo(i DeliveryInfo) *DeliveryBuilder
SetDeliveryInfo - sets DeliveryInfo
func (*DeliveryBuilder) SetShippingItem ¶
func (f *DeliveryBuilder) SetShippingItem(i ShippingItem) *DeliveryBuilder
SetShippingItem - sets the delivery ShippingItem
type DeliveryBuilderProvider ¶
type DeliveryBuilderProvider func() *DeliveryBuilder
DeliveryBuilderProvider should be used to create a Delivery
type DeliveryInfo ¶
type DeliveryInfo struct { // Code - is a project specific identifier for the Delivery - you need it for the AddToCart Request for example // The code can follow the convention in the Readme: Type_Method_LocationType_LocationCode Code string //Type - The Type of the Delivery - e.g. delivery or pickup - this might trigger different workflows Workflow string //Method - The shippingmethod something that is project specific and that can mean different delivery qualities with different deliverycosts Method string //Carrier - Optional the name of the Carrier that should be responsible for executing the delivery Carrier string //DeliveryLocation The target Location for the delivery DeliveryLocation DeliveryLocation //DesiredTime - Optional - the desired time of the delivery DesiredTime time.Time //AdditionalData - Possibility for key value based information on the delivery - can be used flexible by each project AdditionalData map[string]string //AdditionalDeliveryInfos - similar to AdditionalData this can be used to store "any" other object on a delivery encoded as json.RawMessage AdditionalDeliveryInfos map[string]json.RawMessage }
DeliveryInfo - represents the Delivery
func (DeliveryInfo) AdditionalDataKeys ¶
func (di DeliveryInfo) AdditionalDataKeys() []string
AdditionalDataKeys lists all available keys
func (DeliveryInfo) AdditionalDeliveryInfoKeys ¶
func (di DeliveryInfo) AdditionalDeliveryInfoKeys() []string
AdditionalDeliveryInfoKeys lists all available keys
func (DeliveryInfo) GetAdditionalData ¶
func (di DeliveryInfo) GetAdditionalData(key string) string
GetAdditionalData returns additional data
func (DeliveryInfo) GetAdditionalDeliveryInfo ¶
func (di DeliveryInfo) GetAdditionalDeliveryInfo(key string) json.RawMessage
GetAdditionalDeliveryInfo returns additional delivery info
func (*DeliveryInfo) LoadAdditionalInfo ¶
func (di *DeliveryInfo) LoadAdditionalInfo(key string, info AdditionalDeliverInfo) error
LoadAdditionalInfo - returns the additional Data
type DeliveryInfoBuilder ¶
type DeliveryInfoBuilder interface {
BuildByDeliveryCode(deliveryCode string) (*DeliveryInfo, error)
}
DeliveryInfoBuilder - Factory
type DeliveryInfoUpdateCommand ¶
type DeliveryInfoUpdateCommand struct { DeliveryInfo DeliveryInfo // contains filtered or unexported fields }
DeliveryInfoUpdateCommand defines the update item command
func CreateDeliveryInfoUpdateCommand ¶
func CreateDeliveryInfoUpdateCommand(info DeliveryInfo) DeliveryInfoUpdateCommand
CreateDeliveryInfoUpdateCommand - factory to get the update command based on the given deliveryInfos (which might come from cart)
func (*DeliveryInfoUpdateCommand) AddAdditional ¶
func (d *DeliveryInfoUpdateCommand) AddAdditional(key string, val AdditionalDeliverInfo) (err error)
AddAdditional adds additional delivery info data
func (*DeliveryInfoUpdateCommand) Additional ¶
func (d *DeliveryInfoUpdateCommand) Additional() map[string]json.RawMessage
Additional gets the additional data as war map from the delivery info update command
func (*DeliveryInfoUpdateCommand) SetAdditional ¶
func (d *DeliveryInfoUpdateCommand) SetAdditional(val map[string]json.RawMessage)
SetAdditional adds additional delivery info data
type DeliveryLocation ¶
type DeliveryLocation struct { //Type - the type of the delivery - use some of the constant defined in the package like DeliverylocationTypeAddress Type string //Address - (only relevant for type address) Address *Address //UseBillingAddress - the address should be taken from billing (only relevant for type address) UseBillingAddress bool //Code - optional identifier of this location/destination - is used in special destination Types Code string }
DeliveryLocation value object
type ExistingCustomerData ¶
type ExistingCustomerData struct { //ID of the customer ID string }
ExistingCustomerData value object
type GiftCardAndVoucherBehaviour ¶
type GiftCardAndVoucherBehaviour interface {
ApplyAny(ctx context.Context, cart *Cart, anyCode string) (*Cart, DeferEvents, error)
}
GiftCardAndVoucherBehaviour - additional interface that can be implemented to support generic code entry (which can either be voucher or giftcard)
type GiftCardBehaviour ¶
type GiftCardBehaviour interface { ApplyGiftCard(ctx context.Context, cart *Cart, giftCardCode string) (*Cart, DeferEvents, error) RemoveGiftCard(ctx context.Context, cart *Cart, giftCardCode string) (*Cart, DeferEvents, error) }
GiftCardBehaviour - additional interface that can be implemented to support GiftCard features
type GuestCartService ¶
type GuestCartService interface { // GetModifyBehaviour gets the behaviour for the guest cart service GetModifyBehaviour(context.Context) (ModifyBehaviour, error) GetCart(ctx context.Context, cartID string) (*Cart, error) // GetNewCart - should return a new guest cart (including the id of the cart) GetNewCart(ctx context.Context) (*Cart, error) // RestoreCart restores a previously used guest cart with all its content. // Depending on the used adapter this can lead to a new Cart.ID // Deprecated: Implement CompleteBehaviour instead RestoreCart(ctx context.Context, cart Cart) (*Cart, error) }
GuestCartService interface - Secondary PORT
type InvalidateCartEvent ¶
InvalidateCartEvent value object
type Item ¶
type Item struct { // ID of the item - needs to be unique over the whole cart ID string // ExternalReference can be used by cart service implementations to separate the representation in an external // cart service from the unique item ID ExternalReference string MarketplaceCode string // VariantMarketPlaceCode is used for Configurable products VariantMarketPlaceCode string ProductName string // Source Id of where the items should be initial picked - This is set by the SourcingLogic SourceID string Qty int AdditionalData map[string]string // SinglePriceGross brutto (gross) for single product SinglePriceGross priceDomain.Price // SinglePriceNet net price for single product SinglePriceNet priceDomain.Price // RowPriceGross RowPriceGross priceDomain.Price // RowPriceNet RowPriceNet priceDomain.Price // RowPriceGross RowTaxes Taxes // AppliedDiscounts contains the details about the discounts applied to this item - they can be "itemrelated" or not AppliedDiscounts AppliedDiscounts }
Item for Cart
func (Item) AdditionalDataKeys ¶
AdditionalDataKeys lists all available keys
func (Item) AdditionalDataValues ¶
AdditionalDataValues lists all values
func (Item) GetAdditionalData ¶
GetAdditionalData returns a specified attribute
func (Item) HasAdditionalDataKey ¶
HasAdditionalDataKey checks if an attribute is available
func (*Item) HasAppliedDiscounts ¶
HasAppliedDiscounts check whether there are any discounts currently applied to the item
func (Item) ItemRelatedDiscountAmount ¶
func (i Item) ItemRelatedDiscountAmount() priceDomain.Price
ItemRelatedDiscountAmount = Sum of AppliedDiscounts where IsItemRelated = True
func (*Item) MergeDiscounts ¶
func (i *Item) MergeDiscounts() (AppliedDiscounts, error)
MergeDiscounts parses discounts of a single item All discounts with the same campaign code are aggregated and returned as one with a summed price
func (Item) NonItemRelatedDiscountAmount ¶
func (i Item) NonItemRelatedDiscountAmount() priceDomain.Price
NonItemRelatedDiscountAmount = Sum of AppliedDiscounts where IsItemRelated = false
func (Item) RowPriceGrossWithDiscount ¶
func (i Item) RowPriceGrossWithDiscount() priceDomain.Price
RowPriceGrossWithDiscount = RowPriceGross-TotalDiscountAmount()
func (Item) RowPriceGrossWithItemRelatedDiscount ¶
func (i Item) RowPriceGrossWithItemRelatedDiscount() priceDomain.Price
RowPriceGrossWithItemRelatedDiscount = RowPriceGross-ItemRelatedDiscountAmount()
func (Item) RowPriceNetWithDiscount ¶
func (i Item) RowPriceNetWithDiscount() priceDomain.Price
RowPriceNetWithDiscount = RowPriceNet-TotalDiscountAmount()
func (Item) RowPriceNetWithItemRelatedDiscount ¶
func (i Item) RowPriceNetWithItemRelatedDiscount() priceDomain.Price
RowPriceNetWithItemRelatedDiscount =RowTotal-ItemRelatedDiscountAmount
func (Item) TotalDiscountAmount ¶
func (i Item) TotalDiscountAmount() priceDomain.Price
TotalDiscountAmount gets the savings by item
func (Item) TotalTaxAmount ¶
func (i Item) TotalTaxAmount() priceDomain.Price
TotalTaxAmount - returns total tax amount as price
type ItemBuilder ¶
type ItemBuilder struct {
// contains filtered or unexported fields
}
ItemBuilder can be used to construct an item with a fluent interface
func (*ItemBuilder) AddDiscount ¶
func (f *ItemBuilder) AddDiscount(discount AppliedDiscount) *ItemBuilder
AddDiscount - adds a discount
func (*ItemBuilder) AddDiscounts ¶
func (f *ItemBuilder) AddDiscounts(discounts ...AppliedDiscount) *ItemBuilder
AddDiscounts - adds a discount
func (*ItemBuilder) AddTaxInfo ¶
func (f *ItemBuilder) AddTaxInfo(taxType string, taxRate *big.Float, taxAmount *priceDomain.Price) *ItemBuilder
AddTaxInfo - add a tax info - at least taxRate OR taxAmount need to be given. The taxAmount can be calculated
func (*ItemBuilder) Build ¶
func (f *ItemBuilder) Build() (*Item, error)
Build returns build item or error if invariants do not match. Any call will also REST the ItemBuilder
func (*ItemBuilder) CalculatePricesAndTax ¶
func (f *ItemBuilder) CalculatePricesAndTax() *ItemBuilder
CalculatePricesAndTax - reads the config flag and reculculates Total and Tax
func (*ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceGross ¶
func (f *ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceGross() *ItemBuilder
CalculatePricesAndTaxAmountsFromSinglePriceGross - Vertical Tax Calculation - based from current SinglePriceNet, Qty and the RowTax Infos given Sets RowPriceNet, missing tax.Amount and RowPriceGross
func (*ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceNet ¶
func (f *ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceNet() *ItemBuilder
CalculatePricesAndTaxAmountsFromSinglePriceNet - Vertikal Tax Calculation - based from current SinglePriceNet, Qty and the RowTax Infos given Sets RowPriceNet, missing tax.Amount and RowPriceGross
func (*ItemBuilder) Inject ¶
func (f *ItemBuilder) Inject(config *struct { UseGrosPrice bool `inject:"config:commerce.product.priceIsGross,optional"` })
Inject - called by dingo
func (*ItemBuilder) SetAdditionalData ¶
func (f *ItemBuilder) SetAdditionalData(d map[string]string) *ItemBuilder
SetAdditionalData - optional
func (*ItemBuilder) SetByProduct ¶
func (f *ItemBuilder) SetByProduct(product domain.BasicProduct) *ItemBuilder
SetByProduct - gets a product and calculates also prices
func (*ItemBuilder) SetExternalReference ¶
func (f *ItemBuilder) SetExternalReference(ref string) *ItemBuilder
SetExternalReference - sets the ExternalReference
func (*ItemBuilder) SetFromItem ¶
func (f *ItemBuilder) SetFromItem(item Item) *ItemBuilder
SetFromItem - sets the data in builder from existing item - useful to get a updated item based from existing. Its not setting Taxes (use Calculate)
func (*ItemBuilder) SetProductData ¶
func (f *ItemBuilder) SetProductData(marketplace string, vc string, name string) *ItemBuilder
SetProductData - set product data: MarketplaceCode,VariantMarketPlaceCode,ProductName
func (*ItemBuilder) SetQty ¶
func (f *ItemBuilder) SetQty(q int) *ItemBuilder
SetQty - optional (default 1)
func (*ItemBuilder) SetSinglePriceGross ¶
func (f *ItemBuilder) SetSinglePriceGross(grossPrice priceDomain.Price) *ItemBuilder
SetSinglePriceGross - set by gross price
func (*ItemBuilder) SetSinglePriceNet ¶
func (f *ItemBuilder) SetSinglePriceNet(price priceDomain.Price) *ItemBuilder
SetSinglePriceNet - set by net
func (*ItemBuilder) SetSourceID ¶
func (f *ItemBuilder) SetSourceID(id string) *ItemBuilder
SetSourceID - optional
func (*ItemBuilder) SetVariantMarketPlaceCode ¶
func (f *ItemBuilder) SetVariantMarketPlaceCode(id string) *ItemBuilder
SetVariantMarketPlaceCode sets VariantMarketPlaceCode (only for configurable_with_variant relevant)
type ItemBuilderProvider ¶
type ItemBuilderProvider func() *ItemBuilder
ItemBuilderProvider should be used to create an item
type ItemSplitter ¶
type ItemSplitter struct {
// contains filtered or unexported fields
}
ItemSplitter used to split an item
func (*ItemSplitter) Inject ¶
func (s *ItemSplitter) Inject(itemBuilderProvider ItemBuilderProvider, config *struct { UseGrosPrice bool `inject:"config:commerce.product.priceIsGross,optional"` })
Inject of ItemSplitter
func (*ItemSplitter) SplitInSingleQtyItems ¶
func (s *ItemSplitter) SplitInSingleQtyItems(givenItem Item) ([]Item, error)
SplitInSingleQtyItems the given item into multiple items with Qty 1 and make sure the sum of the items prices matches by using SplitInPayables
type ItemUpdateCommand ¶
type ItemUpdateCommand struct { // SourceID of where the items should be initially picked from - This is set by the SourcingLogic SourceID *string // Qty contains the item quantity Qty *int // AdditionalData contains item related data AdditionalData map[string]string // Mandatory field: ItemID is only for identifying the item. ItemID string }
ItemUpdateCommand defines the update item command
type ModifyBehaviour ¶
type ModifyBehaviour interface { DeleteItem(ctx context.Context, cart *Cart, itemID string, deliveryCode string) (*Cart, DeferEvents, error) UpdateItem(ctx context.Context, cart *Cart, itemUpdateCommand ItemUpdateCommand) (*Cart, DeferEvents, error) UpdateItems(ctx context.Context, cart *Cart, itemUpdateCommands []ItemUpdateCommand) (*Cart, DeferEvents, error) AddToCart(ctx context.Context, cart *Cart, deliveryCode string, addRequest AddRequest) (*Cart, DeferEvents, error) CleanCart(ctx context.Context, cart *Cart) (*Cart, DeferEvents, error) CleanDelivery(ctx context.Context, cart *Cart, deliveryCode string) (*Cart, DeferEvents, error) UpdatePurchaser(ctx context.Context, cart *Cart, purchaser *Person, additionalData *AdditionalData) (*Cart, DeferEvents, error) UpdateAdditionalData(ctx context.Context, cart *Cart, additionalData *AdditionalData) (*Cart, DeferEvents, error) UpdatePaymentSelection(ctx context.Context, cart *Cart, paymentSelection PaymentSelection) (*Cart, DeferEvents, error) UpdateDeliveryInfo(ctx context.Context, cart *Cart, deliveryCode string, deliveryInfo DeliveryInfoUpdateCommand) (*Cart, DeferEvents, error) UpdateBillingAddress(ctx context.Context, cart *Cart, billingAddress Address) (*Cart, DeferEvents, error) UpdateDeliveryInfoAdditionalData(ctx context.Context, cart *Cart, deliveryCode string, additionalData *AdditionalData) (*Cart, DeferEvents, error) ApplyVoucher(ctx context.Context, cart *Cart, couponCode string) (*Cart, DeferEvents, error) RemoveVoucher(ctx context.Context, cart *Cart, couponCode string) (*Cart, DeferEvents, error) }
ModifyBehaviour is a interface that can be implemented by other packages to provide cart actions This port can not be registered directly but is provided by the registered "GuestCartService"
type PaymentSelection ¶
type PaymentSelection interface { Gateway() string //ChargeSplits - the selected split per ChargeType and PaymentMethod CartSplit() PaymentSplit //ChargeSplits - the selected split per ChargeType and PaymentMethod ItemSplit() PaymentSplitByItem TotalValue() price.Price MethodByType(string) string IdempotencyKey() string GenerateNewIdempotencyKey() (PaymentSelection, error) }
PaymentSelection value object - that represents the payment selection on the cart
func NewDefaultPaymentSelection ¶
func NewDefaultPaymentSelection(gateway string, chargeTypeToPaymentMethod map[string]string, cart Cart) (PaymentSelection, error)
NewDefaultPaymentSelection returns a PaymentSelection that can be used to update the cart is able to include gift card charges if applied to cart
func NewPaymentSelection ¶
func NewPaymentSelection(gateway string, chargedItems PaymentSplitByItem) PaymentSelection
NewPaymentSelection - with the passed PaymentSplitByItem
func RemoveZeroCharges ¶
func RemoveZeroCharges(selection PaymentSelection, chargeTypeToPaymentMethod map[string]string) PaymentSelection
RemoveZeroCharges removes charges which have an value of zero from selection as they are necessary for our internal calculations but not for external clients, we assume zero charges are ignored moreover charges are transformed to pay ables
type PaymentSplit ¶
type PaymentSplit map[SplitQualifier]price.Charge
PaymentSplit represents the Charges qualified by Charge Type, Charge Reference and Payment Method
func (PaymentSplit) ChargesByType ¶
func (s PaymentSplit) ChargesByType() price.Charges
ChargesByType returns Charges (a list of Charges summed by Type)
func (PaymentSplit) MarshalJSON ¶
func (s PaymentSplit) MarshalJSON() ([]byte, error)
MarshalJSON serialize to json
func (PaymentSplit) TotalValue ¶
func (s PaymentSplit) TotalValue() price.Price
TotalValue returns the sum of the valued Price in the included Charges in this Split
func (*PaymentSplit) UnmarshalJSON ¶
func (s *PaymentSplit) UnmarshalJSON(data []byte) error
UnmarshalJSON deserialize from json
type PaymentSplitByItem ¶
type PaymentSplitByItem struct { CartItems map[string]PaymentSplit ShippingItems map[string]PaymentSplit TotalItems map[string]PaymentSplit }
PaymentSplitByItem - similar to value object that contains items of the different possible types, that have a price
func (PaymentSplitByItem) Sum ¶
func (c PaymentSplitByItem) Sum() PaymentSplit
Sum - the resulting Split after sum all the included item split
type PaymentSplitByItemBuilder ¶
type PaymentSplitByItemBuilder struct {
// contains filtered or unexported fields
}
PaymentSplitByItemBuilder - Builder to get valid PaymentSplitByItem instances
func (*PaymentSplitByItemBuilder) AddCartItem ¶
func (pb *PaymentSplitByItemBuilder) AddCartItem(id string, method string, charge price.Charge) *PaymentSplitByItemBuilder
AddCartItem - adds a cartitems charge to the PaymentSplitByItem
func (*PaymentSplitByItemBuilder) AddShippingItem ¶
func (pb *PaymentSplitByItemBuilder) AddShippingItem(deliveryCode string, method string, charge price.Charge) *PaymentSplitByItemBuilder
AddShippingItem - adds shipping charge
func (*PaymentSplitByItemBuilder) AddTotalItem ¶
func (pb *PaymentSplitByItemBuilder) AddTotalItem(totalType string, method string, charge price.Charge) *PaymentSplitByItemBuilder
AddTotalItem - adds totalitem charge
func (*PaymentSplitByItemBuilder) Build ¶
func (pb *PaymentSplitByItemBuilder) Build() PaymentSplitByItem
Build - returns the instance of PaymentSplitByItem
type PaymentSplitService ¶
type PaymentSplitService struct{}
PaymentSplitService enables the creation of a PaymentSplitByItem following different payment methods
func (PaymentSplitService) SplitWithGiftCards ¶
func (service PaymentSplitService) SplitWithGiftCards(chargeTypeToPaymentMethod map[string]string, items PricedItems, cards AppliedGiftCards) (*PaymentSplitByItem, error)
SplitWithGiftCards calculates a payment selection based on given method, priced items and applied gift cards
type Person ¶
type Person struct { Address *Address PersonalDetails PersonalDetails //ExistingCustomerData if the current purchaser is an existing customer - this contains infos about existing customer ExistingCustomerData *ExistingCustomerData }
Person value object
type PersonalDetails ¶
type PersonalDetails struct { DateOfBirth string PassportCountry string PassportNumber string Nationality string }
PersonalDetails value object
type PricedItems ¶
type PricedItems struct {
// contains filtered or unexported fields
}
PricedItems - value object that contains items of the different possible types, that have a price
func (PricedItems) CartItems ¶
func (p PricedItems) CartItems() map[string]domain.Price
CartItems - returns the Price per cartItems - map key is cartitem ID
func (PricedItems) ShippingItems ¶
func (p PricedItems) ShippingItems() map[string]domain.Price
ShippingItems - returns the Price per ShippingItems - map key is deliverycode
func (PricedItems) Sum ¶
func (p PricedItems) Sum() domain.Price
Sum - returns Sum of all items in this struct
func (PricedItems) TotalItems ¶
func (p PricedItems) TotalItems() map[string]domain.Price
TotalItems - returns the Price per Totalitem - map key is total type
type ShippingItem ¶
type ShippingItem struct { Title string PriceNet priceDomain.Price TaxAmount priceDomain.Price AppliedDiscounts AppliedDiscounts }
ShippingItem value object
func (*ShippingItem) HasAppliedDiscounts ¶
func (s *ShippingItem) HasAppliedDiscounts() (bool, error)
HasAppliedDiscounts checks whether there are any discounts currently applied to the shipping item
func (*ShippingItem) MergeDiscounts ¶
func (s *ShippingItem) MergeDiscounts() (AppliedDiscounts, error)
MergeDiscounts parses discounts of a shipping item All discounts with the same campaign code are aggregated and returned as one with a summed price
func (ShippingItem) TotalWithDiscountInclTax ¶
func (s ShippingItem) TotalWithDiscountInclTax() priceDomain.Price
TotalWithDiscountInclTax - the price the customer need to pay for the shipping
type SplitQualifier ¶
SplitQualifier qualifies by Charge Type, Charge Reference and Payment Method
type Taxes ¶
type Taxes []Tax
Taxes is a list of Tax
func (Taxes) AddTaxWithMerge ¶
AddTaxWithMerge returns new Taxes with this Tax added
func (Taxes) AddTaxesWithMerge ¶
AddTaxesWithMerge - returns new Taxes with the given Taxes all added or merged in
func (Taxes) TotalAmount ¶
TotalAmount - returns the sum of all taxes as price
type WithDiscount ¶
type WithDiscount interface { HasAppliedDiscounts() (bool, error) MergeDiscounts() (AppliedDiscounts, error) }
WithDiscount interface for a cart that is able to handle discounts