Merge pull request #216 from medusajs/hotfix/klarna-swap
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)
|
||||
|
||||
if (discount_total) {
|
||||
if (discount_total > 0) {
|
||||
order.order_lines.push({
|
||||
name: `Discount`,
|
||||
quantity: 1,
|
||||
@@ -113,6 +113,16 @@ class KlarnaProviderService extends PaymentService {
|
||||
total_amount: -discount_total * (1 + 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) {
|
||||
|
||||
Reference in New Issue
Block a user