fix(medusa-payment-klarna): Default shipping fee name in Klarna plugin (#926)
This commit is contained in:
committed by
GitHub
parent
e4d4fd7671
commit
8782016095
@@ -61,15 +61,21 @@ export const carts = {
|
||||
shipping_methods: [
|
||||
{
|
||||
id: IdMap.getId("freeShipping"),
|
||||
name: "Free shipping",
|
||||
data: {
|
||||
name: "test",
|
||||
},
|
||||
shipping_option: {
|
||||
id: IdMap.getId("freeShipping"),
|
||||
name: "Free shipping",
|
||||
},
|
||||
profile_id: "default_profile",
|
||||
},
|
||||
],
|
||||
shipping_options: [
|
||||
{
|
||||
id: IdMap.getId("freeShipping"),
|
||||
name: "Free shipping",
|
||||
profile_id: "default_profile",
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
jest.unmock("axios")
|
||||
import axios from "axios"
|
||||
import MockAdapter from "axios-mock-adapter"
|
||||
|
||||
import KlarnaProviderService from "../klarna-provider"
|
||||
import { carts } from "../../__mocks__/cart"
|
||||
import { TotalsServiceMock } from "../../__mocks__/totals"
|
||||
import { RegionServiceMock } from "../../__mocks__/region"
|
||||
import { TotalsServiceMock } from "../../__mocks__/totals"
|
||||
import KlarnaProviderService from "../klarna-provider"
|
||||
|
||||
describe("KlarnaProviderService", () => {
|
||||
describe("createPayment", () => {
|
||||
@@ -38,7 +36,6 @@ describe("KlarnaProviderService", () => {
|
||||
it("creates Klarna order", async () => {
|
||||
const result = await klarnaProviderService.createPayment(carts.frCart)
|
||||
|
||||
// expect(mockAxios.post).toHaveBeenCalledTimes(1)
|
||||
expect(result).toEqual({
|
||||
order_id: "123456789",
|
||||
order_amount: 100,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ from "lodash"
|
||||
import axios from "axios"
|
||||
import _ from "lodash"
|
||||
import { PaymentService } from "medusa-interfaces"
|
||||
|
||||
class KlarnaProviderService extends PaymentService {
|
||||
@@ -68,7 +68,7 @@ class KlarnaProviderService extends PaymentService {
|
||||
if (cart.shipping_methods.length) {
|
||||
const { name, price } = cart.shipping_methods.reduce(
|
||||
(acc, next) => {
|
||||
acc.name = [...acc.name, next.data.name]
|
||||
acc.name = [...acc.name, next?.shipping_option.name]
|
||||
acc.price += next.price
|
||||
return acc
|
||||
},
|
||||
@@ -76,7 +76,7 @@ class KlarnaProviderService extends PaymentService {
|
||||
)
|
||||
|
||||
order_lines.push({
|
||||
name: name.join(" + "),
|
||||
name: name?.join(" + ") || "Shipping fee",
|
||||
quantity: 1,
|
||||
type: "shipping_fee",
|
||||
unit_price: price * (1 + tax),
|
||||
|
||||
Reference in New Issue
Block a user