fix: klarna doesn't treat negative discounts well
This commit is contained in:
@@ -102,7 +102,7 @@ class KlarnaProviderService extends PaymentService {
|
|||||||
|
|
||||||
order.order_lines = await this.lineItemsToOrderLines_(cart, region.tax_rate)
|
order.order_lines = await this.lineItemsToOrderLines_(cart, region.tax_rate)
|
||||||
|
|
||||||
if (discount_total) {
|
if (discount_total > 0) {
|
||||||
order.order_lines.push({
|
order.order_lines.push({
|
||||||
name: `Discount`,
|
name: `Discount`,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
@@ -113,6 +113,16 @@ class KlarnaProviderService extends PaymentService {
|
|||||||
total_amount: -discount_total * (1 + taxRate),
|
total_amount: -discount_total * (1 + taxRate),
|
||||||
total_tax_amount: -discount_total * taxRate,
|
total_tax_amount: -discount_total * taxRate,
|
||||||
})
|
})
|
||||||
|
} else if (discount_total < 0) {
|
||||||
|
order.order_lines.push({
|
||||||
|
name: `Discount Payback`,
|
||||||
|
quantity: 1,
|
||||||
|
type: "surcharge",
|
||||||
|
unit_price: -discount_total * (1 + taxRate),
|
||||||
|
tax_rate: taxRate * 10000,
|
||||||
|
total_amount: -discount_total * (1 + taxRate),
|
||||||
|
total_tax_amount: -discount_total * taxRate,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gift_card_total) {
|
if (gift_card_total) {
|
||||||
|
|||||||
Reference in New Issue
Block a user