diff --git a/cart-grain.go b/cart-grain.go index a07ebf4..9d9fecf 100644 --- a/cart-grain.go +++ b/cart-grain.go @@ -311,8 +311,8 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa if msg.Tax > 0 { tax = int(msg.Tax) } - total := int(msg.Price) * int(msg.Quantity) - taxAmount := GetTaxAmount(total, tax) + + taxAmount := GetTaxAmount(int(msg.Price), tax) c.Items = append(c.Items, &CartItem{ Id: c.lastItemId, @@ -466,13 +466,13 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa } else { orderLines := make([]*Line, 0, len(c.Items)) - totalTax := 0 + c.PaymentInProgress = true c.Processing = true for _, item := range c.Items { total := int(item.Price) * item.Quantity - taxAmount := GetTaxAmount(total, item.Tax) - totalTax += taxAmount + taxAmount := int(item.Tax) * item.Quantity + orderLines = append(orderLines, &Line{ Type: "physical", Reference: item.Sku, @@ -491,7 +491,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa PurchaseCurrency: "SEK", Locale: "sv-se", OrderAmount: int(c.TotalPrice), - OrderTaxAmount: totalTax, + OrderTaxAmount: int(c.TotalTax), OrderLines: orderLines, MerchantReference1: c.Id.String(), MerchantURLS: &CheckoutMerchantURLS{