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