chore: merge develop
This commit is contained in:
commit
b20d5c7150
78 files changed
+1131
-173
No files matched your search
@@ -100,11 +100,12 @@ describe("/admin/orders", () => {
|
|||||||
await manager.query(`DELETE FROM "fulfillment_item"`);
|
await manager.query(`DELETE FROM "fulfillment_item"`);
|
||||||
await manager.query(`DELETE FROM "fulfillment"`);
|
await manager.query(`DELETE FROM "fulfillment"`);
|
||||||
await manager.query(`DELETE FROM "swap"`);
|
await manager.query(`DELETE FROM "swap"`);
|
||||||
await manager.query(`DELETE FROM "return"`);
|
|
||||||
await manager.query(`DELETE FROM "claim_image"`);
|
await manager.query(`DELETE FROM "claim_image"`);
|
||||||
await manager.query(`DELETE FROM "claim_tag"`);
|
await manager.query(`DELETE FROM "claim_tag"`);
|
||||||
await manager.query(`DELETE FROM "claim_item"`);
|
await manager.query(`DELETE FROM "claim_item"`);
|
||||||
await manager.query(`DELETE FROM "shipping_method"`);
|
await manager.query(`DELETE FROM "shipping_method"`);
|
||||||
|
await manager.query(`DELETE FROM "return_item"`);
|
||||||
|
await manager.query(`DELETE FROM "return"`);
|
||||||
await manager.query(`DELETE FROM "line_item"`);
|
await manager.query(`DELETE FROM "line_item"`);
|
||||||
await manager.query(`DELETE FROM "claim_order"`);
|
await manager.query(`DELETE FROM "claim_order"`);
|
||||||
await manager.query(`DELETE FROM "money_amount"`);
|
await manager.query(`DELETE FROM "money_amount"`);
|
||||||
@@ -178,6 +179,72 @@ describe("/admin/orders", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("creates a claim with return shipping", async () => {
|
||||||
|
const api = useApi();
|
||||||
|
|
||||||
|
const response = await api.post(
|
||||||
|
"/admin/orders/test-order/claims",
|
||||||
|
{
|
||||||
|
type: "replace",
|
||||||
|
claim_items: [
|
||||||
|
{
|
||||||
|
item_id: "test-item",
|
||||||
|
quantity: 1,
|
||||||
|
reason: "production_failure",
|
||||||
|
tags: ["fluff"],
|
||||||
|
images: ["https://test.image.com"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
additional_items: [
|
||||||
|
{
|
||||||
|
variant_id: "test-variant",
|
||||||
|
quantity: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
return_shipping: { option_id: "test-return-option", price: 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
authorization: "Bearer test_token",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
expect(response.status).toEqual(200);
|
||||||
|
|
||||||
|
expect(response.data.order.claims[0].claim_items).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
item_id: "test-item",
|
||||||
|
quantity: 1,
|
||||||
|
reason: "production_failure",
|
||||||
|
images: expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
url: "https://test.image.com",
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(response.data.order.claims[0].additional_items).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
variant_id: "test-variant",
|
||||||
|
quantity: 1,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
response.data.order.claims[0].return_order.shipping_method
|
||||||
|
).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
price: 0,
|
||||||
|
shipping_option_id: "test-return-option",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("updates a claim", async () => {
|
it("updates a claim", async () => {
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,19 @@ describe("/store/carts", () => {
|
|||||||
let medusaProcess;
|
let medusaProcess;
|
||||||
let dbConnection;
|
let dbConnection;
|
||||||
|
|
||||||
|
const doAfterEach = async (manager) => {
|
||||||
|
await manager.query(`DELETE FROM "discount"`);
|
||||||
|
await manager.query(`DELETE FROM "discount_rule"`);
|
||||||
|
await manager.query(`DELETE FROM "shipping_method"`);
|
||||||
|
await manager.query(`DELETE FROM "shipping_option"`);
|
||||||
|
await manager.query(`DELETE FROM "cart"`);
|
||||||
|
await manager.query(`DELETE FROM "customer"`);
|
||||||
|
await manager.query(
|
||||||
|
`UPDATE "country" SET region_id=NULL WHERE iso_2 = 'us'`
|
||||||
|
);
|
||||||
|
await manager.query(`DELETE FROM "region"`);
|
||||||
|
};
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||||
dbConnection = await initDb({ cwd });
|
dbConnection = await initDb({ cwd });
|
||||||
@@ -43,13 +56,7 @@ describe("/store/carts", () => {
|
|||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
const manager = dbConnection.manager;
|
const manager = dbConnection.manager;
|
||||||
await manager.query(`DELETE FROM "cart"`);
|
await doAfterEach(manager);
|
||||||
await manager.query(`DELETE FROM "discount"`);
|
|
||||||
await manager.query(`DELETE FROM "discount_rule"`);
|
|
||||||
await manager.query(
|
|
||||||
`UPDATE "country" SET region_id=NULL WHERE iso_2 = 'us'`
|
|
||||||
);
|
|
||||||
await manager.query(`DELETE FROM "region"`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates a cart", async () => {
|
it("creates a cart", async () => {
|
||||||
@@ -108,14 +115,7 @@ describe("/store/carts", () => {
|
|||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
const manager = dbConnection.manager;
|
const manager = dbConnection.manager;
|
||||||
await manager.query(`DELETE FROM "cart"`);
|
await doAfterEach(manager);
|
||||||
await manager.query(`DELETE FROM "discount"`);
|
|
||||||
await manager.query(`DELETE FROM "discount_rule"`);
|
|
||||||
await manager.query(`DELETE FROM "customer"`);
|
|
||||||
await manager.query(
|
|
||||||
`UPDATE "country" SET region_id=NULL WHERE iso_2 = 'us'`
|
|
||||||
);
|
|
||||||
await manager.query(`DELETE FROM "region"`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fails on apply discount if limit has been reached", async () => {
|
it("fails on apply discount if limit has been reached", async () => {
|
||||||
@@ -142,6 +142,73 @@ describe("/store/carts", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200);
|
expect(response.status).toEqual(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("adds free shipping to cart then removes it again", async () => {
|
||||||
|
const api = useApi();
|
||||||
|
|
||||||
|
let cart = await api.post(
|
||||||
|
"/store/carts/test-cart",
|
||||||
|
{
|
||||||
|
discounts: [{ code: "FREE_SHIPPING" }, { code: "CREATED" }],
|
||||||
|
},
|
||||||
|
{ withCredentials: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(cart.data.cart.shipping_total).toBe(0);
|
||||||
|
expect(cart.status).toEqual(200);
|
||||||
|
|
||||||
|
cart = await api.post(
|
||||||
|
"/store/carts/test-cart",
|
||||||
|
{
|
||||||
|
discounts: [{ code: "CREATED" }],
|
||||||
|
},
|
||||||
|
{ withCredentials: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(cart.data.cart.shipping_total).toBe(1000);
|
||||||
|
expect(cart.status).toEqual(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("DELETE /store/carts/:id/discounts/:code", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
try {
|
||||||
|
await cartSeeder(dbConnection);
|
||||||
|
await dbConnection.manager.query(
|
||||||
|
`INSERT INTO "cart_discounts" (cart_id, discount_id) VALUES ('test-cart', 'free-shipping')`
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
const manager = dbConnection.manager;
|
||||||
|
await doAfterEach(manager);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removes free shipping and updates shipping total", async () => {
|
||||||
|
const api = useApi();
|
||||||
|
|
||||||
|
const cartWithFreeShipping = await api.post(
|
||||||
|
"/store/carts/test-cart",
|
||||||
|
{
|
||||||
|
discounts: [{ code: "FREE_SHIPPING" }],
|
||||||
|
},
|
||||||
|
{ withCredentials: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(cartWithFreeShipping.data.cart.shipping_total).toBe(0);
|
||||||
|
expect(cartWithFreeShipping.status).toEqual(200);
|
||||||
|
|
||||||
|
const response = await api.delete(
|
||||||
|
"/store/carts/test-cart/discounts/FREE_SHIPPING"
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(response.data.cart.shipping_total).toBe(1000);
|
||||||
|
expect(response.status).toEqual(200);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("get-cart with session customer", () => {
|
describe("get-cart with session customer", () => {
|
||||||
@@ -156,14 +223,7 @@ describe("/store/carts", () => {
|
|||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
const manager = dbConnection.manager;
|
const manager = dbConnection.manager;
|
||||||
await manager.query(`DELETE FROM "cart"`);
|
await doAfterEach(manager);
|
||||||
await manager.query(`DELETE FROM "discount"`);
|
|
||||||
await manager.query(`DELETE FROM "discount_rule"`);
|
|
||||||
await manager.query(`DELETE FROM "customer"`);
|
|
||||||
await manager.query(
|
|
||||||
`UPDATE "country" SET region_id=NULL WHERE iso_2 = 'us'`
|
|
||||||
);
|
|
||||||
await manager.query(`DELETE FROM "region"`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updates empty cart.customer_id on cart retrieval", async () => {
|
it("updates empty cart.customer_id on cart retrieval", async () => {
|
||||||
|
|||||||
@@ -4,11 +4,18 @@ const {
|
|||||||
Cart,
|
Cart,
|
||||||
DiscountRule,
|
DiscountRule,
|
||||||
Discount,
|
Discount,
|
||||||
|
ShippingProfile,
|
||||||
|
ShippingOption,
|
||||||
|
ShippingMethod,
|
||||||
} = require("@medusajs/medusa");
|
} = require("@medusajs/medusa");
|
||||||
|
|
||||||
module.exports = async (connection, data = {}) => {
|
module.exports = async (connection, data = {}) => {
|
||||||
const manager = connection.manager;
|
const manager = connection.manager;
|
||||||
|
|
||||||
|
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||||
|
type: "default",
|
||||||
|
});
|
||||||
|
|
||||||
const r = manager.create(Region, {
|
const r = manager.create(Region, {
|
||||||
id: "test-region",
|
id: "test-region",
|
||||||
name: "Test Region",
|
name: "Test Region",
|
||||||
@@ -16,24 +23,26 @@ module.exports = async (connection, data = {}) => {
|
|||||||
tax_rate: 0,
|
tax_rate: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
await manager.insert(DiscountRule, {
|
const freeRule = manager.create(DiscountRule, {
|
||||||
id: "test-discount-rule",
|
id: "free-shipping-rule",
|
||||||
description: "Dynamic rule",
|
description: "Free shipping rule",
|
||||||
type: "percentage",
|
type: "free_shipping",
|
||||||
value: 10,
|
value: 100,
|
||||||
allocation: "total",
|
allocation: "total",
|
||||||
});
|
});
|
||||||
|
|
||||||
await manager.insert(Discount, {
|
const freeDisc = manager.create(Discount, {
|
||||||
id: "test-discount",
|
id: "free-shipping",
|
||||||
code: "DYNAMIC",
|
code: "FREE_SHIPPING",
|
||||||
rule_id: "test-discount-rule",
|
is_dynamic: false,
|
||||||
is_dynamic: true,
|
|
||||||
usage_count: 0,
|
|
||||||
usage_limit: 1,
|
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
freeDisc.regions = [r];
|
||||||
|
freeDisc.rule = freeRule;
|
||||||
|
|
||||||
|
await manager.save(freeDisc);
|
||||||
|
|
||||||
const d = await manager.create(Discount, {
|
const d = await manager.create(Discount, {
|
||||||
id: "test-discount",
|
id: "test-discount",
|
||||||
code: "CREATED",
|
code: "CREATED",
|
||||||
@@ -73,6 +82,17 @@ module.exports = async (connection, data = {}) => {
|
|||||||
email: "some-customer@email.com",
|
email: "some-customer@email.com",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await manager.insert(ShippingOption, {
|
||||||
|
id: "test-option",
|
||||||
|
name: "test-option",
|
||||||
|
provider_id: "test-ful",
|
||||||
|
region_id: "test-region",
|
||||||
|
profile_id: defaultProfile.id,
|
||||||
|
price_type: "flat_rate",
|
||||||
|
amount: 1000,
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
|
|
||||||
const cart = manager.create(Cart, {
|
const cart = manager.create(Cart, {
|
||||||
id: "test-cart",
|
id: "test-cart",
|
||||||
customer_id: "some-customer",
|
customer_id: "some-customer",
|
||||||
@@ -88,4 +108,12 @@ module.exports = async (connection, data = {}) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await manager.save(cart);
|
await manager.save(cart);
|
||||||
|
|
||||||
|
await manager.insert(ShippingMethod, {
|
||||||
|
id: "test-method",
|
||||||
|
shipping_option_id: "test-option",
|
||||||
|
cart_id: "test-cart",
|
||||||
|
price: 1000,
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
@@ -94,6 +94,18 @@ module.exports = async (connection, data = {}) => {
|
|||||||
data: {},
|
data: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await manager.insert(ShippingOption, {
|
||||||
|
id: "test-return-option",
|
||||||
|
name: "Test ret",
|
||||||
|
profile_id: defaultProfile.id,
|
||||||
|
region_id: "test-region",
|
||||||
|
provider_id: "test-ful",
|
||||||
|
data: {},
|
||||||
|
price_type: "flat_rate",
|
||||||
|
amount: 1000,
|
||||||
|
is_return: true,
|
||||||
|
});
|
||||||
|
|
||||||
const order = manager.create(Order, {
|
const order = manager.create(Order, {
|
||||||
id: "test-order",
|
id: "test-order",
|
||||||
customer_id: "test-customer",
|
customer_id: "test-customer",
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.3](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.0...babel-preset-medusa-package@1.1.3) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package babel-preset-medusa-package
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.2](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.1...babel-preset-medusa-package@1.1.2) (2021-04-20)
|
## [1.1.2](https://github.com/medusajs/medusa/compare/babel-preset-medusa-package@1.1.1...babel-preset-medusa-package@1.1.2) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package babel-preset-medusa-package
|
**Note:** Version bump only for package babel-preset-medusa-package
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-preset-medusa-package",
|
"name": "babel-preset-medusa-package",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"author": "Sebastian Rindom <sebastian@mrbltech.com>",
|
"author": "Sebastian Rindom <sebastian@mrbltech.com>",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
.env
|
.env
|
||||||
dist/
|
dist/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
|
.env
|
||||||
@@ -3,3 +3,4 @@ src
|
|||||||
.eslintrc
|
.eslintrc
|
||||||
.gitignore
|
.gitignore
|
||||||
.prettierrc
|
.prettierrc
|
||||||
|
.env
|
||||||
@@ -3,6 +3,22 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.8](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.7...@medusajs/medusa-cli@1.1.8) (2021-05-05)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @medusajs/medusa-cli
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [1.1.7](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.4...@medusajs/medusa-cli@1.1.7) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @medusajs/medusa-cli
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.6](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.5...@medusajs/medusa-cli@1.1.6) (2021-04-20)
|
## [1.1.6](https://github.com/medusajs/medusa/compare/@medusajs/medusa-cli@1.1.5...@medusajs/medusa-cli@1.1.6) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package @medusajs/medusa-cli
|
**Note:** Version bump only for package @medusajs/medusa-cli
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@medusajs/medusa-cli",
|
"name": "@medusajs/medusa-cli",
|
||||||
"version": "1.1.6",
|
"version": "1.1.8",
|
||||||
"description": "Command Line interface for Medusa Commerce",
|
"description": "Command Line interface for Medusa Commerce",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.6...medusa-core-utils@1.1.9) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-core-utils
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.7...medusa-core-utils@1.1.8) (2021-04-20)
|
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-core-utils@1.1.7...medusa-core-utils@1.1.8) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-core-utils
|
**Note:** Version bump only for package medusa-core-utils
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-core-utils",
|
"name": "medusa-core-utils",
|
||||||
"version": "1.1.8",
|
"version": "1.1.9",
|
||||||
"description": "Core utils for Medusa",
|
"description": "Core utils for Medusa",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [0.0.8](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.5...medusa-dev-cli@0.0.8) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-dev-cli
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0.0.7](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.6...medusa-dev-cli@0.0.7) (2021-04-20)
|
## [0.0.7](https://github.com/medusajs/medusa/compare/medusa-dev-cli@0.0.6...medusa-dev-cli@0.0.7) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-dev-cli
|
**Note:** Version bump only for package medusa-dev-cli
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-dev-cli",
|
"name": "medusa-dev-cli",
|
||||||
"description": "CLI helpers for contributors working on Medusa",
|
"description": "CLI helpers for contributors working on Medusa",
|
||||||
"version": "0.0.7",
|
"version": "0.0.8",
|
||||||
"author": "Sebastian Rindom <skrindom@gmail.com>",
|
"author": "Sebastian Rindom <skrindom@gmail.com>",
|
||||||
"bin": {
|
"bin": {
|
||||||
"medusa-dev": "./dist/index.js"
|
"medusa-dev": "./dist/index.js"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.12.1",
|
"@babel/cli": "^7.12.1",
|
||||||
"@babel/core": "^7.12.3",
|
"@babel/core": "^7.12.3",
|
||||||
"babel-preset-medusa-package": "^1.1.2",
|
"babel-preset-medusa-package": "^1.1.3",
|
||||||
"cross-env": "^7.0.3"
|
"cross-env": "^7.0.3"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/medusajs/medusa/tree/master/packages/medusa-dev-cli#readme",
|
"homepage": "https://github.com/medusajs/medusa/tree/master/packages/medusa-dev-cli#readme",
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.9...medusa-file-spaces@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-file-spaces
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.10...medusa-file-spaces@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-file-spaces@1.1.10...medusa-file-spaces@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-file-spaces
|
**Note:** Version bump only for package medusa-file-spaces
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-file-spaces",
|
"name": "medusa-file-spaces",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Digital Ocean Spaces file connector for Medusa",
|
"description": "Digital Ocean Spaces file connector for Medusa",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -40,8 +40,8 @@
|
|||||||
"aws-sdk": "^2.710.0",
|
"aws-sdk": "^2.710.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"stripe": "^8.50.0"
|
"stripe": "^8.50.0"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.6...medusa-fulfillment-manual@1.1.9) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-fulfillment-manual
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.7...medusa-fulfillment-manual@1.1.8) (2021-04-20)
|
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-fulfillment-manual@1.1.7...medusa-fulfillment-manual@1.1.8) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-fulfillment-manual
|
**Note:** Version bump only for package medusa-fulfillment-manual
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-fulfillment-manual",
|
"name": "medusa-fulfillment-manual",
|
||||||
"version": "1.1.8",
|
"version": "1.1.9",
|
||||||
"description": "A manual fulfillment provider for Medusa",
|
"description": "A manual fulfillment provider for Medusa",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||||
"@babel/runtime": "^7.7.6",
|
"@babel/runtime": "^7.7.6",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8"
|
"medusa-core-utils": "^1.1.9"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,22 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.12...medusa-fulfillment-webshipper@1.1.13) (2021-05-05)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-fulfillment-webshipper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.9...medusa-fulfillment-webshipper@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-fulfillment-webshipper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.10...medusa-fulfillment-webshipper@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-fulfillment-webshipper@1.1.10...medusa-fulfillment-webshipper@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-fulfillment-webshipper
|
**Note:** Version bump only for package medusa-fulfillment-webshipper
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ A webhook listener is exposed at `/webshipper/shipments` to listen for shipment
|
|||||||
api_token: [a webshipper api token] (required)
|
api_token: [a webshipper api token] (required)
|
||||||
order_channel_id: [the channel id to register orders on] (required)
|
order_channel_id: [the channel id to register orders on] (required)
|
||||||
webhook_secret: [the webhook secret used to listen for shipments] (required)
|
webhook_secret: [the webhook secret used to listen for shipments] (required)
|
||||||
|
coo_countries: [an array of countries in which a Certificate of Origin will be attached] (default: "all")
|
||||||
```
|
```
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-fulfillment-webshipper",
|
"name": "medusa-fulfillment-webshipper",
|
||||||
"version": "1.1.11",
|
"version": "1.1.13",
|
||||||
"description": "Webshipper Fulfillment provider for Medusa",
|
"description": "Webshipper Fulfillment provider for Medusa",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8"
|
"medusa-core-utils": "^1.1.9"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,16 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
|||||||
|
|
||||||
this.options_ = options
|
this.options_ = options
|
||||||
|
|
||||||
|
if (!options.coo_countries) {
|
||||||
|
this.options_.coo_countries = ["all"]
|
||||||
|
} else if (Array.isArray(options.coo_countries)) {
|
||||||
|
this.options_.coo_countries = options.coo_countries.map((c) =>
|
||||||
|
c.toLowerCase()
|
||||||
|
)
|
||||||
|
} else if (typeof options.coo_countries === "string") {
|
||||||
|
this.options_.coo_countries = [options.coo_countries]
|
||||||
|
}
|
||||||
|
|
||||||
/** @private @const {logger} */
|
/** @private @const {logger} */
|
||||||
this.logger_ = logger
|
this.logger_ = logger
|
||||||
|
|
||||||
@@ -242,6 +252,8 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
|||||||
webshipperOrder = await this.client_.orders.retrieve(existing)
|
webshipperOrder = await this.client_.orders.retrieve(existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { shipping_address } = fromOrder
|
||||||
|
|
||||||
if (!webshipperOrder) {
|
if (!webshipperOrder) {
|
||||||
let invoice
|
let invoice
|
||||||
let certificateOfOrigin
|
let certificateOfOrigin
|
||||||
@@ -266,7 +278,14 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
|||||||
throw err
|
throw err
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.invoiceGenerator_.createCertificateOfOrigin) {
|
const cooCountries = this.options_.coo_countries
|
||||||
|
if (
|
||||||
|
(cooCountries.includes("all") ||
|
||||||
|
cooCountries.includes(
|
||||||
|
shipping_address.country_code.toLowerCase()
|
||||||
|
)) &&
|
||||||
|
this.invoiceGenerator_.createCertificateOfOrigin
|
||||||
|
) {
|
||||||
const base64Coo = await this.invoiceGenerator_.createCertificateOfOrigin(
|
const base64Coo = await this.invoiceGenerator_.createCertificateOfOrigin(
|
||||||
fromOrder,
|
fromOrder,
|
||||||
fulfillmentItems
|
fulfillmentItems
|
||||||
@@ -297,7 +316,6 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
|||||||
visible_ref = `S-${fromOrder.display_id}`
|
visible_ref = `S-${fromOrder.display_id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const { shipping_address } = fromOrder
|
|
||||||
const newOrder = {
|
const newOrder = {
|
||||||
type: "orders",
|
type: "orders",
|
||||||
attributes: {
|
attributes: {
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.7...medusa-interfaces@1.1.10) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-interfaces
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.8...medusa-interfaces@1.1.9) (2021-04-20)
|
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-interfaces@1.1.8...medusa-interfaces@1.1.9) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-interfaces
|
**Note:** Version bump only for package medusa-interfaces
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-interfaces",
|
"name": "medusa-interfaces",
|
||||||
"version": "1.1.9",
|
"version": "1.1.10",
|
||||||
"description": "Core interfaces for Medusa",
|
"description": "Core interfaces for Medusa",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
"typeorm": "0.x"
|
"typeorm": "0.x"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"medusa-core-utils": "^1.1.8"
|
"medusa-core-utils": "^1.1.9"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.9...medusa-payment-adyen@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-payment-adyen
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.10...medusa-payment-adyen@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.10...medusa-payment-adyen@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-payment-adyen
|
**Note:** Version bump only for package medusa-payment-adyen
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-payment-adyen",
|
"name": "medusa-payment-adyen",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Adyen Payment provider for Medusa Commerce",
|
"description": "Adyen Payment provider for Medusa Commerce",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"jest": "^25.5.2",
|
"jest": "^25.5.2",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel src -d .",
|
"build": "babel src -d .",
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8"
|
"medusa-core-utils": "^1.1.9"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.10...medusa-payment-klarna@1.1.13) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-payment-klarna
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.11...medusa-payment-klarna@1.1.12) (2021-04-20)
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-payment-klarna@1.1.11...medusa-payment-klarna@1.1.12) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-payment-klarna
|
**Note:** Version bump only for package medusa-payment-klarna
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-payment-klarna",
|
"name": "medusa-payment-klarna",
|
||||||
"version": "1.1.12",
|
"version": "1.1.13",
|
||||||
"description": "Klarna Payment provider for Medusa Commerce",
|
"description": "Klarna Payment provider for Medusa Commerce",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -40,8 +40,8 @@
|
|||||||
"axios": "^0.21.0",
|
"axios": "^0.21.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,22 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.12...medusa-payment-paypal@1.0.13) (2021-04-29)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-payment-paypal
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.9...medusa-payment-paypal@1.0.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-payment-paypal
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.0.11](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.10...medusa-payment-paypal@1.0.11) (2021-04-20)
|
## [1.0.11](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.10...medusa-payment-paypal@1.0.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-payment-paypal
|
**Note:** Version bump only for package medusa-payment-paypal
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-payment-paypal",
|
"name": "medusa-payment-paypal",
|
||||||
"version": "1.0.11",
|
"version": "1.0.13",
|
||||||
"description": "Paypal Payment provider for Meduas Commerce",
|
"description": "Paypal Payment provider for Meduas Commerce",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -26,12 +26,13 @@
|
|||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"jest": "^25.5.2",
|
"jest": "^25.5.2",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-interfaces": "^1.1.10",
|
||||||
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel src -d . --ignore **/__tests__",
|
"build": "babel src -d . --ignore **/__tests__,**/__mocks__",
|
||||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||||
"watch": "babel -w src --out-dir . --ignore **/__tests__",
|
"watch": "babel -w src --out-dir . --ignore **/__tests__,**/__mocks__",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
"@paypal/checkout-server-sdk": "^1.0.2",
|
"@paypal/checkout-server-sdk": "^1.0.2",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8"
|
"medusa-core-utils": "^1.1.9"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
export const PayPalClientMock = {
|
||||||
|
execute: jest.fn().mockImplementation((r) => {
|
||||||
|
return {
|
||||||
|
result: r.result,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PayPalMock = {
|
||||||
|
core: {
|
||||||
|
SandboxEnvironment: function () {
|
||||||
|
this.env = {
|
||||||
|
sandbox: true,
|
||||||
|
live: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
LiveEnvironment: function () {
|
||||||
|
this.env = {
|
||||||
|
sandbox: false,
|
||||||
|
live: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PayPalHttpClient: function () {
|
||||||
|
return PayPalClientMock
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
payments: {
|
||||||
|
AuthorizationsGetRequest: jest.fn().mockImplementation(() => {}),
|
||||||
|
AuthorizationsVoidRequest: jest.fn().mockImplementation(() => {}),
|
||||||
|
AuthorizationsCaptureRequest: jest.fn().mockImplementation(() => {
|
||||||
|
return {
|
||||||
|
result: {
|
||||||
|
id: "test",
|
||||||
|
},
|
||||||
|
capture: true,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
CapturesRefundRequest: jest.fn().mockImplementation(() => {
|
||||||
|
return {
|
||||||
|
result: {
|
||||||
|
id: "test",
|
||||||
|
},
|
||||||
|
body: null,
|
||||||
|
requestBody: function (d) {
|
||||||
|
this.body = d
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
|
||||||
|
orders: {
|
||||||
|
OrdersCreateRequest: jest.fn().mockImplementation(() => {
|
||||||
|
return {
|
||||||
|
result: {
|
||||||
|
id: "test",
|
||||||
|
},
|
||||||
|
order: true,
|
||||||
|
body: null,
|
||||||
|
requestBody: function (d) {
|
||||||
|
this.body = d
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
OrdersPatchRequest: jest.fn().mockImplementation(() => {
|
||||||
|
return {
|
||||||
|
result: {
|
||||||
|
id: "test",
|
||||||
|
},
|
||||||
|
order: true,
|
||||||
|
body: null,
|
||||||
|
requestBody: function (d) {
|
||||||
|
this.body = d
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
OrdersGetRequest: jest.fn().mockImplementation(() => {
|
||||||
|
return {
|
||||||
|
result: {
|
||||||
|
id: "test",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PayPalMock
|
||||||
@@ -0,0 +1,346 @@
|
|||||||
|
import PayPalProviderService from "../paypal-provider"
|
||||||
|
import {
|
||||||
|
PayPalMock,
|
||||||
|
PayPalClientMock,
|
||||||
|
} from "../../__mocks__/@paypal/checkout-server-sdk"
|
||||||
|
|
||||||
|
const TotalsServiceMock = {
|
||||||
|
getTotal: jest.fn().mockImplementation((c) => c.total),
|
||||||
|
}
|
||||||
|
|
||||||
|
const RegionServiceMock = {
|
||||||
|
retrieve: jest.fn().mockImplementation((id) =>
|
||||||
|
Promise.resolve({
|
||||||
|
currency_code: "eur",
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("PaypalProviderService", () => {
|
||||||
|
describe("createPayment", () => {
|
||||||
|
let result
|
||||||
|
const paypalProviderService = new PayPalProviderService(
|
||||||
|
{
|
||||||
|
regionService: RegionServiceMock,
|
||||||
|
totalsService: TotalsServiceMock,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
api_key: "test",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("creates paypal order", async () => {
|
||||||
|
result = await paypalProviderService.createPayment({
|
||||||
|
id: "test_cart",
|
||||||
|
region_id: "fr",
|
||||||
|
total: 1000,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(PayPalMock.orders.OrdersCreateRequest).toHaveBeenCalledTimes(1)
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledTimes(1)
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
order: true,
|
||||||
|
body: {
|
||||||
|
intent: "AUTHORIZE",
|
||||||
|
application_context: {
|
||||||
|
shipping_preference: "NO_SHIPPING",
|
||||||
|
},
|
||||||
|
purchase_units: [
|
||||||
|
{
|
||||||
|
custom_id: "test_cart",
|
||||||
|
amount: {
|
||||||
|
currency_code: "EUR",
|
||||||
|
value: "10.00",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result.id).toEqual("test")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("retrievePayment", () => {
|
||||||
|
let result
|
||||||
|
const paypalProviderService = new PayPalProviderService(
|
||||||
|
{
|
||||||
|
regionService: RegionServiceMock,
|
||||||
|
totalsService: TotalsServiceMock,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
api_key: "test",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("retrieves paypal order", async () => {
|
||||||
|
result = await paypalProviderService.retrievePayment({ id: "test" })
|
||||||
|
expect(PayPalMock.orders.OrdersGetRequest).toHaveBeenCalledTimes(1)
|
||||||
|
expect(PayPalMock.orders.OrdersGetRequest).toHaveBeenCalledWith("test")
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledTimes(1)
|
||||||
|
|
||||||
|
expect(result.id).toEqual("test")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("updatePayment", () => {
|
||||||
|
let result
|
||||||
|
const paypalProviderService = new PayPalProviderService(
|
||||||
|
{
|
||||||
|
regionService: RegionServiceMock,
|
||||||
|
totalsService: TotalsServiceMock,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
api_key: "test",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("updates paypal order", async () => {
|
||||||
|
result = await paypalProviderService.updatePayment(
|
||||||
|
{ id: "test" },
|
||||||
|
{
|
||||||
|
id: "test_cart",
|
||||||
|
region_id: "fr",
|
||||||
|
total: 1000,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(PayPalMock.orders.OrdersPatchRequest).toHaveBeenCalledTimes(1)
|
||||||
|
expect(PayPalMock.orders.OrdersPatchRequest).toHaveBeenCalledWith("test")
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledTimes(1)
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
order: true,
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
op: "replace",
|
||||||
|
path: "/purchase_units/@reference_id=='default'",
|
||||||
|
value: {
|
||||||
|
amount: {
|
||||||
|
currency_code: "EUR",
|
||||||
|
value: "10.00",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result.id).toEqual("test")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("capturePayment", () => {
|
||||||
|
let result
|
||||||
|
const paypalProviderService = new PayPalProviderService(
|
||||||
|
{
|
||||||
|
regionService: RegionServiceMock,
|
||||||
|
totalsService: TotalsServiceMock,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
api_key: "test",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("updates paypal order", async () => {
|
||||||
|
result = await paypalProviderService.capturePayment({
|
||||||
|
data: {
|
||||||
|
id: "test",
|
||||||
|
purchase_units: [
|
||||||
|
{
|
||||||
|
payments: {
|
||||||
|
authorizations: [
|
||||||
|
{
|
||||||
|
id: "test_auth",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(
|
||||||
|
PayPalMock.payments.AuthorizationsCaptureRequest
|
||||||
|
).toHaveBeenCalledTimes(1)
|
||||||
|
expect(
|
||||||
|
PayPalMock.payments.AuthorizationsCaptureRequest
|
||||||
|
).toHaveBeenCalledWith("test_auth")
|
||||||
|
expect(PayPalMock.orders.OrdersGetRequest).toHaveBeenCalledWith("test")
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledTimes(2)
|
||||||
|
|
||||||
|
expect(result.id).toEqual("test")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("refundPayment", () => {
|
||||||
|
let result
|
||||||
|
const paypalProviderService = new PayPalProviderService(
|
||||||
|
{
|
||||||
|
regionService: RegionServiceMock,
|
||||||
|
totalsService: TotalsServiceMock,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
api_key: "test",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("refunds payment", async () => {
|
||||||
|
result = await paypalProviderService.refundPayment(
|
||||||
|
{
|
||||||
|
currency_code: "eur",
|
||||||
|
data: {
|
||||||
|
id: "test",
|
||||||
|
purchase_units: [
|
||||||
|
{
|
||||||
|
payments: {
|
||||||
|
captures: [
|
||||||
|
{
|
||||||
|
id: "test_cap",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
2000
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(PayPalMock.payments.CapturesRefundRequest).toHaveBeenCalledWith(
|
||||||
|
"test_cap"
|
||||||
|
)
|
||||||
|
expect(PayPalMock.orders.OrdersGetRequest).toHaveBeenCalledWith("test")
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledTimes(2)
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
body: {
|
||||||
|
amount: {
|
||||||
|
currency_code: "EUR",
|
||||||
|
value: "20.00",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result.id).toEqual("test")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("doesn't refund without captures", async () => {
|
||||||
|
await expect(
|
||||||
|
paypalProviderService.refundPayment(
|
||||||
|
{
|
||||||
|
currency_code: "eur",
|
||||||
|
data: {
|
||||||
|
id: "test",
|
||||||
|
purchase_units: [
|
||||||
|
{
|
||||||
|
payments: {
|
||||||
|
captures: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
2000
|
||||||
|
)
|
||||||
|
).rejects.toThrow("Order not yet captured")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("cancelPayment", () => {
|
||||||
|
let result
|
||||||
|
const paypalProviderService = new PayPalProviderService(
|
||||||
|
{
|
||||||
|
regionService: RegionServiceMock,
|
||||||
|
totalsService: TotalsServiceMock,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
api_key: "test",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("refunds if captured", async () => {
|
||||||
|
result = await paypalProviderService.cancelPayment({
|
||||||
|
captured_at: "true",
|
||||||
|
currency_code: "eur",
|
||||||
|
data: {
|
||||||
|
id: "test",
|
||||||
|
purchase_units: [
|
||||||
|
{
|
||||||
|
payments: {
|
||||||
|
captures: [
|
||||||
|
{
|
||||||
|
id: "test_cap",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(PayPalMock.payments.CapturesRefundRequest).toHaveBeenCalledWith(
|
||||||
|
"test_cap"
|
||||||
|
)
|
||||||
|
expect(PayPalMock.orders.OrdersGetRequest).toHaveBeenCalledWith("test")
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledTimes(2)
|
||||||
|
|
||||||
|
expect(result.id).toEqual("test")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("voids if not captured", async () => {
|
||||||
|
result = await paypalProviderService.cancelPayment({
|
||||||
|
currency_code: "eur",
|
||||||
|
data: {
|
||||||
|
id: "test",
|
||||||
|
purchase_units: [
|
||||||
|
{
|
||||||
|
payments: {
|
||||||
|
authorizations: [
|
||||||
|
{
|
||||||
|
id: "test_auth",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(
|
||||||
|
PayPalMock.payments.AuthorizationsVoidRequest
|
||||||
|
).toHaveBeenCalledWith("test_auth")
|
||||||
|
expect(PayPalMock.orders.OrdersGetRequest).toHaveBeenCalledWith("test")
|
||||||
|
expect(PayPalClientMock.execute).toHaveBeenCalledTimes(2)
|
||||||
|
|
||||||
|
expect(result.id).toEqual("test")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -5,7 +5,7 @@ import { PaymentService } from "medusa-interfaces"
|
|||||||
class PayPalProviderService extends PaymentService {
|
class PayPalProviderService extends PaymentService {
|
||||||
static identifier = "paypal"
|
static identifier = "paypal"
|
||||||
|
|
||||||
constructor({ customerService, totalsService, regionService }, options) {
|
constructor({ totalsService, regionService }, options) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,9 +35,6 @@ class PayPalProviderService extends PaymentService {
|
|||||||
/** @private @const {PayPalHttpClient} */
|
/** @private @const {PayPalHttpClient} */
|
||||||
this.paypal_ = new PayPal.core.PayPalHttpClient(environment)
|
this.paypal_ = new PayPal.core.PayPalHttpClient(environment)
|
||||||
|
|
||||||
/** @private @const {CustomerService} */
|
|
||||||
this.customerService_ = customerService
|
|
||||||
|
|
||||||
/** @private @const {RegionService} */
|
/** @private @const {RegionService} */
|
||||||
this.regionService_ = regionService
|
this.regionService_ = regionService
|
||||||
|
|
||||||
@@ -196,7 +193,7 @@ class PayPalProviderService extends PaymentService {
|
|||||||
value: {
|
value: {
|
||||||
amount: {
|
amount: {
|
||||||
currency_code: currency_code.toUpperCase(),
|
currency_code: currency_code.toUpperCase(),
|
||||||
value: (cart.total / 100).toFixed(),
|
value: (cart.total / 100).toFixed(2),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -240,7 +237,7 @@ class PayPalProviderService extends PaymentService {
|
|||||||
* Refunds a given amount.
|
* Refunds a given amount.
|
||||||
* @param {object} payment - payment to refund
|
* @param {object} payment - payment to refund
|
||||||
* @param {number} amountToRefund - amount to refund
|
* @param {number} amountToRefund - amount to refund
|
||||||
* @returns {string} the resulting PayPal order
|
* @returns {Promise<Object>} the resulting PayPal order
|
||||||
*/
|
*/
|
||||||
async refundPayment(payment, amountToRefund) {
|
async refundPayment(payment, amountToRefund) {
|
||||||
const { purchase_units } = payment.data
|
const { purchase_units } = payment.data
|
||||||
@@ -257,13 +254,13 @@ class PayPalProviderService extends PaymentService {
|
|||||||
request.requestBody({
|
request.requestBody({
|
||||||
amount: {
|
amount: {
|
||||||
currency_code: payment.currency_code.toUpperCase(),
|
currency_code: payment.currency_code.toUpperCase(),
|
||||||
value: (amountToRefund / 100).toFixed(),
|
value: (amountToRefund / 100).toFixed(2),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
await this.paypal_.execute(request)
|
await this.paypal_.execute(request)
|
||||||
|
|
||||||
return this.retrievePayment(payment.id)
|
return this.retrievePayment(payment.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
@@ -272,7 +269,7 @@ class PayPalProviderService extends PaymentService {
|
|||||||
/**
|
/**
|
||||||
* Cancels payment for Stripe payment intent.
|
* Cancels payment for Stripe payment intent.
|
||||||
* @param {object} paymentData - payment method data from cart
|
* @param {object} paymentData - payment method data from cart
|
||||||
* @returns {object} canceled payment intent
|
* @returns {Promise<object>} canceled payment intent
|
||||||
*/
|
*/
|
||||||
async cancelPayment(payment) {
|
async cancelPayment(payment) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.9...medusa-payment-stripe@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-payment-stripe
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.10...medusa-payment-stripe@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-payment-stripe@1.1.10...medusa-payment-stripe@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-payment-stripe
|
**Note:** Version bump only for package medusa-payment-stripe
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-payment-stripe",
|
"name": "medusa-payment-stripe",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Stripe Payment provider for Meduas Commerce",
|
"description": "Stripe Payment provider for Meduas Commerce",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"jest": "^25.5.2",
|
"jest": "^25.5.2",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel src -d . --ignore **/__tests__",
|
"build": "babel src -d . --ignore **/__tests__",
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"stripe": "^8.50.0"
|
"stripe": "^8.50.0"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.9...medusa-plugin-add-ons@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-add-ons
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.10...medusa-plugin-add-ons@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-add-ons@1.1.10...medusa-plugin-add-ons@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-add-ons
|
**Note:** Version bump only for package medusa-plugin-add-ons
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-add-ons",
|
"name": "medusa-plugin-add-ons",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Add-on plugin for Medusa Commerce",
|
"description": "Add-on plugin for Medusa Commerce",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"jest": "^25.5.2",
|
"jest": "^25.5.2",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel src -d . --ignore **/__tests__",
|
"build": "babel src -d . --ignore **/__tests__",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"redis": "^3.0.2"
|
"redis": "^3.0.2"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,17 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.13...medusa-plugin-brightpearl@1.1.15) (2021-04-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* better inventory sync ([9eaf027](https://github.com/medusajs/medusa/commit/9eaf02762ff1ad455ac5020668ee9106db7c705a))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.13...medusa-plugin-brightpearl@1.1.14) (2021-04-20)
|
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.13...medusa-plugin-brightpearl@1.1.14) (2021-04-20)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-brightpearl",
|
"name": "medusa-plugin-brightpearl",
|
||||||
"version": "1.1.14",
|
"version": "1.1.15",
|
||||||
"description": "Brightpearl plugin for Medusa Commerce",
|
"description": "Brightpearl plugin for Medusa Commerce",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"jest": "^25.5.2",
|
"jest": "^25.5.2",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"prettier": "^2.0.5"
|
"prettier": "^2.0.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"axios-rate-limit": "^1.2.1",
|
"axios-rate-limit": "^1.2.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"randomatic": "^3.1.1"
|
"randomatic": "^3.1.1"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -5,13 +5,9 @@ const inventorySync = async (container, options) => {
|
|||||||
const brightpearlService = container.resolve("brightpearlService")
|
const brightpearlService = container.resolve("brightpearlService")
|
||||||
const eventBus = container.resolve("eventBusService")
|
const eventBus = container.resolve("eventBusService")
|
||||||
try {
|
try {
|
||||||
const client = await brightpearlService.getClient()
|
|
||||||
const pattern = options.inventory_sync_cron
|
const pattern = options.inventory_sync_cron
|
||||||
eventBus.createCronJob(
|
eventBus.createCronJob("inventory-sync", {}, pattern, () =>
|
||||||
"inventory-sync",
|
brightpearlService.syncInventory()
|
||||||
{},
|
|
||||||
pattern,
|
|
||||||
brightpearlService.syncInventory
|
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.name === "not_allowed") {
|
if (err.name === "not_allowed") {
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ class BrightpearlService extends BaseService {
|
|||||||
|
|
||||||
async syncInventory() {
|
async syncInventory() {
|
||||||
const client = await this.getClient()
|
const client = await this.getClient()
|
||||||
const variants = await this.productVariantService_.list()
|
|
||||||
|
|
||||||
let search = true
|
let search = true
|
||||||
let bpProducts = []
|
let bpProducts = []
|
||||||
@@ -141,31 +140,39 @@ class BrightpearlService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bpProducts.length) {
|
if (bpProducts.length) {
|
||||||
const productRange = `${bpProducts[0].productId}-${
|
const productRange = bpProducts
|
||||||
bpProducts[bpProducts.length - 1].productId
|
.map(({ productId }) => productId)
|
||||||
}`
|
.join(",")
|
||||||
|
|
||||||
const availabilities = await client.products.retrieveAvailability(
|
const availabilities = await client.products.retrieveAvailability(
|
||||||
productRange
|
productRange
|
||||||
)
|
)
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
variants.map(async (v) => {
|
bpProducts.map(async (bpProduct) => {
|
||||||
const brightpearlProduct = bpProducts.find(
|
const { SKU: sku, productId } = bpProduct
|
||||||
(prod) => prod.SKU === v.sku
|
|
||||||
)
|
const variant = await this.productVariantService_
|
||||||
if (!brightpearlProduct) {
|
.retrieveBySKU(sku, {
|
||||||
return
|
select: ["id", "manage_inventory", "inventory_quantity"],
|
||||||
|
})
|
||||||
|
.catch((_) => undefined)
|
||||||
|
|
||||||
|
const prodAvail = availabilities[productId]
|
||||||
|
|
||||||
|
let onHand = 0
|
||||||
|
if (
|
||||||
|
prodAvail &&
|
||||||
|
prodAvail.warehouses &&
|
||||||
|
prodAvail.warehouses[`${this.options.warehouse}`]
|
||||||
|
) {
|
||||||
|
onHand = prodAvail.warehouses[`${this.options.warehouse}`].onHand
|
||||||
}
|
}
|
||||||
|
|
||||||
const { productId } = brightpearlProduct
|
if (variant && variant.manage_inventory) {
|
||||||
const availability = availabilities[productId]
|
if (parseInt(variant.inventory_quantity) !== parseInt(onHand)) {
|
||||||
if (availability) {
|
return this.productVariantService_.update(variant.id, {
|
||||||
const onHand = availability.total.onHand
|
inventory_quantity: parseInt(onHand),
|
||||||
|
|
||||||
// Only update if the inventory levels have changed
|
|
||||||
if (parseInt(v.inventory_quantity) !== parseInt(onHand)) {
|
|
||||||
return this.productVariantService_.update(v.id, {
|
|
||||||
inventory_quantity: onHand,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.10...medusa-plugin-contentful@1.1.13) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-contentful
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.11...medusa-plugin-contentful@1.1.12) (2021-04-20)
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.11...medusa-plugin-contentful@1.1.12) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-contentful
|
**Note:** Version bump only for package medusa-plugin-contentful
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-contentful",
|
"name": "medusa-plugin-contentful",
|
||||||
"version": "1.1.12",
|
"version": "1.1.13",
|
||||||
"description": "Contentful plugin for Medusa Commerce",
|
"description": "Contentful plugin for Medusa Commerce",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"contentful-management": "^5.27.1",
|
"contentful-management": "^5.27.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"redis": "^3.0.2"
|
"redis": "^3.0.2"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.0...medusa-plugin-discount-generator@1.1.3) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-discount-generator
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.1...medusa-plugin-discount-generator@1.1.2) (2021-04-20)
|
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-discount-generator@1.1.1...medusa-plugin-discount-generator@1.1.2) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-discount-generator
|
**Note:** Version bump only for package medusa-plugin-discount-generator
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-discount-generator",
|
"name": "medusa-plugin-discount-generator",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Sebastian Rindom",
|
"author": "Sebastian Rindom",
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.9...medusa-plugin-economic@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-economic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.10...medusa-plugin-economic@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.10...medusa-plugin-economic@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-economic
|
**Note:** Version bump only for package medusa-plugin-economic
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-economic",
|
"name": "medusa-plugin-economic",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-economic",
|
"name": "medusa-plugin-economic",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "E-conomic financial reporting",
|
"description": "E-conomic financial reporting",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"moment": "^2.27.0"
|
"moment": "^2.27.0"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.0...medusa-plugin-ip-lookup@1.1.3) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-ip-lookup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.1...medusa-plugin-ip-lookup@1.1.2) (2021-04-20)
|
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-ip-lookup@1.1.1...medusa-plugin-ip-lookup@1.1.2) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-ip-lookup
|
**Note:** Version bump only for package medusa-plugin-ip-lookup
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-ip-lookup",
|
"name": "medusa-plugin-ip-lookup",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"description": "IP lookup middleware for Medusa core",
|
"description": "IP lookup middleware for Medusa core",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.9...medusa-plugin-mailchimp@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.10...medusa-plugin-mailchimp@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.10...medusa-plugin-mailchimp@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-mailchimp",
|
"name": "medusa-plugin-mailchimp",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Mailchimp newsletter subscriptions",
|
"description": "Mailchimp newsletter subscriptions",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -40,8 +40,8 @@
|
|||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"mailchimp-api-v3": "^1.14.0",
|
"mailchimp-api-v3": "^1.14.0",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.9...medusa-plugin-permissions@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-permissions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.10...medusa-plugin-permissions@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-permissions@1.1.10...medusa-plugin-permissions@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-permissions
|
**Note:** Version bump only for package medusa-plugin-permissions
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-permissions",
|
"name": "medusa-plugin-permissions",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Role permission for Medusa core",
|
"description": "Role permission for Medusa core",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
"medusa-interfaces": "1.x"
|
"medusa-interfaces": "1.x"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"mongoose": "^5.8.0"
|
"mongoose": "^5.8.0"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,22 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [0.0.7](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.6...medusa-plugin-restock-notification@0.0.7) (2021-04-29)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-restock-notification
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [0.0.6](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.3...medusa-plugin-restock-notification@0.0.6) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-restock-notification
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0.0.5](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.4...medusa-plugin-restock-notification@0.0.5) (2021-04-20)
|
## [0.0.5](https://github.com/medusajs/medusa/compare/medusa-plugin-restock-notification@0.0.4...medusa-plugin-restock-notification@0.0.5) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-restock-notification
|
**Note:** Version bump only for package medusa-plugin-restock-notification
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-restock-notification",
|
"name": "medusa-plugin-restock-notification",
|
||||||
"version": "0.0.5",
|
"version": "0.0.7",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -14,12 +14,12 @@
|
|||||||
"@babel/core": "^7.7.5",
|
"@babel/core": "^7.7.5",
|
||||||
"@babel/plugin-transform-typescript": "^7.13.0",
|
"@babel/plugin-transform-typescript": "^7.13.0",
|
||||||
"@babel/preset-typescript": "^7.12.7",
|
"@babel/preset-typescript": "^7.12.7",
|
||||||
"@medusajs/medusa": "^1.1.21",
|
"@medusajs/medusa": "^1.1.23",
|
||||||
"babel-preset-medusa-package": "^1.1.2",
|
"babel-preset-medusa-package": "^1.1.3",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"jest": "^25.5.2",
|
"jest": "^25.5.2",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"pg": "^8.5.1",
|
"pg": "^8.5.1",
|
||||||
"ulid": "^2.3.0"
|
"ulid": "^2.3.0"
|
||||||
},
|
},
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8"
|
"medusa-core-utils": "^1.1.9"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.12...medusa-plugin-segment@1.1.15) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-segment
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.13...medusa-plugin-segment@1.1.14) (2021-04-20)
|
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-segment@1.1.13...medusa-plugin-segment@1.1.14) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-segment
|
**Note:** Version bump only for package medusa-plugin-segment
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-segment",
|
"name": "medusa-plugin-segment",
|
||||||
"version": "1.1.14",
|
"version": "1.1.15",
|
||||||
"description": "Segment Analytics",
|
"description": "Segment Analytics",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.10...medusa-plugin-sendgrid@1.1.13) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-sendgrid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.11...medusa-plugin-sendgrid@1.1.12) (2021-04-20)
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-sendgrid@1.1.11...medusa-plugin-sendgrid@1.1.12) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-sendgrid
|
**Note:** Version bump only for package medusa-plugin-sendgrid
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-sendgrid",
|
"name": "medusa-plugin-sendgrid",
|
||||||
"version": "1.1.12",
|
"version": "1.1.13",
|
||||||
"description": "SendGrid transactional emails",
|
"description": "SendGrid transactional emails",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
"@sendgrid/mail": "^7.1.1",
|
"@sendgrid/mail": "^7.1.1",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.9...medusa-plugin-slack-notification@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-slack-notification
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.10...medusa-plugin-slack-notification@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-slack-notification@1.1.10...medusa-plugin-slack-notification@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-slack-notification
|
**Note:** Version bump only for package medusa-plugin-slack-notification
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-economic",
|
"name": "medusa-plugin-economic",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-slack-notification",
|
"name": "medusa-plugin-slack-notification",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Slack notifications",
|
"description": "Slack notifications",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"moment": "^2.27.0"
|
"moment": "^2.27.0"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.9...medusa-plugin-twilio-sms@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.10...medusa-plugin-twilio-sms@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.10...medusa-plugin-twilio-sms@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-twilio-sms",
|
"name": "medusa-plugin-twilio-sms",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -35,8 +35,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-transform-classes": "^7.9.5",
|
"@babel/plugin-transform-classes": "^7.9.5",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"twilio": "^3.49.1"
|
"twilio": "^3.49.1"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.9...medusa-plugin-wishlist@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-plugin-wishlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.10...medusa-plugin-wishlist@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-wishlist@1.1.10...medusa-plugin-wishlist@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-plugin-wishlist
|
**Note:** Version bump only for package medusa-plugin-wishlist
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-plugin-wishlist",
|
"name": "medusa-plugin-wishlist",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Provides /customers/:id/wishlist to add items to a customr's wishlist",
|
"description": "Provides /customers/:id/wishlist to add items to a customr's wishlist",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -37,8 +37,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11"
|
"medusa-test-utils": "^1.1.12"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.9...medusa-test-utils@1.1.12) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package medusa-test-utils
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.10...medusa-test-utils@1.1.11) (2021-04-20)
|
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.10...medusa-test-utils@1.1.11) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package medusa-test-utils
|
**Note:** Version bump only for package medusa-test-utils
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "medusa-test-utils",
|
"name": "medusa-test-utils",
|
||||||
"version": "1.1.11",
|
"version": "1.1.12",
|
||||||
"description": "Test utils for Medusa",
|
"description": "Test utils for Medusa",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-transform-classes": "^7.9.5",
|
"@babel/plugin-transform-classes": "^7.9.5",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"randomatic": "^3.1.1"
|
"randomatic": "^3.1.1"
|
||||||
},
|
},
|
||||||
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
"gitHead": "982da259ed93fe1b618800c8693a5c9dfe312532"
|
||||||
|
|||||||
@@ -3,6 +3,22 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.1.23](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.22...@medusajs/medusa@1.1.23) (2021-04-29)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @medusajs/medusa
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [1.1.22](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.19...@medusajs/medusa@1.1.22) (2021-04-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @medusajs/medusa
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.1.21](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.20...@medusajs/medusa@1.1.21) (2021-04-20)
|
## [1.1.21](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.20...@medusajs/medusa@1.1.21) (2021-04-20)
|
||||||
|
|
||||||
**Note:** Version bump only for package @medusajs/medusa
|
**Note:** Version bump only for package @medusajs/medusa
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@medusajs/medusa",
|
"name": "@medusajs/medusa",
|
||||||
"version": "1.1.21",
|
"version": "1.1.23",
|
||||||
"description": "E-commerce for JAMstack",
|
"description": "E-commerce for JAMstack",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"@babel/preset-typescript": "^7.12.7",
|
"@babel/preset-typescript": "^7.12.7",
|
||||||
"@babel/register": "^7.7.4",
|
"@babel/register": "^7.7.4",
|
||||||
"@babel/runtime": "^7.7.6",
|
"@babel/runtime": "^7.7.6",
|
||||||
"babel-preset-medusa-package": "^1.1.2",
|
"babel-preset-medusa-package": "^1.1.3",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"jest": "^25.5.2",
|
"jest": "^25.5.2",
|
||||||
@@ -67,8 +67,8 @@
|
|||||||
"joi": "^17.3.0",
|
"joi": "^17.3.0",
|
||||||
"joi-objectid": "^3.0.1",
|
"joi-objectid": "^3.0.1",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"medusa-core-utils": "^1.1.8",
|
"medusa-core-utils": "^1.1.9",
|
||||||
"medusa-test-utils": "^1.1.11",
|
"medusa-test-utils": "^1.1.12",
|
||||||
"morgan": "^1.9.1",
|
"morgan": "^1.9.1",
|
||||||
"multer": "^1.4.2",
|
"multer": "^1.4.2",
|
||||||
"passport": "^0.4.0",
|
"passport": "^0.4.0",
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ describe("POST /store/carts/:id", () => {
|
|||||||
expect(CartServiceMock.retrieve).toHaveBeenCalledWith(
|
expect(CartServiceMock.retrieve).toHaveBeenCalledWith(
|
||||||
IdMap.getId("emptyCart"),
|
IdMap.getId("emptyCart"),
|
||||||
{
|
{
|
||||||
relations: ["payment_sessions"],
|
relations: ["payment_sessions", "shipping_methods"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
expect(CartServiceMock.retrieve).toHaveBeenCalledWith(
|
expect(CartServiceMock.retrieve).toHaveBeenCalledWith(
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export default async (req, res) => {
|
|||||||
|
|
||||||
// If the cart has payment sessions update these
|
// If the cart has payment sessions update these
|
||||||
const updated = await cartService.retrieve(id, {
|
const updated = await cartService.retrieve(id, {
|
||||||
relations: ["payment_sessions"],
|
relations: ["payment_sessions", "shipping_methods"],
|
||||||
})
|
})
|
||||||
|
|
||||||
if (updated.payment_sessions?.length && !value.region_id) {
|
if (updated.payment_sessions?.length && !value.region_id) {
|
||||||
|
|||||||
@@ -1281,6 +1281,7 @@ describe("CartService", () => {
|
|||||||
profile_id: IdMap.getId(m.profile),
|
profile_id: IdMap.getId(m.profile),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
discounts: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ describe("ClaimService", () => {
|
|||||||
expect(withTransactionMock).toHaveBeenCalledWith("return")
|
expect(withTransactionMock).toHaveBeenCalledWith("return")
|
||||||
|
|
||||||
expect(returnService.create).toHaveBeenCalledTimes(1)
|
expect(returnService.create).toHaveBeenCalledTimes(1)
|
||||||
expect(returnService.create).toHaveBeenCalledWith(
|
expect(returnService.create).toHaveBeenCalledWith({
|
||||||
{
|
order_id: "1234",
|
||||||
claim_order_id: "claim_134",
|
claim_order_id: "claim_134",
|
||||||
shipping_method: {
|
shipping_method: {
|
||||||
option_id: "opt_13",
|
option_id: "opt_13",
|
||||||
@@ -113,18 +113,7 @@ describe("ClaimService", () => {
|
|||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
})
|
||||||
{
|
|
||||||
id: "1234",
|
|
||||||
region_id: "order_region",
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
id: "itm_1",
|
|
||||||
unit_price: 8000,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(withTransactionMock).toHaveBeenCalledWith("lineItem")
|
expect(withTransactionMock).toHaveBeenCalledWith("lineItem")
|
||||||
expect(lineItemService.generate).toHaveBeenCalledTimes(1)
|
expect(lineItemService.generate).toHaveBeenCalledTimes(1)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
import { Validator, MedusaError } from "medusa-core-utils"
|
import { Validator, MedusaError } from "medusa-core-utils"
|
||||||
import { BaseService } from "medusa-interfaces"
|
import { BaseService } from "medusa-interfaces"
|
||||||
import { defaultFields, defaultRelations } from "../api/routes/store/carts"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides layer to manipulate carts.
|
* Provides layer to manipulate carts.
|
||||||
@@ -574,6 +573,49 @@ class CartService extends BaseService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures shipping total on cart is correct in regards to a potential free
|
||||||
|
* shipping discount
|
||||||
|
* If a free shipping is present, we set shipping methods price to 0
|
||||||
|
* if a free shipping was present, we set shipping methods to original amount
|
||||||
|
* @param {Cart} cart - the the cart to adjust free shipping for
|
||||||
|
* @param {boolean} shouldAdd - flag to indicate, if we should add or remove
|
||||||
|
*/
|
||||||
|
async adjustFreeShipping_(cart, shouldAdd) {
|
||||||
|
if (cart.shipping_methods?.length) {
|
||||||
|
// if any free shipping discounts, we ensure to update shipping method amount
|
||||||
|
if (shouldAdd) {
|
||||||
|
await Promise.all(
|
||||||
|
cart.shipping_methods.map(async sm => {
|
||||||
|
const smRepo = this.manager_.getCustomRepository(
|
||||||
|
this.shippingMethodRepository_
|
||||||
|
)
|
||||||
|
|
||||||
|
const method = await smRepo.findOne({ where: { id: sm.id } })
|
||||||
|
|
||||||
|
if (method) {
|
||||||
|
method.price = 0
|
||||||
|
await smRepo.save(method)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await Promise.all(
|
||||||
|
cart.shipping_methods.map(async sm => {
|
||||||
|
const smRepo = this.manager_.getCustomRepository(
|
||||||
|
this.shippingMethodRepository_
|
||||||
|
)
|
||||||
|
|
||||||
|
// if free shipping discount is removed, we adjust the shipping
|
||||||
|
// back to its original amount
|
||||||
|
sm.price = sm.shipping_option.amount
|
||||||
|
await smRepo.save(sm)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async update(cartId, update) {
|
async update(cartId, update) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async manager => {
|
||||||
const cartRepo = manager.getCustomRepository(this.cartRepository_)
|
const cartRepo = manager.getCustomRepository(this.cartRepository_)
|
||||||
@@ -627,10 +669,29 @@ class CartService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("discounts" in update) {
|
if ("discounts" in update) {
|
||||||
|
const previousDiscounts = cart.discounts
|
||||||
cart.discounts = []
|
cart.discounts = []
|
||||||
|
|
||||||
for (const { code } of update.discounts) {
|
for (const { code } of update.discounts) {
|
||||||
await this.applyDiscount_(cart, code)
|
await this.applyDiscount_(cart, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasFreeShipping = cart.discounts.some(
|
||||||
|
({ rule }) => rule.type === "free_shipping"
|
||||||
|
)
|
||||||
|
|
||||||
|
// if we previously had a free shipping discount and then removed it,
|
||||||
|
// we need to update shipping methods to original price
|
||||||
|
if (
|
||||||
|
previousDiscounts.some(({ rule }) => rule.type === "free_shipping") &&
|
||||||
|
!hasFreeShipping
|
||||||
|
) {
|
||||||
|
await this.adjustFreeShipping_(cart, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasFreeShipping) {
|
||||||
|
await this.adjustFreeShipping_(cart, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("gift_cards" in update) {
|
if ("gift_cards" in update) {
|
||||||
@@ -890,8 +951,13 @@ class CartService extends BaseService {
|
|||||||
async removeDiscount(cartId, discountCode) {
|
async removeDiscount(cartId, discountCode) {
|
||||||
return this.atomicPhase_(async manager => {
|
return this.atomicPhase_(async manager => {
|
||||||
const cart = await this.retrieve(cartId, {
|
const cart = await this.retrieve(cartId, {
|
||||||
relations: ["discounts", "payment_sessions"],
|
relations: ["discounts", "payment_sessions", "shipping_methods"],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (cart.discounts.some(({ rule }) => rule.type === "free_shipping")) {
|
||||||
|
await this.adjustFreeShipping_(cart, false)
|
||||||
|
}
|
||||||
|
|
||||||
cart.discounts = cart.discounts.filter(d => d.code !== discountCode)
|
cart.discounts = cart.discounts.filter(d => d.code !== discountCode)
|
||||||
|
|
||||||
const cartRepo = manager.getCustomRepository(this.cartRepository_)
|
const cartRepo = manager.getCustomRepository(this.cartRepository_)
|
||||||
@@ -1232,6 +1298,7 @@ class CartService extends BaseService {
|
|||||||
select: ["subtotal"],
|
select: ["subtotal"],
|
||||||
relations: [
|
relations: [
|
||||||
"shipping_methods",
|
"shipping_methods",
|
||||||
|
"discounts",
|
||||||
"shipping_methods.shipping_option",
|
"shipping_methods.shipping_option",
|
||||||
"items",
|
"items",
|
||||||
"items.variant",
|
"items.variant",
|
||||||
@@ -1267,7 +1334,15 @@ class CartService extends BaseService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.retrieve(cartId)
|
const result = await this.retrieve(cartId, {
|
||||||
|
relations: ["discounts", "shipping_methods"],
|
||||||
|
})
|
||||||
|
|
||||||
|
// if cart has freeshipping, adjust price
|
||||||
|
if (result.discounts.some(({ rule }) => rule.type === "free_shipping")) {
|
||||||
|
await this.adjustFreeShipping_(result, true)
|
||||||
|
}
|
||||||
|
|
||||||
await this.eventBus_
|
await this.eventBus_
|
||||||
.withTransaction(manager)
|
.withTransaction(manager)
|
||||||
.emit(CartService.Events.UPDATED, result)
|
.emit(CartService.Events.UPDATED, result)
|
||||||
|
|||||||
@@ -252,8 +252,8 @@ class ClaimService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (return_shipping) {
|
if (return_shipping) {
|
||||||
await this.returnService_.withTransaction(manager).create(
|
await this.returnService_.withTransaction(manager).create({
|
||||||
{
|
order_id: order.id,
|
||||||
claim_order_id: result.id,
|
claim_order_id: result.id,
|
||||||
items: claim_items.map(ci => ({
|
items: claim_items.map(ci => ({
|
||||||
item_id: ci.item_id,
|
item_id: ci.item_id,
|
||||||
@@ -261,9 +261,7 @@ class ClaimService extends BaseService {
|
|||||||
metadata: ci.metadata,
|
metadata: ci.metadata,
|
||||||
})),
|
})),
|
||||||
shipping_method: return_shipping,
|
shipping_method: return_shipping,
|
||||||
},
|
})
|
||||||
order
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.eventBus_
|
await this.eventBus_
|
||||||
|
|||||||
@@ -400,8 +400,13 @@ class SwapService extends BaseService {
|
|||||||
|
|
||||||
const order = swap.order
|
const order = swap.order
|
||||||
|
|
||||||
|
// filter out free shipping discounts
|
||||||
|
const discounts =
|
||||||
|
order?.discounts?.filter(({ rule }) => rule.type !== "free_shipping") ||
|
||||||
|
undefined
|
||||||
|
|
||||||
const cart = await this.cartService_.withTransaction(manager).create({
|
const cart = await this.cartService_.withTransaction(manager).create({
|
||||||
discounts: order.discounts,
|
discounts,
|
||||||
email: order.email,
|
email: order.email,
|
||||||
billing_address_id: order.billing_address_id,
|
billing_address_id: order.billing_address_id,
|
||||||
shipping_address_id: order.shipping_address_id,
|
shipping_address_id: order.shipping_address_id,
|
||||||
|
|||||||
Reference in new issue
Block a user