chore: Remove deprecated plugins (#7199)
This commit is contained in:
6
packages/gatsby-source-medusa/.gitignore
vendored
6
packages/gatsby-source-medusa/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
/dist
|
||||
node_modules
|
||||
.DS_store
|
||||
.env*
|
||||
.env
|
||||
*.sql
|
||||
@@ -1,62 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 0.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4419](https://github.com/medusajs/medusa/pull/4419) [`627bdb689`](https://github.com/medusajs/medusa/commit/627bdb689f26282ba49a185bfc5182a7c1e734dd) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(gatsby-source-medusa): Cleanup plugin setup
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1914](https://github.com/medusajs/medusa/pull/1914) [`1dec44287`](https://github.com/medusajs/medusa/commit/1dec44287df5ac69b4c5769b59f9ebef58d3da68) Thanks [@fPolic](https://github.com/fPolic)! - Version bump due to missing changesets in merged PRs
|
||||
|
||||
* [#1463](https://github.com/medusajs/medusa/pull/1463) [`cbdc5b777`](https://github.com/medusajs/medusa/commit/cbdc5b7774c76f4e95f8aa1367652acd74eb9b6b) Thanks [@kasperkristensen](https://github.com/kasperkristensen)! - Moves sourceUpdatedNodes and sourceAllNodes to a separate file, to prevent warning of unsupported exports.
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [0.1.0](https://github.com/medusajs/medusa/compare/gatsby-source-medusa@0.0.49...gatsby-source-medusa@0.1.0) (2022-05-01)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **gatsby-source-medusa:** adds support for incremental sourcing of medusa data ([#1217](https://github.com/medusajs/medusa/issues/1217)) ([23f8399](https://github.com/medusajs/medusa/commit/23f8399c16e3f3c7a01a6846b2b96750dde55a60))
|
||||
|
||||
## [0.0.49](https://github.com/medusajs/medusa/compare/gatsby-source-medusa@0.0.48...gatsby-source-medusa@0.0.49) (2022-02-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release ([fc3fbc8](https://github.com/medusajs/medusa/commit/fc3fbc897fad5c8a5d3eea828ac7277fba9d70af))
|
||||
|
||||
## [0.0.48](https://github.com/medusajs/medusa/compare/gatsby-source-medusa@0.0.47...gatsby-source-medusa@0.0.48) (2022-02-06)
|
||||
|
||||
### Features
|
||||
|
||||
- medusa-react admin hooks ([#978](https://github.com/medusajs/medusa/issues/978)) ([2e38484](https://github.com/medusajs/medusa/commit/2e384842d5b2e9742a86b96f28a8f00357795b86)), closes [#1019](https://github.com/medusajs/medusa/issues/1019)
|
||||
|
||||
## [0.0.47](https://github.com/medusajs/medusa/compare/gatsby-source-medusa@0.0.46...gatsby-source-medusa@0.0.47) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package gatsby-source-medusa
|
||||
|
||||
## [0.0.46](https://github.com/medusajs/medusa/compare/gatsby-source-medusa@0.0.45...gatsby-source-medusa@0.0.46) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package gatsby-source-medusa
|
||||
|
||||
## 0.0.45 (2021-12-17)
|
||||
|
||||
### Features
|
||||
|
||||
- gatsby source medusa ([#924](https://github.com/medusajs/medusa/issues/924)) ([b8ff364](https://github.com/medusajs/medusa/commit/b8ff364276bf143f061a7c85e309dcd3ebfe4185))
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Medusa
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,72 +0,0 @@
|
||||
<p align="center">
|
||||
<a href="https://www.medusajs.com">
|
||||
<img alt="Medusa" src="https://user-images.githubusercontent.com/7554214/129161578-19b83dc8-fac5-4520-bd48-53cba676edd2.png" width="100" />
|
||||
</a>
|
||||
</p>
|
||||
<h1 align="center">
|
||||
gatsby-source-medusa
|
||||
</h1>
|
||||
<p align="center">
|
||||
Medusa is an open-source headless commerce engine that enables developers to create amazing digital commerce experiences. This is a Gatsby source plugin for building websites using Medusa as a data source.
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/medusajs/medusa/blob/master/LICENSE">
|
||||
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Medusa is released under the MIT license." />
|
||||
</a>
|
||||
<a href="https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md">
|
||||
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs welcome!" />
|
||||
</a>
|
||||
<a href="https://discord.gg/xpCwq3Kfn8">
|
||||
<img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Discord Chat" />
|
||||
</a>
|
||||
<a href="https://twitter.com/intent/follow?screen_name=medusajs">
|
||||
<img src="https://img.shields.io/twitter/follow/medusajs.svg?label=Follow%20@medusajs" alt="Follow @medusajs" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Note
|
||||
|
||||
We're not actively maintaining this repository. So, it may not work as expected with the latest versions of Medusa. Contributions are highly appreciated.**
|
||||
|
||||
## Quickstart
|
||||
|
||||
This takes you through the minimal steps to see your Medusa data in your Gatsby site's GraphiQL explorer.
|
||||
|
||||
### 1. Installation
|
||||
|
||||
Install the source plugin to your Gatsby project using your favorite package manager.
|
||||
|
||||
```shell
|
||||
npm install gatsby-source-medusa
|
||||
```
|
||||
|
||||
```shell
|
||||
yarn add gatsby-source-medusa
|
||||
```
|
||||
|
||||
### 2. Configuration
|
||||
|
||||
Add the plugin to your `gatsby-config.js`:
|
||||
|
||||
```js:title=gatsby-config.js
|
||||
require("dotenv").config()
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
{
|
||||
resolve: "gatsby-source-medusa",
|
||||
options: {
|
||||
storeUrl: process.env.MEDUSA_URL,
|
||||
authToken: process.env.MEDUSA_AUTH_TOKEN //This is optional
|
||||
},
|
||||
},
|
||||
...,
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
The plugin accepts two options `storeUrl` and `authToken`. The `storeUrl` option is required and should point to the server where your Medusa instance is hosted (this could be `localhost:9000` in development). The `authToken` option is optional, and if you add it the plugin will also source orders from your store.
|
||||
|
||||
## You should now be ready to begin querying your data
|
||||
|
||||
You should now be able to view your stores `MedusaProducts`, `MedusaRegions`, `MedusaCollections`, and `MedusaOrders` (if enabled) in your Gatsby site's GraphiQL explorer.
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
globals: {
|
||||
"ts-jest": {
|
||||
tsconfig: "tsconfig.spec.json",
|
||||
isolatedModules: false,
|
||||
},
|
||||
},
|
||||
transform: {
|
||||
"^.+\\.[jt]s?$": "ts-jest",
|
||||
},
|
||||
testEnvironment: `node`,
|
||||
moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`],
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
{
|
||||
"name": "gatsby-source-medusa",
|
||||
"version": "0.1.4",
|
||||
"description": "Gatsby source plugin for building websites using Medusa Commerce as a data source",
|
||||
"scripts": {
|
||||
"test": "jest --passWithNoTests",
|
||||
"watch": "tsc-watch",
|
||||
"build": "tsc"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"keywords": [
|
||||
"gatsby",
|
||||
"gatsby-plugin",
|
||||
"gatsby-source",
|
||||
"gatsby-source-medusa",
|
||||
"medusa",
|
||||
"medusa-commerce"
|
||||
],
|
||||
"author": "Kasper Kristensen <kasper@medusa-commerce.com> (https://www.medusa-commerce.com/)",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa.git",
|
||||
"directory": "packages/gatsby-source-medusa"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/medusajs/medusa/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.24.0",
|
||||
"gatsby-core-utils": "^3.3.0",
|
||||
"gatsby-plugin-image": "^2.3.0",
|
||||
"gatsby-source-filesystem": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.0.1",
|
||||
"gatsby": "^4.1.0",
|
||||
"jest": "^27.0.6",
|
||||
"ts-jest": "^27.1.5",
|
||||
"tsc-watch": "^4.5.0",
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"gatsby": "^4.1.0"
|
||||
},
|
||||
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e"
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`helper functions should return return a new node from processNode 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"children": Array [],
|
||||
"description": "A test product",
|
||||
"id": "prod_test_1234",
|
||||
"internal": Object {
|
||||
"content": "{\\"id\\":\\"prod_test_1234\\",\\"title\\":\\"Test Shirt\\",\\"description\\":\\"A test product\\",\\"unit_price\\":2500}",
|
||||
"contentDigest": "digest_string",
|
||||
"type": "MedusaProduct",
|
||||
},
|
||||
"parent": null,
|
||||
"title": "Test Shirt",
|
||||
"unit_price": 2500,
|
||||
},
|
||||
]
|
||||
`;
|
||||
@@ -1,20 +0,0 @@
|
||||
const { processNode } = require("../process-node.ts")
|
||||
|
||||
describe("helper functions", () => {
|
||||
it("should return return a new node from processNode", () => {
|
||||
const fieldName = "product"
|
||||
const node = {
|
||||
id: "prod_test_1234",
|
||||
title: "Test Shirt",
|
||||
description: "A test product",
|
||||
unit_price: 2500,
|
||||
}
|
||||
|
||||
const createContentDigest = jest.fn(() => "digest_string")
|
||||
const processNodeResult = processNode(node, fieldName, createContentDigest)
|
||||
|
||||
expect(createContentDigest).toBeCalled()
|
||||
|
||||
expect(processNodeResult).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
@@ -1,135 +0,0 @@
|
||||
import axios, { AxiosPromise, AxiosRequestConfig } from "axios"
|
||||
|
||||
function medusaRequest(
|
||||
storeURL: string,
|
||||
path = "",
|
||||
headers = {}
|
||||
): AxiosPromise {
|
||||
const options: AxiosRequestConfig = {
|
||||
method: "GET",
|
||||
withCredentials: true,
|
||||
url: path,
|
||||
headers: headers,
|
||||
}
|
||||
|
||||
const client = axios.create({ baseURL: storeURL })
|
||||
|
||||
return client(options)
|
||||
}
|
||||
|
||||
export const createClient = (options: MedusaPluginOptions): any => {
|
||||
const { storeUrl, apiKey } = options
|
||||
|
||||
/**
|
||||
* @param {string} _date used fetch products updated since the specified date
|
||||
* @return {Promise<any[]>} products to create nodes from
|
||||
*/
|
||||
async function products(_date?: string): Promise<any[]> {
|
||||
let products: any[] = []
|
||||
let offset = 0
|
||||
let count = 1
|
||||
do {
|
||||
let path = `/store/products?offset=${offset}`
|
||||
if (_date) {
|
||||
path += `&updated_at[gt]=${_date}`
|
||||
}
|
||||
|
||||
await medusaRequest(storeUrl, path).then(({ data }) => {
|
||||
products = [...products, ...data.products]
|
||||
count = data.count
|
||||
offset = data.products.length
|
||||
})
|
||||
} while (products.length < count)
|
||||
|
||||
if (!products.length && !_date) {
|
||||
console.warn(
|
||||
"[gatsby-source-medusa]: 📣 No products were retrieved. If this is a new store, please ensure that you have at least one published product in your store. You can create a product by using the Medusa admin dashboard."
|
||||
)
|
||||
}
|
||||
|
||||
return products
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} _date used fetch regions updated since the specified date
|
||||
* @return {Promise<any[]>} regions to create nodes from
|
||||
*/
|
||||
async function regions(_date?: string): Promise<any[]> {
|
||||
let path = `/store/regions`
|
||||
if (_date) {
|
||||
path += `?updated_at[gt]=${_date}`
|
||||
}
|
||||
|
||||
const regions = await medusaRequest(storeUrl, path).then(({ data }) => {
|
||||
return data.regions
|
||||
})
|
||||
|
||||
if (!regions.length && !_date) {
|
||||
console.warn(
|
||||
"[gatsby-source-medusa]: 📣 No regions were retrieved. If this is a new store, please ensure that you have configured at least one region in the Medusa admin dashboard."
|
||||
)
|
||||
}
|
||||
|
||||
return regions
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} _date used fetch regions updated since the specified date
|
||||
* @return {Promise<any[]>} orders to create nodes from
|
||||
*/
|
||||
async function orders(_date?: string): Promise<any[]> {
|
||||
const orders = await medusaRequest(storeUrl, `/admin/orders`, {
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return data.orders
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn(`
|
||||
📣 The following error status was produced while attempting to fetch orders: ${error}. \n
|
||||
Make sure that the auth token you provided is valid.
|
||||
`)
|
||||
return []
|
||||
})
|
||||
return orders
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} _date used fetch regions updated since the specified date
|
||||
* @return {Promise<any[]>} collections to create nodes from
|
||||
*/
|
||||
async function collections(_date?: string): Promise<any[]> {
|
||||
let collections: any[] = []
|
||||
let offset = 0
|
||||
let count = 1
|
||||
do {
|
||||
let path = `/store/collections?offset=${offset}`
|
||||
if (_date) {
|
||||
path += `&updated_at[gt]=${_date}`
|
||||
}
|
||||
await medusaRequest(storeUrl, path).then(({ data }) => {
|
||||
collections = [...collections, ...data.collections]
|
||||
count = data.count
|
||||
offset = data.collections.length
|
||||
})
|
||||
} while (collections.length < count)
|
||||
|
||||
if (!collections.length && !_date) {
|
||||
console.warn(
|
||||
"[gatsby-source-medusa]: 📣 No collections were retrieved. You can create collections using the Medusa admin dasbboard."
|
||||
)
|
||||
}
|
||||
|
||||
return collections
|
||||
}
|
||||
|
||||
return {
|
||||
products,
|
||||
collections,
|
||||
regions,
|
||||
orders,
|
||||
}
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
import {
|
||||
CreateResolversArgs,
|
||||
GatsbyCache,
|
||||
Node,
|
||||
PluginOptionsSchemaArgs,
|
||||
Reporter,
|
||||
SourceNodesArgs,
|
||||
Store,
|
||||
} from "gatsby"
|
||||
import {
|
||||
createRemoteFileNode,
|
||||
CreateRemoteFileNodeArgs,
|
||||
} from "gatsby-source-filesystem"
|
||||
import { sourceAllNodes, sourceUpdatedNodes } from "./source-nodes"
|
||||
|
||||
export function pluginOptionsSchema({ Joi }: PluginOptionsSchemaArgs): any {
|
||||
return Joi.object({
|
||||
storeUrl: Joi.string().required(),
|
||||
apiKey: Joi.string().optional(),
|
||||
})
|
||||
}
|
||||
|
||||
export async function onPostBuild({ cache }: { cache: any }): Promise<void> {
|
||||
await cache.set("timestamp", Date.now())
|
||||
}
|
||||
|
||||
export async function sourceNodes(
|
||||
gatsbyApi: SourceNodesArgs,
|
||||
pluginOptions: MedusaPluginOptions
|
||||
): Promise<void> {
|
||||
const { cache } = gatsbyApi
|
||||
const lastBuildTime = await cache.get("timestamp")
|
||||
|
||||
if (lastBuildTime !== undefined) {
|
||||
await sourceUpdatedNodes(gatsbyApi, pluginOptions, lastBuildTime)
|
||||
} else {
|
||||
gatsbyApi.reporter.info(`Cache is cold, running a clean build.`)
|
||||
await sourceAllNodes(gatsbyApi, pluginOptions)
|
||||
}
|
||||
|
||||
gatsbyApi.reporter.info(`Finished sourcing nodes`)
|
||||
}
|
||||
|
||||
export function createResolvers({ createResolvers }: CreateResolversArgs): any {
|
||||
const resolvers = {
|
||||
MedusaProducts: {
|
||||
images: {
|
||||
type: ["MedusaImages"],
|
||||
resolve: async (
|
||||
source: any,
|
||||
_args: any,
|
||||
context: any,
|
||||
_info: any
|
||||
): Promise<any> => {
|
||||
const { entries } = await context.nodeModel.findAll({
|
||||
query: {
|
||||
filter: { parent: { id: { eq: source.id } } },
|
||||
},
|
||||
type: "MedusaImages",
|
||||
})
|
||||
return entries
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
createResolvers(resolvers)
|
||||
}
|
||||
|
||||
export async function createSchemaCustomization({
|
||||
actions: { createTypes },
|
||||
}: {
|
||||
actions: { createTypes: any }
|
||||
schema: any
|
||||
}): Promise<void> {
|
||||
createTypes(`
|
||||
type MedusaProducts implements Node {
|
||||
id: ID!
|
||||
title: String!
|
||||
subtitle: String
|
||||
description: String
|
||||
handle: String!
|
||||
is_giftcard: Boolean!
|
||||
status: String!
|
||||
thumbnail: File @link(from: "fields.localThumbnail")
|
||||
options: [MedusaProductOptions]!
|
||||
variants: [MedusaProductVariants]!
|
||||
collection: MedusaCollections @link(from: "collection_id")
|
||||
collection_id: String
|
||||
profile_id: String!
|
||||
discountable: Boolean!
|
||||
published_at: Date!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
weight: Int
|
||||
length: Int
|
||||
width: Int
|
||||
}
|
||||
type MedusaImages implements Node {
|
||||
id: ID!
|
||||
url: String!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
image: File @link(from: "fields.localImage")
|
||||
}
|
||||
type MedusaCollections implements Node {
|
||||
id: ID!
|
||||
handle: String!
|
||||
title: String!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
}
|
||||
type MedusaProductOptions @dontInfer {
|
||||
id: ID!
|
||||
title: String!
|
||||
product_id: String!
|
||||
values: [MedusaProductOptionValues]!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
}
|
||||
type MedusaProductOptionValues @dontInfer {
|
||||
id: ID!
|
||||
value: String!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
option_id: String!
|
||||
variant_id: String!
|
||||
}
|
||||
type MedusaProductVariants @dontInfer {
|
||||
id: ID!
|
||||
title: String!
|
||||
product_id: String!
|
||||
prices: [MedusaMoneyAmounts]!
|
||||
sku: String
|
||||
barcode: String
|
||||
upc: String
|
||||
variant_rank: Int
|
||||
inventory_quantity: Int!
|
||||
allow_backorder: Boolean!
|
||||
manage_inventory: Boolean!
|
||||
hs_code: String
|
||||
origin_country: String
|
||||
mid_code: String
|
||||
material: String
|
||||
weight: Int
|
||||
length: Int
|
||||
height: Int
|
||||
width: Int
|
||||
options: [MedusaProductOptionValues]!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
}
|
||||
type MedusaMoneyAmounts @dontInfer {
|
||||
id: ID!
|
||||
amount: Int!
|
||||
currency_code: String!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
variant_id: String!
|
||||
}
|
||||
type MedusaRegions implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
currency_code: String!
|
||||
tax_rate: Int!
|
||||
tax_code: String
|
||||
automatic_taxes: Boolean!
|
||||
created_at: Date!
|
||||
updated_at: Date!
|
||||
countries: [MedusaCountries]!
|
||||
}
|
||||
type MedusaCountries implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
iso_2: String!
|
||||
iso_3: String!
|
||||
num_code: Int!
|
||||
display_name: String!
|
||||
region_id: String!
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
export async function onCreateNode({
|
||||
actions: { createNode, createNodeField },
|
||||
cache,
|
||||
createNodeId,
|
||||
node,
|
||||
store,
|
||||
reporter,
|
||||
}: {
|
||||
actions: { createNode: any; createNodeField: any }
|
||||
cache: GatsbyCache
|
||||
createNodeId: any
|
||||
node: Node
|
||||
store: Store
|
||||
reporter: Reporter
|
||||
}): Promise<void> {
|
||||
if (node.internal.type === `MedusaProducts`) {
|
||||
if (node.thumbnail !== null) {
|
||||
const thumbnailNode: Node | null = await createRemoteFileNode({
|
||||
url: `${node.thumbnail}`,
|
||||
parentNodeId: node.id,
|
||||
createNode,
|
||||
createNodeId,
|
||||
cache,
|
||||
store,
|
||||
reporter,
|
||||
} as CreateRemoteFileNodeArgs)
|
||||
|
||||
if (thumbnailNode) {
|
||||
createNodeField({
|
||||
node,
|
||||
name: `localThumbnail`,
|
||||
value: thumbnailNode.id,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node.internal.type === `MedusaImages`) {
|
||||
const imageNode: Node | null = await createRemoteFileNode({
|
||||
url: `${node.url}`,
|
||||
parentNodeId: node.id,
|
||||
createNode,
|
||||
createNodeId,
|
||||
cache,
|
||||
store,
|
||||
reporter,
|
||||
} as CreateRemoteFileNodeArgs)
|
||||
|
||||
if (imageNode) {
|
||||
createNodeField({
|
||||
node,
|
||||
name: `localImage`,
|
||||
value: imageNode.id,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
interface MedusaPluginOptions {
|
||||
storeUrl: string
|
||||
apiKey: string
|
||||
}
|
||||
|
||||
interface MedusaProductImage {
|
||||
url: string
|
||||
metadata: Record<string, unknown> | null
|
||||
id: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at: string | null
|
||||
}
|
||||
|
||||
interface IMedusaOperation {
|
||||
execute: () => Promise<any[]>
|
||||
name: string
|
||||
}
|
||||
|
||||
interface IOperations {
|
||||
createProductsOperation: IMedusaOperation
|
||||
createCollectionsOperation: IMedusaOperation
|
||||
createRegionsOperation: IMedusaOperation
|
||||
createOrdersOperation: IMedusaOperation
|
||||
incrementalProductsOperation: (date: string) => IMedusaOperation
|
||||
incrementalCollectionsOperation: (date: string) => IMedusaOperation
|
||||
incrementalRegionsOperation: (date: string) => IMedusaOperation
|
||||
incrementalOrdersOperation: (date: string) => IMedusaOperation
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import { SourceNodesArgs } from "gatsby"
|
||||
import { processNode } from "./process-node"
|
||||
|
||||
export function makeSourceFromOperation(gatsbyApi: SourceNodesArgs) {
|
||||
return async function sourceFromOperation(
|
||||
op: IMedusaOperation
|
||||
): Promise<void> {
|
||||
const { reporter, actions } = gatsbyApi
|
||||
|
||||
reporter.info(`Initiating operation query ${op.name}`)
|
||||
const nodes = await op.execute()
|
||||
|
||||
nodes.map((rawNode) => {
|
||||
const nodeArr = processNode(
|
||||
rawNode,
|
||||
op.name,
|
||||
gatsbyApi.createContentDigest
|
||||
)
|
||||
|
||||
nodeArr.forEach((node) => {
|
||||
actions.createNode(node)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { createClient } from "./client"
|
||||
|
||||
export function createOperations(options: MedusaPluginOptions): IOperations {
|
||||
const client = createClient(options)
|
||||
|
||||
function createOperation(
|
||||
name: "products" | "collections" | "regions" | "orders",
|
||||
queryString?: string
|
||||
): IMedusaOperation {
|
||||
return {
|
||||
execute: (): Promise<any[]> => client[name](queryString),
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
createProductsOperation: createOperation("products"),
|
||||
createCollectionsOperation: createOperation("collections"),
|
||||
createRegionsOperation: createOperation("regions"),
|
||||
createOrdersOperation: createOperation("orders"),
|
||||
incrementalProductsOperation: (date: string): any =>
|
||||
createOperation("products", date),
|
||||
incrementalCollectionsOperation: (date: string): any =>
|
||||
createOperation("collections", date),
|
||||
incrementalRegionsOperation: (date: string): any =>
|
||||
createOperation("regions", date),
|
||||
incrementalOrdersOperation: (date: string): any =>
|
||||
createOperation("orders", date),
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
export const processNode = (
|
||||
node: any,
|
||||
fieldName: string,
|
||||
createContentDigest: (this: void, input: string | object) => string
|
||||
): any[] => {
|
||||
const nodeId: string = node.id
|
||||
const nodeContent = JSON.stringify(node)
|
||||
const nodeContentDigest = createContentDigest(nodeContent)
|
||||
|
||||
let images = []
|
||||
|
||||
if (fieldName === "products") {
|
||||
if (node.images?.length) {
|
||||
images = node.images.map((image: any) => {
|
||||
const nodeImageContentDigest = createContentDigest(image.id)
|
||||
const nodeImageContent = JSON.stringify(image)
|
||||
|
||||
const imageData = Object.assign({}, image, {
|
||||
id: image.id,
|
||||
parent: nodeId,
|
||||
children: [],
|
||||
internal: {
|
||||
type: "MedusaImages",
|
||||
content: nodeImageContent,
|
||||
contentDigest: nodeImageContentDigest,
|
||||
},
|
||||
})
|
||||
|
||||
return imageData
|
||||
})
|
||||
}
|
||||
delete node.images
|
||||
}
|
||||
|
||||
// TODO: use upperFirstCase from medusajs/utils when it's available
|
||||
const type = `Medusa${fieldName[0].toUpperCase() + fieldName.slice(1)}`
|
||||
const nodeData = Object.assign({}, node, {
|
||||
id: nodeId,
|
||||
parent: null,
|
||||
children: [],
|
||||
internal: {
|
||||
type,
|
||||
content: nodeContent,
|
||||
contentDigest: nodeContentDigest,
|
||||
},
|
||||
})
|
||||
|
||||
return [nodeData, ...images]
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
import { SourceNodesArgs } from "gatsby"
|
||||
import { makeSourceFromOperation } from "./make-source-from-operation"
|
||||
import { createOperations } from "./operations"
|
||||
|
||||
const medusaNodeTypes = [
|
||||
"MedusaRegions",
|
||||
"MedusaProducts",
|
||||
"MedusaOrders",
|
||||
"MedusaCollections",
|
||||
]
|
||||
|
||||
export async function sourceAllNodes(
|
||||
gatsbyApi: SourceNodesArgs,
|
||||
pluginOptions: MedusaPluginOptions
|
||||
): Promise<void> {
|
||||
const {
|
||||
createProductsOperation,
|
||||
createRegionsOperation,
|
||||
createOrdersOperation,
|
||||
createCollectionsOperation,
|
||||
} = createOperations(pluginOptions)
|
||||
|
||||
const operations = [
|
||||
createProductsOperation,
|
||||
createRegionsOperation,
|
||||
createCollectionsOperation,
|
||||
]
|
||||
|
||||
// if auth token is provided then source orders
|
||||
if (pluginOptions.apiKey) {
|
||||
operations.push(createOrdersOperation)
|
||||
}
|
||||
|
||||
const sourceFromOperation = makeSourceFromOperation(gatsbyApi)
|
||||
|
||||
for (const op of operations) {
|
||||
await sourceFromOperation(op)
|
||||
}
|
||||
}
|
||||
|
||||
export async function sourceUpdatedNodes(
|
||||
gatsbyApi: SourceNodesArgs,
|
||||
pluginOptions: MedusaPluginOptions,
|
||||
lastBuildTime: string
|
||||
): Promise<void> {
|
||||
const {
|
||||
incrementalProductsOperation,
|
||||
incrementalRegionsOperation,
|
||||
incrementalOrdersOperation,
|
||||
incrementalCollectionsOperation,
|
||||
} = createOperations(pluginOptions)
|
||||
|
||||
for (const nodeType of medusaNodeTypes) {
|
||||
gatsbyApi
|
||||
.getNodesByType(nodeType)
|
||||
.forEach((node) => gatsbyApi.actions.touchNode(node))
|
||||
}
|
||||
|
||||
const operations = [
|
||||
incrementalProductsOperation(lastBuildTime),
|
||||
incrementalRegionsOperation(lastBuildTime),
|
||||
incrementalCollectionsOperation(lastBuildTime),
|
||||
]
|
||||
|
||||
if (pluginOptions.apiKey) {
|
||||
operations.push(incrementalOrdersOperation(lastBuildTime))
|
||||
}
|
||||
|
||||
const sourceFromOperation = makeSourceFromOperation(gatsbyApi)
|
||||
|
||||
for (const op of operations) {
|
||||
await sourceFromOperation(op)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
export const formatUri = (uri: string): string => {
|
||||
let url
|
||||
|
||||
try {
|
||||
url = new URL(uri)
|
||||
} catch (_) {
|
||||
const formatted = /[\w||\d].*/.exec(uri)?.[0]
|
||||
return `https://${formatted}`
|
||||
}
|
||||
|
||||
return url.href
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2020"],
|
||||
"target": "es2020",
|
||||
"outDir": "./dist",
|
||||
"esModuleInterop": true,
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"noImplicitReturns": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitThis": true,
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"downlevelIteration": true // to use ES5 specific tooling
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": [
|
||||
"dist",
|
||||
"./src/**/__tests__",
|
||||
"./src/**/__mocks__",
|
||||
"./src/**/__fixtures__",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-instanceof",
|
||||
"@babel/plugin-transform-classes"
|
||||
],
|
||||
"presets": ["@babel/preset-env"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
}
|
||||
}
|
||||
16
packages/medusa-payment-adyen/.gitignore
vendored
16
packages/medusa-payment-adyen/.gitignore
vendored
@@ -1,16 +0,0 @@
|
||||
/lib
|
||||
node_modules
|
||||
.DS_store
|
||||
.env*
|
||||
/*.js
|
||||
!index.js
|
||||
yarn.lock
|
||||
|
||||
/dist
|
||||
|
||||
/api
|
||||
/services
|
||||
/models
|
||||
/subscribers
|
||||
/__mocks__
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
.DS_store
|
||||
src
|
||||
dist
|
||||
yarn.lock
|
||||
.babelrc
|
||||
|
||||
.turbo
|
||||
.yarn
|
||||
@@ -1,291 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 1.1.46
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8f8a4f9b13`](https://github.com/medusajs/medusa/commit/8f8a4f9b1353087d98f6cc75346d43a7f49901a8)]:
|
||||
- medusa-interfaces@1.3.9
|
||||
|
||||
## 1.1.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`45996d58a2`](https://github.com/medusajs/medusa/commit/45996d58a2665d72335faad11bea958f8da74195), [`f86877586`](https://github.com/medusajs/medusa/commit/f86877586147ecedbf7f56a1c57f37ef0c33286c), [`46d610bc5`](https://github.com/medusajs/medusa/commit/46d610bc555797df2ae81eb89b18faf1411b33b8)]:
|
||||
- medusa-interfaces@1.3.8
|
||||
- medusa-core-utils@1.2.1
|
||||
|
||||
## 1.1.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0
|
||||
- medusa-interfaces@1.3.7
|
||||
|
||||
## 1.1.44-rc.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0-rc.0
|
||||
- medusa-interfaces@1.3.7-rc.0
|
||||
|
||||
## 1.1.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
|
||||
|
||||
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
|
||||
- medusa-core-utils@1.1.39
|
||||
- medusa-interfaces@1.3.6
|
||||
|
||||
## 1.1.42
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3011](https://github.com/medusajs/medusa/pull/3011) [`ce866475b`](https://github.com/medusajs/medusa/commit/ce866475b4b6c8b453638000f7b1df7a27daf45d) Thanks [@adrien2p](https://github.com/adrien2p)! - chore(_-payment-_): cleanup payment provider plugins
|
||||
|
||||
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
|
||||
|
||||
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
|
||||
- medusa-core-utils@1.1.38
|
||||
- medusa-interfaces@1.3.5
|
||||
|
||||
## 1.1.41
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
|
||||
|
||||
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
|
||||
- medusa-interfaces@1.3.4
|
||||
|
||||
## 1.1.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
|
||||
|
||||
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
|
||||
- medusa-core-utils@1.1.37
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.39](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.38...medusa-payment-adyen@1.1.39) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.38](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.37...medusa-payment-adyen@1.1.38) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.36...medusa-payment-adyen@1.1.37) (2021-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.35...medusa-payment-adyen@1.1.36) (2021-12-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.34...medusa-payment-adyen@1.1.35) (2021-11-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.33...medusa-payment-adyen@1.1.34) (2021-11-22)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.32...medusa-payment-adyen@1.1.33) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.31...medusa-payment-adyen@1.1.32) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.30...medusa-payment-adyen@1.1.31) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.29...medusa-payment-adyen@1.1.30) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.27...medusa-payment-adyen@1.1.29) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.27...medusa-payment-adyen@1.1.28) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.26...medusa-payment-adyen@1.1.27) (2021-09-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.25...medusa-payment-adyen@1.1.26) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.24...medusa-payment-adyen@1.1.25) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.23...medusa-payment-adyen@1.1.24) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.21...medusa-payment-adyen@1.1.23) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.21...medusa-payment-adyen@1.1.22) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.20...medusa-payment-adyen@1.1.21) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.19...medusa-payment-adyen@1.1.20) (2021-06-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.18...medusa-payment-adyen@1.1.19) (2021-06-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.17...medusa-payment-adyen@1.1.18) (2021-06-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- mobile pay support ([91511cb](https://github.com/medusajs/medusa/commit/91511cbdf8bc66f5688a36ecf56edb16a220cc82))
|
||||
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.16...medusa-payment-adyen@1.1.17) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.15...medusa-payment-adyen@1.1.16) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.14...medusa-payment-adyen@1.1.15) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.13...medusa-payment-adyen@1.1.14) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.12...medusa-payment-adyen@1.1.13) (2021-06-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [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)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.9...medusa-payment-adyen@1.1.10) (2021-04-20)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.8...medusa-payment-adyen@1.1.9) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
|
||||
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
|
||||
|
||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.7...medusa-payment-adyen@1.1.8) (2021-04-13)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.6...medusa-payment-adyen@1.1.7) (2021-03-30)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.5...medusa-payment-adyen@1.1.6) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.3...medusa-payment-adyen@1.1.5) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.3...medusa-payment-adyen@1.1.4) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.2...medusa-payment-adyen@1.1.3) (2021-02-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.1...medusa-payment-adyen@1.1.2) (2021-02-03)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.1.0...medusa-payment-adyen@1.1.1) (2021-01-27)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.0.13...medusa-payment-adyen@1.1.0) (2021-01-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.0.12...medusa-payment-adyen@1.0.13) (2020-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-payment-adyen@1.0.11...medusa-payment-adyen@1.0.12) (2020-11-24)
|
||||
|
||||
**Note:** Version bump only for package medusa-payment-adyen
|
||||
|
||||
## 1.0.11 (2020-10-19)
|
||||
|
||||
## 1.0.10 (2020-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
|
||||
|
||||
## 1.0.7 (2020-09-07)
|
||||
|
||||
## 1.0.1 (2020-09-05)
|
||||
|
||||
## 1.0.1-beta.0 (2020-09-04)
|
||||
|
||||
# 1.0.0 (2020-09-03)
|
||||
|
||||
# 1.0.0-alpha.30 (2020-08-28)
|
||||
|
||||
# 1.0.0-alpha.27 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.26 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.24 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.22 (2020-08-25)
|
||||
|
||||
# 1.0.0-alpha.6 (2020-08-21)
|
||||
|
||||
# 1.0.0-alpha.3 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.2 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.1 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.0 (2020-08-20)
|
||||
|
||||
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
|
||||
@@ -1,79 +0,0 @@
|
||||
# Adyen
|
||||
|
||||
Receive payments on your Medusa commerce application using Adyen.
|
||||
|
||||
> This plugin is not ready for production use. Community contributions are highly appreciated. You can learn more about contributing in [our repository](https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md).
|
||||
|
||||
[Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
|
||||
|
||||
## Features
|
||||
|
||||
- Authorize payments on orders from any sales channel.
|
||||
- Support for MobilePay.
|
||||
- Capture payments from the admin dashboard.
|
||||
- Support for Webhooks.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
|
||||
- [Adyen account](https://www.adyen.com)
|
||||
|
||||
---
|
||||
|
||||
## How to Install
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend:
|
||||
|
||||
```bash
|
||||
npm install medusa-payment-adyen
|
||||
```
|
||||
|
||||
2\. Set the following environment variables in `.env`:
|
||||
|
||||
```bash
|
||||
ADYEN_API_KEY=<YOUR_API_KEY>
|
||||
ADYEN_NOTIFICATION_HMAC=<YOUR_NOTIFICATION_HMAC>
|
||||
ADYEN_RETURN_URL=<YOUR_RETURN_URL>
|
||||
ADYEN_MERCHANT_ACCOUNT=<YOUR_MERCHANT_ACCOUNT>
|
||||
ADYEN_ORIGIN=<YOUR_ORIGIN>
|
||||
ADYEN_ENVIRONMENT=<YOUR_ENVIRONMENT>
|
||||
ADYEN_LIVE_ENDPOINT_PREFIX=<YOUR_LIVE_ENDPOINT_PREFIX>
|
||||
ADYEN_PAYMENT_ENDPOINT=<YOUR_PAYMENT_ENDPOINT>
|
||||
```
|
||||
|
||||
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
||||
|
||||
```js
|
||||
const plugins = [
|
||||
// ...
|
||||
{
|
||||
resolve: `medusa-payment-adyen`,
|
||||
options: {
|
||||
api_key: process.env.STRIPE_API_KEY,
|
||||
notification_hmac: process.env.ADYEN_NOTIFICATION_HMAC,
|
||||
return_url: process.env.ADYEN_RETURN_URL,
|
||||
merchant_account: process.env.ADYEN_MERCHANT_ACCOUNT,
|
||||
origin: process.env.ADYEN_ORIGIN,
|
||||
environment: process.env.ADYEN_ENVIRONMENT,
|
||||
live_endpoint_prefix: process.env.ADYEN_LIVE_ENDPOINT_PREFIX,
|
||||
payment_endpoint: process.env.ADYEN_PAYMENT_ENDPOINT,
|
||||
},
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test the Plugin
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend to run the backend:
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
2\. Enable Adyen in a region in the admin. You can refer to [this User Guide](https://docs.medusajs.com/user-guide/regions/providers) to learn how to do that. Alternatively, you can use the [Admin APIs](https://docs.medusajs.com/api/admin#tag/Region/operation/PostRegionsRegion).
|
||||
|
||||
3\. Place an order using a storefront or the [Store APIs](https://docs.medusajs.com/api/store). You should be able to use Stripe as a payment method.
|
||||
@@ -1 +0,0 @@
|
||||
// noop
|
||||
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"name": "medusa-payment-adyen",
|
||||
"version": "1.1.46",
|
||||
"description": "Adyen Payment provider for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/medusa-payment-adyen"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"author": "Oliver Juhl",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.5",
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/node": "^7.7.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
||||
"@babel/preset-env": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"@babel/runtime": "^7.9.6",
|
||||
"client-sessions": "^0.8.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-interfaces": "^1.3.9",
|
||||
"medusa-test-utils": "^1.1.42"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "cross-env NODE_ENV=production yarn run build",
|
||||
"test": "jest --passWithNoTests src",
|
||||
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
|
||||
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"medusa-interfaces": "1.3.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"@adyen/api-library": "^5.0.1",
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"lodash": "^4.17.21",
|
||||
"medusa-core-utils": "^1.2.1"
|
||||
},
|
||||
"gitHead": "81a7ff73d012fda722f6e9ef0bd9ba0232d37808",
|
||||
"keywords": [
|
||||
"medusa-plugin",
|
||||
"medusa-plugin-payment"
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Router } from "express"
|
||||
import store from "./routes/store"
|
||||
import hooks from "./routes/hooks"
|
||||
|
||||
export default (rootDirectory) => {
|
||||
const app = Router()
|
||||
store(app, rootDirectory)
|
||||
hooks(app, rootDirectory)
|
||||
return app
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export default (fn) => (...args) => fn(...args).catch(args[2])
|
||||
@@ -1,5 +0,0 @@
|
||||
import { default as wrap } from "./await-middleware"
|
||||
|
||||
export default {
|
||||
wrap,
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
export default async (req, res) => {
|
||||
const adyenService = req.scope.resolve("adyenService")
|
||||
const eventBus = req.scope.resolve("eventBusService")
|
||||
|
||||
const notification = req.body
|
||||
const event = notification.notificationItems[0].NotificationRequestItem
|
||||
|
||||
const valid = adyenService.validateNotification(event)
|
||||
|
||||
if (!valid) {
|
||||
res.status(401).send(`Unauthorized webhook event`)
|
||||
return
|
||||
}
|
||||
|
||||
eventBus.emit("adyen.notification_received", event)
|
||||
res.status(200).send("[accepted]")
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { Router } from "express"
|
||||
import cors from "cors"
|
||||
import bodyParser from "body-parser"
|
||||
import middlewares from "../../middlewares"
|
||||
import { getConfigFile, parseCorsOrigins } from "medusa-core-utils"
|
||||
|
||||
const route = Router()
|
||||
|
||||
export default (app, rootDirectory) => {
|
||||
const { configModule } = getConfigFile(rootDirectory, `medusa-config`)
|
||||
const config = (configModule && configModule.projectConfig) || {}
|
||||
|
||||
const storeCors = config.store_cors || ""
|
||||
route.use(
|
||||
cors({
|
||||
origin: parseCorsOrigins(storeCors),
|
||||
credentials: true,
|
||||
})
|
||||
)
|
||||
|
||||
app.use("/adyen/webhooks", route)
|
||||
|
||||
route.post(
|
||||
"/notification",
|
||||
bodyParser.json(),
|
||||
middlewares.wrap(require("./adyen-notification").default)
|
||||
)
|
||||
|
||||
return app
|
||||
}
|
||||
@@ -1,432 +0,0 @@
|
||||
import axios from "axios"
|
||||
import _ from "lodash"
|
||||
import { CheckoutAPI, Client, Config, hmacValidator } from "@adyen/api-library"
|
||||
import { BaseService } from "medusa-interfaces"
|
||||
|
||||
class AdyenService extends BaseService {
|
||||
constructor({ cartService }, options) {
|
||||
super()
|
||||
|
||||
/** @private @constant {CartService} */
|
||||
this.cartService_ = cartService
|
||||
|
||||
/**
|
||||
* {
|
||||
* api_key: "",
|
||||
* notification_hmac: "",
|
||||
* return_url: "",
|
||||
* merchant_account: "",
|
||||
* origin: "",
|
||||
* environment: "",
|
||||
* live_endpoint_prefix: "",
|
||||
* payment_endpoint: ""
|
||||
* }
|
||||
*/
|
||||
this.options_ = options
|
||||
|
||||
/** @private @constant {AxiosClient} */
|
||||
this.adyenClient_ = this.initAdyenClient()
|
||||
|
||||
/** @private @constant {AxiosClient} */
|
||||
this.adyenPaymentApi = this.initPaymentClient()
|
||||
}
|
||||
|
||||
withTransaction(transactionManager) {
|
||||
if (!transactionManager) {
|
||||
return this
|
||||
}
|
||||
|
||||
const cloned = new AdyenService({
|
||||
cartService: this.cartService_,
|
||||
totalsService: this.totalsService_,
|
||||
})
|
||||
|
||||
this.transactionManager_ = transactionManager
|
||||
|
||||
return cloned
|
||||
}
|
||||
|
||||
getOptions() {
|
||||
return this.options_
|
||||
}
|
||||
|
||||
initAdyenClient() {
|
||||
const config = new Config()
|
||||
config.apiKey = this.options_.api_key
|
||||
config.merchantAccount = this.options_.merchant_account
|
||||
|
||||
const client = new Client({
|
||||
config,
|
||||
})
|
||||
|
||||
if (this.options_.live_endpoint_prefix) {
|
||||
client.setEnvironment(
|
||||
this.options_.environment,
|
||||
this.options_.live_endpoint_prefix
|
||||
)
|
||||
} else {
|
||||
client.setEnvironment(this.options_.environment)
|
||||
}
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
initPaymentClient() {
|
||||
return axios.create({
|
||||
baseURL:
|
||||
this.options_.payment_endpoint || "https://checkout-test.adyen.com/v67",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-API-key": this.options_.api_key,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an Adyen webhook notification
|
||||
* @param {object} notification - notification to validate
|
||||
* @returns {string} the status of the payment
|
||||
*/
|
||||
validateNotification(notification) {
|
||||
const validator = new hmacValidator()
|
||||
|
||||
const validated = validator.validateHMAC(
|
||||
notification,
|
||||
this.options_.notification_hmac
|
||||
)
|
||||
|
||||
return validated
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve stored payment methods from Adyen.
|
||||
* @param {Customer} customer - customer to retrieve methods for
|
||||
* @returns {Promise} result containing the stored payment methods from Adyen
|
||||
*/
|
||||
async retrieveSavedMethods(customer) {
|
||||
let request = {
|
||||
merchantAccount: this.options_.merchant_account,
|
||||
channel: "Web",
|
||||
shopperReference: customer.id,
|
||||
}
|
||||
|
||||
try {
|
||||
const checkout = new CheckoutAPI(this.adyenClient_)
|
||||
const methods = await checkout.paymentMethods(request)
|
||||
return methods.storedPaymentMethods || []
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve payment methods from Adyen.
|
||||
* @param {string[]} allowedMethods - the allowed methods based on region
|
||||
* @param {number} total - total amount to be paid with payment methods
|
||||
* @param {string} currency - currency code to use for the payment
|
||||
* @param {string} customerId - id of the customer paying
|
||||
* @returns {Promise} result containing the payment methods from Adyen
|
||||
*/
|
||||
async retrievePaymentMethods(allowedMethods, total, currency, customerId) {
|
||||
let request = {
|
||||
allowedPaymentMethods: allowedMethods,
|
||||
amount: {
|
||||
value: total,
|
||||
currency: currency,
|
||||
},
|
||||
merchantAccount: this.options_.merchant_account,
|
||||
channel: "Web",
|
||||
shopperReference: customerId,
|
||||
}
|
||||
|
||||
try {
|
||||
const checkout = new CheckoutAPI(this.adyenClient_)
|
||||
return checkout.paymentMethods(request)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Status for Adyen payment.
|
||||
* @param {object} paymentData - payment method data from cart
|
||||
* @returns {string} the status of the payment
|
||||
*/
|
||||
getStatus(paymentData) {
|
||||
const { resultCode } = paymentData
|
||||
let status = "pending"
|
||||
|
||||
if (resultCode === "Pending") {
|
||||
return status
|
||||
}
|
||||
|
||||
if (resultCode === "Refused") {
|
||||
return status
|
||||
}
|
||||
|
||||
if (resultCode === "Error") {
|
||||
status = "error"
|
||||
}
|
||||
|
||||
if (resultCode === "Authorised") {
|
||||
status = "authorized"
|
||||
}
|
||||
|
||||
if (resultCode === "Canceled") {
|
||||
status = "canceled"
|
||||
}
|
||||
|
||||
if (resultCode === "ChallengeShopper") {
|
||||
status = "requires_more"
|
||||
}
|
||||
|
||||
if (resultCode === "RedirectShopper") {
|
||||
status = "requires_more"
|
||||
}
|
||||
|
||||
if (resultCode === "IdentifyShopper") {
|
||||
status = "requires_more"
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Adyen payment object.
|
||||
* @param {Cart} cart - cart to initiate payment for
|
||||
* @returns {object} empty payment data
|
||||
*/
|
||||
async createPayment(cart) {
|
||||
return { cart_id: cart.id }
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Adyen payment. This is not supported by adyen, so we simply
|
||||
* return the current payment method data
|
||||
* @param {object} data - payment session
|
||||
* @returns {object} payment method data
|
||||
*/
|
||||
async getPaymentData(paymentSession) {
|
||||
return { ...paymentSession.data }
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Adyen payment. This is not supported by adyen, so we simply
|
||||
* return the current payment method data
|
||||
* @param {object} sessionData - the data of the payment to retrieve
|
||||
* @returns {Promise<object>} Stripe payment intent
|
||||
*/
|
||||
async retrieve(sessionData) {
|
||||
return sessionData
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and authorizes an Adyen payment.
|
||||
* Requires cart_id in context for authorization.
|
||||
* Return status of authorization result.
|
||||
* @param {object} sessionData - payment session data
|
||||
* @param {object} context - properties relevant to current context
|
||||
* @returns {Promise<{ status: string, data: object }>} result with data and status
|
||||
*/
|
||||
async authorizePayment(session, context) {
|
||||
const sessionData = session.data
|
||||
|
||||
const status = this.getStatus(sessionData)
|
||||
|
||||
if (sessionData.resultCode === "RedirectShopper") {
|
||||
return { data: sessionData, status: "requires_more" }
|
||||
}
|
||||
|
||||
// If session data is present, we already called authorize once.
|
||||
// Therefore, this is most likely a call for getting additional details
|
||||
if (status === "requires_more") {
|
||||
const updated = await this.updatePaymentData(sessionData, {
|
||||
details: sessionData.details,
|
||||
paymentData: sessionData.paymentData,
|
||||
})
|
||||
|
||||
return { data: updated, status: this.getStatus(updated) }
|
||||
}
|
||||
|
||||
if (status === "authorized") {
|
||||
return { data: sessionData, status: "authorized" }
|
||||
}
|
||||
|
||||
const cart = await this.cartService_.retrieve(session.cart_id, {
|
||||
select: ["total"],
|
||||
relations: ["region", "shipping_address"],
|
||||
})
|
||||
|
||||
const amount = {
|
||||
currency: cart.region.currency_code.toUpperCase(),
|
||||
value: cart.total,
|
||||
}
|
||||
|
||||
let paymentData = sessionData.paymentData
|
||||
if (!paymentData) {
|
||||
paymentData = {
|
||||
paymentMethod: {
|
||||
type: sessionData.type,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
let request = {
|
||||
amount,
|
||||
merchantAccount: this.options_.merchant_account,
|
||||
shopperIP: context.ip_address || "",
|
||||
shopperReference: cart.customer_id,
|
||||
returnUrl: this.options_.return_url,
|
||||
paymentMethod: paymentData.paymentMethod,
|
||||
reference: cart.id,
|
||||
metadata: {
|
||||
cart_id: cart.id,
|
||||
},
|
||||
}
|
||||
|
||||
const checkout = new CheckoutAPI(this.adyenClient_)
|
||||
|
||||
try {
|
||||
const authorizedPayment = await checkout.payments(request, {
|
||||
idempotencyKey: context.idempotency_key || "",
|
||||
})
|
||||
|
||||
return {
|
||||
data: authorizedPayment,
|
||||
status: this.getStatus(authorizedPayment),
|
||||
}
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async updatePaymentData(sessionData, update) {
|
||||
if (_.isEmpty(update.details)) {
|
||||
return { ...sessionData, ...update }
|
||||
}
|
||||
|
||||
const checkout = new CheckoutAPI(this.adyenClient_)
|
||||
const updated = await checkout.paymentsDetails(update)
|
||||
|
||||
return updated
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an Adyen payment.
|
||||
* @param {object} paymentData - payment data to update
|
||||
* @param {details} details - details to update
|
||||
* @returns {Promise} result of the update operation
|
||||
*/
|
||||
async updatePayment(paymentData, details) {
|
||||
return paymentData
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional details
|
||||
* @param {object} paymentData - payment data
|
||||
* @param {object} details - payment details
|
||||
* @returns {Promise} current payment result
|
||||
*/
|
||||
async additionalDetails(paymentData, details) {
|
||||
const request = {
|
||||
paymentData,
|
||||
details,
|
||||
}
|
||||
|
||||
const checkout = new CheckoutAPI(this.adyenClient_)
|
||||
return checkout.paymentsDetails(request)
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures an Adyen payment
|
||||
* @param {object} payment - payment to capture
|
||||
* @returns {string} status = processing_captures
|
||||
*/
|
||||
async capturePayment(payment) {
|
||||
if (payment.captured_at !== null) {
|
||||
return
|
||||
}
|
||||
|
||||
const { pspReference, merchantReference } = payment.data
|
||||
const { amount, currency_code } = payment
|
||||
|
||||
try {
|
||||
const captured = await this.adyenPaymentApi.post(
|
||||
`/payments/${pspReference}/captures`,
|
||||
{
|
||||
merchantAccount: this.options_.merchant_account,
|
||||
amount: {
|
||||
value: amount,
|
||||
currency: currency_code.toUpperCase(),
|
||||
},
|
||||
reference: merchantReference,
|
||||
}
|
||||
)
|
||||
|
||||
if (captured.data.pspReference && captured.data.status !== "received") {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_ARGUMENT,
|
||||
"Could not process capture"
|
||||
)
|
||||
}
|
||||
|
||||
return { pspReference }
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refunds an Adyen payment
|
||||
* @param {object} payment - payment to refund
|
||||
* @param {number} amountToRefund - amount to refund
|
||||
* @returns {object} payment data result of refund
|
||||
*/
|
||||
async refundPayment(payment, amountToRefund) {
|
||||
const { pspReference } = payment.data
|
||||
const { currency_code } = payment
|
||||
|
||||
const refundAmount = {
|
||||
currency: currency_code.toUpperCase(),
|
||||
value: amountToRefund,
|
||||
}
|
||||
|
||||
try {
|
||||
await this.adyenPaymentApi.post(`/payments/${pspReference}/refunds`, {
|
||||
merchantAccount: this.options_.merchant_account,
|
||||
amount: refundAmount,
|
||||
})
|
||||
|
||||
return { pspReference }
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adyen does not have a way of deleting payments, hence the empty impl.
|
||||
*/
|
||||
async deletePayment(_) {
|
||||
return {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels an Adyen payment.
|
||||
* @param {object} payment - payment to cancel
|
||||
* @returns {object} payment data result of cancel
|
||||
*/
|
||||
async cancelPayment(payment) {
|
||||
const { pspReference } = payment.data
|
||||
|
||||
try {
|
||||
return this.adyenPaymentApi.post("/cancel", {
|
||||
originalReference: pspReference,
|
||||
merchantAccount: this.options_.merchant_account,
|
||||
})
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AdyenService
|
||||
@@ -1,59 +0,0 @@
|
||||
import { PaymentService } from "medusa-interfaces"
|
||||
|
||||
class MobilePayAdyenService extends PaymentService {
|
||||
static identifier = "mobilepay-adyen"
|
||||
|
||||
constructor({ adyenService }) {
|
||||
super()
|
||||
|
||||
this.adyenService_ = adyenService
|
||||
}
|
||||
|
||||
async getStatus(paymentData) {
|
||||
return this.adyenService_.getStatus(paymentData)
|
||||
}
|
||||
|
||||
async createPayment(data) {
|
||||
const raw = await this.adyenService_.createPayment(data)
|
||||
raw.type = "mobilepay"
|
||||
return raw
|
||||
}
|
||||
|
||||
async authorizePayment(sessionData, context) {
|
||||
return this.adyenService_.authorizePayment(sessionData, context)
|
||||
}
|
||||
|
||||
async retrievePayment(data) {
|
||||
return this.adyenService_.retrievePayment(data)
|
||||
}
|
||||
|
||||
async updatePayment(data, _) {
|
||||
return this.adyenService_.updatePayment(data)
|
||||
}
|
||||
|
||||
async updatePaymentData(sessionData, update) {
|
||||
return this.adyenService_.updatePaymentData(sessionData, update)
|
||||
}
|
||||
|
||||
async getPaymentData(data) {
|
||||
return this.adyenService_.getPaymentData(data)
|
||||
}
|
||||
|
||||
async deletePayment(data) {
|
||||
return this.adyenService_.deletePayment(data)
|
||||
}
|
||||
|
||||
async capturePayment(data) {
|
||||
return this.adyenService_.capturePayment(data)
|
||||
}
|
||||
|
||||
async refundPayment(data, amountToRefund) {
|
||||
return this.adyenService_.refundPayment(data, amountToRefund)
|
||||
}
|
||||
|
||||
async cancelPayment(data) {
|
||||
return this.adyenService_.cancelPayment(data)
|
||||
}
|
||||
}
|
||||
|
||||
export default MobilePayAdyenService
|
||||
@@ -1,158 +0,0 @@
|
||||
class AdyenSubscriber {
|
||||
constructor(container) {
|
||||
/** @private @const {CartService} */
|
||||
this.cartService_ = container.cartService
|
||||
|
||||
/** @private @const {OrderService} */
|
||||
this.orderService_ = container.orderService
|
||||
|
||||
/** @private @const {EventBusService} */
|
||||
this.eventBus_ = container.eventBusService
|
||||
|
||||
/** @private @const {PaymentRepository} */
|
||||
this.paymentRepository_ = container.paymentRepository
|
||||
|
||||
this.manager_ = container.manager
|
||||
|
||||
this.eventBus_.subscribe(
|
||||
"adyen.notification_received",
|
||||
async (notification) => this.handleAdyenNotification(notification)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Webhook handler for Adyen payment.
|
||||
* @param {object} notification - webhook notification object
|
||||
* @returns {string} the status of the payment intent
|
||||
*/
|
||||
async handleAdyenNotification(notification) {
|
||||
switch (true) {
|
||||
case notification.success === "true" &&
|
||||
notification.eventCode === "AUTHORISATION": {
|
||||
this.handleAuthorization_(notification)
|
||||
break
|
||||
}
|
||||
case notification.success === "false" &&
|
||||
notification.eventCode === "AUTHORISATION": {
|
||||
this.handleFailedAuthorization_(notification)
|
||||
break
|
||||
}
|
||||
case notification.success === "true" &&
|
||||
notification.eventCode === "CAPTURE_FAILED": {
|
||||
this.handleFailedCapture_(notification)
|
||||
break
|
||||
}
|
||||
case notification.success === "false" &&
|
||||
notification.eventCode === "CAPTURE": {
|
||||
this.handleFailedCapture_(notification)
|
||||
break
|
||||
}
|
||||
case notification.success === "false" &&
|
||||
notification.eventCode === "REFUND": {
|
||||
this.handleFailedRefund_(notification)
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
async handleFailedAuthorization_(notification) {
|
||||
const cartId = notification.additionalData["metadata.cart_id"]
|
||||
const cart = await this.cartService_.retrieve(cartId, {
|
||||
relations: ["payment_sessions"],
|
||||
})
|
||||
|
||||
const { payment_session } = cart
|
||||
|
||||
const updated = {
|
||||
...payment_session,
|
||||
status: "error",
|
||||
data: {
|
||||
...payment_session.data,
|
||||
pspReference: notification.pspReference,
|
||||
},
|
||||
}
|
||||
|
||||
await this.cartService_.updatePaymentSession(cart.id, updated)
|
||||
}
|
||||
|
||||
async handleAuthorization_(notification) {
|
||||
const cartId = notification.additionalData["metadata.cart_id"]
|
||||
const paymentRepository = this.manager_.getCustomRepository(
|
||||
this.paymentRepository_
|
||||
)
|
||||
|
||||
// We need to ensure, that an order is created in situations, where the
|
||||
// customer might have closed their browser prior to order creation
|
||||
try {
|
||||
const orderPayment = await paymentRepository.findOne({
|
||||
where: { cart_id: cartId },
|
||||
})
|
||||
|
||||
if (!orderPayment) {
|
||||
throw new Error("Payment not found")
|
||||
}
|
||||
|
||||
const updatedPayment = {
|
||||
...orderPayment,
|
||||
data: {
|
||||
...orderPayment.data,
|
||||
resultCode: "Authorised",
|
||||
pspReference: notification.pspReference,
|
||||
},
|
||||
}
|
||||
|
||||
await this.paymentRepository_.save(updatedPayment)
|
||||
} catch (error) {
|
||||
await this.manager_.transaction(async (manager) => {
|
||||
const session = {
|
||||
pspReference: notification.pspReference,
|
||||
resultCode: "Authorised",
|
||||
}
|
||||
|
||||
await this.cartService_
|
||||
.withTransaction(manager)
|
||||
.updatePaymentSession(cartId, session)
|
||||
|
||||
await this.cartService_
|
||||
.withTransaction(manager)
|
||||
.authorizePayment(cartId)
|
||||
|
||||
await this.orderService_.withTransaction(manager).createFromCart(cartId)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async handleFailedCapture_(notification) {
|
||||
const cartId = notification.additionalData["metadata.cart_id"]
|
||||
|
||||
const order = await this.orderService_.retrieveByCartId(cartId)
|
||||
|
||||
await this.orderService_.update(order.id, {
|
||||
payment_status: "requires_action",
|
||||
})
|
||||
|
||||
await this.eventBus_.emit("order.payment_capture_failed", {
|
||||
order,
|
||||
error: new Error(`Adyen payment capture: ${notification.reason}`),
|
||||
})
|
||||
}
|
||||
|
||||
async handleFailedRefund_(notification) {
|
||||
const cartId = notification.additionalData["metadata.cart_id"]
|
||||
|
||||
const order = await this.orderService_.retrieveByCartId(cartId)
|
||||
|
||||
await this.orderService_.update(order.id, {
|
||||
payment_status: "requires_action",
|
||||
})
|
||||
|
||||
await this.eventBus_.emit("order.refund_failed", {
|
||||
order,
|
||||
error: new Error(`Adyen payment capture: ${notification.reason}`),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default AdyenSubscriber
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-instanceof",
|
||||
"@babel/plugin-transform-classes"
|
||||
],
|
||||
"presets": ["@babel/preset-env"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
}
|
||||
}
|
||||
17
packages/medusa-plugin-brightpearl/.gitignore
vendored
17
packages/medusa-plugin-brightpearl/.gitignore
vendored
@@ -1,17 +0,0 @@
|
||||
/lib
|
||||
node_modules
|
||||
.DS_store
|
||||
.env*
|
||||
/*.js
|
||||
!index.js
|
||||
yarn.lock
|
||||
|
||||
/dist
|
||||
|
||||
/api
|
||||
/services
|
||||
/models
|
||||
/subscribers
|
||||
/loaders
|
||||
/utils
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
.DS_store
|
||||
src
|
||||
dist
|
||||
yarn.lock
|
||||
.babelrc
|
||||
|
||||
.turbo
|
||||
.yarn
|
||||
@@ -1,560 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 1.3.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5543](https://github.com/medusajs/medusa/pull/5543) [`f90ba0208`](https://github.com/medusajs/medusa/commit/f90ba02087778d8131aed3a59a6dc9c8ca3c95f4) Thanks [@adrien2p](https://github.com/adrien2p)! - feat(utils): Introduce promiseAll util
|
||||
|
||||
- Updated dependencies [[`c39bf69a5`](https://github.com/medusajs/medusa/commit/c39bf69a5e5cae75d7fa12aa6022b10903557a32), [`154c9b43b`](https://github.com/medusajs/medusa/commit/154c9b43bde1fdff562aba9da8a79af2660b29b3)]:
|
||||
- @medusajs/utils@1.10.5
|
||||
|
||||
## 1.3.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5390](https://github.com/medusajs/medusa/pull/5390) [`04e9dd6a6`](https://github.com/medusajs/medusa/commit/04e9dd6a6a00bb67a1ce55bf575e7c13fb9db223) Thanks [@josipmatichr](https://github.com/josipmatichr)! - fix(medusa-plugin-brightpearl): Missing discounts rule relation
|
||||
|
||||
## 1.3.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4503](https://github.com/medusajs/medusa/pull/4503) [`d184d23c6`](https://github.com/medusajs/medusa/commit/d184d23c6384d5f8bf52827826b62c6bef37f884) Thanks [@pKorsholm](https://github.com/pKorsholm)! - feat(medusa,inventory,types,brightpearl): update some inventory methods to be bulk-operation enabled
|
||||
|
||||
- [#4383](https://github.com/medusajs/medusa/pull/4383) [`130465713`](https://github.com/medusajs/medusa/commit/1304657133585f7850807d9508be2780a08d2b12) Thanks [@pKorsholm](https://github.com/pKorsholm)! - fix(medusa-plugin-brightpearl): change the way reservations are handled
|
||||
|
||||
## 1.3.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4389](https://github.com/medusajs/medusa/pull/4389) [`9dcdc0041`](https://github.com/medusajs/medusa/commit/9dcdc0041a2b08cc0723343dd8d9127d9977b086) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa, utils): fix the way selects are consumed alongside the relations
|
||||
|
||||
## 1.3.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4160](https://github.com/medusajs/medusa/pull/4160) [`572280e1d`](https://github.com/medusajs/medusa/commit/572280e1d1deb1d01660168b453ad397fa382a79) Thanks [@pKorsholm](https://github.com/pKorsholm)! - fix(medusa-plugin-bright-pearl): update order creation to include sales channel brightpearl id where possible
|
||||
|
||||
- [#4295](https://github.com/medusajs/medusa/pull/4295) [`1d91fa4e0`](https://github.com/medusajs/medusa/commit/1d91fa4e08fa3d9ecb6f0aa403655fe75e2b5e6f) Thanks [@pKorsholm](https://github.com/pKorsholm)! - fix(brightpearl): split externalRef to get product id
|
||||
|
||||
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
|
||||
|
||||
## 1.3.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3192](https://github.com/medusajs/medusa/pull/3192) [`4a8562743`](https://github.com/medusajs/medusa/commit/4a8562743569f5bbb7bd0894b025a74725726529) Thanks [@pKorsholm](https://github.com/pKorsholm)! - feat(medusa-plugin-brightpearl, inventory, medusa): Multiwarehouse integration for brightpearl
|
||||
|
||||
## 1.3.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0
|
||||
- medusa-interfaces@1.3.7
|
||||
|
||||
## 1.3.7-rc.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0-rc.0
|
||||
- medusa-interfaces@1.3.7-rc.0
|
||||
|
||||
## 1.3.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
|
||||
|
||||
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
|
||||
- medusa-core-utils@1.1.39
|
||||
- medusa-interfaces@1.3.6
|
||||
|
||||
## 1.3.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
|
||||
|
||||
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
|
||||
- medusa-core-utils@1.1.38
|
||||
- medusa-interfaces@1.3.5
|
||||
|
||||
## 1.3.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
|
||||
|
||||
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
|
||||
- medusa-interfaces@1.3.4
|
||||
|
||||
## 1.3.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2821](https://github.com/medusajs/medusa/pull/2821) [`ba6bb3e54`](https://github.com/medusajs/medusa/commit/ba6bb3e54b9989cecf476c7411c406a43562efe1) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa): Extract cron jobs logic from the EventBusService to its own service JobSchedulerService
|
||||
|
||||
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
|
||||
- medusa-core-utils@1.1.37
|
||||
|
||||
## 1.3.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2536](https://github.com/medusajs/medusa/pull/2536) [`61da5f365`](https://github.com/medusajs/medusa/commit/61da5f365061c3d82d402e250d61ac8991b590a2) Thanks [@srindom](https://github.com/srindom)! - fix(medusa-plugin-brightpearl): account for shipping prices being tax inclusive
|
||||
|
||||
- Updated dependencies [[`ea3d73882`](https://github.com/medusajs/medusa/commit/ea3d7388234f23c4a5bc7ceb55c493a097b76c12)]:
|
||||
- medusa-core-utils@1.1.34
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.3.1](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.3.0...medusa-plugin-brightpearl@1.3.1) (2022-07-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
# [1.3.0](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.2.1...medusa-plugin-brightpearl@1.3.0) (2022-05-01)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.45...medusa-plugin-brightpearl@1.2.1) (2022-02-28)
|
||||
|
||||
### Features
|
||||
|
||||
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([47588e7](https://github.com/medusajs/medusa/commit/47588e7a8d3b2ae2fed0c1e87fdf1ee2db6bcdc2)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
|
||||
|
||||
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.45...medusa-plugin-brightpearl@1.2.0) (2022-02-25)
|
||||
|
||||
### Features
|
||||
|
||||
- new tax api ([#979](https://github.com/medusajs/medusa/issues/979)) ([c56660f](https://github.com/medusajs/medusa/commit/c56660fca9921a3f3637bc137d9794781c5b090f)), closes [#885](https://github.com/medusajs/medusa/issues/885) [#896](https://github.com/medusajs/medusa/issues/896) [#911](https://github.com/medusajs/medusa/issues/911) [#945](https://github.com/medusajs/medusa/issues/945) [#950](https://github.com/medusajs/medusa/issues/950) [#951](https://github.com/medusajs/medusa/issues/951) [#954](https://github.com/medusajs/medusa/issues/954) [#969](https://github.com/medusajs/medusa/issues/969) [#998](https://github.com/medusajs/medusa/issues/998) [#1017](https://github.com/medusajs/medusa/issues/1017) [#1110](https://github.com/medusajs/medusa/issues/1110)
|
||||
|
||||
## [1.1.45](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.44...medusa-plugin-brightpearl@1.1.45) (2022-02-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release ([fc3fbc8](https://github.com/medusajs/medusa/commit/fc3fbc897fad5c8a5d3eea828ac7277fba9d70af))
|
||||
|
||||
## [1.1.44](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.43...medusa-plugin-brightpearl@1.1.44) (2022-02-06)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.43](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.42...medusa-plugin-brightpearl@1.1.43) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.42](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.41...medusa-plugin-brightpearl@1.1.42) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.41](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.40...medusa-plugin-brightpearl@1.1.41) (2021-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.40](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.39...medusa-plugin-brightpearl@1.1.40) (2021-12-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.39](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.38...medusa-plugin-brightpearl@1.1.39) (2021-11-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.38](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.37...medusa-plugin-brightpearl@1.1.38) (2021-11-22)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.36...medusa-plugin-brightpearl@1.1.37) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.35...medusa-plugin-brightpearl@1.1.36) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.34...medusa-plugin-brightpearl@1.1.35) (2021-10-26)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- add missing discount rule to bp orders ([#680](https://github.com/medusajs/medusa/issues/680)) ([d8422fc](https://github.com/medusajs/medusa/commit/d8422fc759f8a55e6290d4f54f3ea38df3118c8b))
|
||||
|
||||
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.33...medusa-plugin-brightpearl@1.1.34) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.32...medusa-plugin-brightpearl@1.1.33) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.30...medusa-plugin-brightpearl@1.1.32) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.30...medusa-plugin-brightpearl@1.1.31) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.30...medusa-plugin-brightpearl@1.1.30) (2021-09-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.30...medusa-plugin-brightpearl@1.1.29) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.28...medusa-plugin-brightpearl@1.1.30) (2021-09-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- account for non-division currencies in sales credit ([#342](https://github.com/medusajs/medusa/issues/342)) ([bd1e115](https://github.com/medusajs/medusa/commit/bd1e115696cf020a29bbfe07e5e85a3e0314bf78))
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.28...medusa-plugin-brightpearl@1.1.29) (2021-08-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- account for non-division currencies in sales credit ([#342](https://github.com/medusajs/medusa/issues/342)) ([bd1e115](https://github.com/medusajs/medusa/commit/bd1e115696cf020a29bbfe07e5e85a3e0314bf78))
|
||||
|
||||
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.27...medusa-plugin-brightpearl@1.1.28) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.26...medusa-plugin-brightpearl@1.1.27) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.24...medusa-plugin-brightpearl@1.1.26) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.24...medusa-plugin-brightpearl@1.1.25) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.23...medusa-plugin-brightpearl@1.1.24) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.22...medusa-plugin-brightpearl@1.1.23) (2021-06-24)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.21...medusa-plugin-brightpearl@1.1.22) (2021-06-23)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **brightpearl:** chunked product availabilities in sync ([fd82de6](https://github.com/medusajs/medusa/commit/fd82de6ef919a53dc25d387a809f7eea998b5e04))
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.20...medusa-plugin-brightpearl@1.1.21) (2021-06-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.19...medusa-plugin-brightpearl@1.1.20) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.18...medusa-plugin-brightpearl@1.1.19) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.17...medusa-plugin-brightpearl@1.1.18) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.16...medusa-plugin-brightpearl@1.1.17) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.15...medusa-plugin-brightpearl@1.1.16) (2021-06-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [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)
|
||||
|
||||
### Features
|
||||
|
||||
- **medusa:** Swaps on swaps ([#229](https://github.com/medusajs/medusa/issues/229)) ([f8f1f57](https://github.com/medusajs/medusa/commit/f8f1f57fa1bcdc6f7ae4183e657a07e2641b1345))
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.13...medusa-plugin-brightpearl@1.1.13) (2021-04-20)
|
||||
|
||||
### Features
|
||||
|
||||
- **medusa:** Swaps on swaps ([#229](https://github.com/medusajs/medusa/issues/229)) ([f8f1f57](https://github.com/medusajs/medusa/commit/f8f1f57fa1bcdc6f7ae4183e657a07e2641b1345))
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.12...medusa-plugin-brightpearl@1.1.13) (2021-04-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.12](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.11...medusa-plugin-brightpearl@1.1.12) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- bp swaps ([e105d4e](https://github.com/medusajs/medusa/commit/e105d4edde5793f40e867291606b3db5e44dc24f))
|
||||
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
|
||||
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
|
||||
- typo ([37ab52b](https://github.com/medusajs/medusa/commit/37ab52b19514fb1dfd864f0c218efd7ad205ff30))
|
||||
|
||||
## [1.1.11](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.10...medusa-plugin-brightpearl@1.1.11) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- bp swaps ([e105d4e](https://github.com/medusajs/medusa/commit/e105d4edde5793f40e867291606b3db5e44dc24f))
|
||||
- typo ([37ab52b](https://github.com/medusajs/medusa/commit/37ab52b19514fb1dfd864f0c218efd7ad205ff30))
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.9...medusa-plugin-brightpearl@1.1.10) (2021-04-01)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- don't divide zero decimal currencies ([cfab2d4](https://github.com/medusajs/medusa/commit/cfab2d408a296a938266d0989b1de67d060b2ed5))
|
||||
- publish assist ([7719957](https://github.com/medusajs/medusa/commit/7719957b44a0c0d950eff948faf31188fe0e3ef1))
|
||||
|
||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.9...medusa-plugin-brightpearl@1.1.9) (2021-03-30)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- don't divide zero decimal currencies ([cfab2d4](https://github.com/medusajs/medusa/commit/cfab2d408a296a938266d0989b1de67d060b2ed5))
|
||||
- publish assist ([7719957](https://github.com/medusajs/medusa/commit/7719957b44a0c0d950eff948faf31188fe0e3ef1))
|
||||
|
||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.8...medusa-plugin-brightpearl@1.1.9) (2021-03-25)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.7...medusa-plugin-brightpearl@1.1.8) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.5...medusa-plugin-brightpearl@1.1.7) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.5...medusa-plugin-brightpearl@1.1.6) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.4...medusa-plugin-brightpearl@1.1.5) (2021-02-25)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.3...medusa-plugin-brightpearl@1.1.4) (2021-02-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.2...medusa-plugin-brightpearl@1.1.3) (2021-02-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.1...medusa-plugin-brightpearl@1.1.2) (2021-02-03)
|
||||
|
||||
### Features
|
||||
|
||||
- **medusa,brightpearl,segment,webshipper:** claims ([#163](https://github.com/medusajs/medusa/issues/163)) ([690d339](https://github.com/medusajs/medusa/commit/690d33966754a7dbe159c3ac09712a3c3bfaff0b))
|
||||
|
||||
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.1.0...medusa-plugin-brightpearl@1.1.1) (2021-01-27)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.26...medusa-plugin-brightpearl@1.1.0) (2021-01-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.26](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.25...medusa-plugin-brightpearl@1.0.26) (2020-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.25](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.24...medusa-plugin-brightpearl@1.0.25) (2020-12-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- allow swaps with total < 0 ([#143](https://github.com/medusajs/medusa/issues/143)) ([304431e](https://github.com/medusajs/medusa/commit/304431e7c35e73b5dcd3ad4f28574b7cda091355))
|
||||
|
||||
## [1.0.24](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.23...medusa-plugin-brightpearl@1.0.24) (2020-11-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- swaps with discounts ([#142](https://github.com/medusajs/medusa/issues/142)) ([aae8d5e](https://github.com/medusajs/medusa/commit/aae8d5e1128daa433b333483094cceeba4389c17))
|
||||
|
||||
## [1.0.23](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.22...medusa-plugin-brightpearl@1.0.23) (2020-11-24)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.22](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.21...medusa-plugin-brightpearl@1.0.22) (2020-11-10)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.21](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.20...medusa-plugin-brightpearl@1.0.21) (2020-10-28)
|
||||
|
||||
### Features
|
||||
|
||||
- **medusa:** adds support for gift cards ([#132](https://github.com/medusajs/medusa/issues/132)) ([f2c62cd](https://github.com/medusajs/medusa/commit/f2c62cd2321c9013c15160a80598f912daef4647))
|
||||
|
||||
## [1.0.20](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.19...medusa-plugin-brightpearl@1.0.20) (2020-10-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.19](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.18...medusa-plugin-brightpearl@1.0.19) (2020-10-08)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** faulty fulfillments ([6979cce](https://github.com/medusajs/medusa/commit/6979cce59a02fda591d44ba2eb19959ea248181d))
|
||||
|
||||
## [1.0.18](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.17...medusa-plugin-brightpearl@1.0.18) (2020-10-06)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.17](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.16...medusa-plugin-brightpearl@1.0.17) (2020-10-05)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** reliable oauth ([#119](https://github.com/medusajs/medusa/issues/119)) ([0889059](https://github.com/medusajs/medusa/commit/0889059ba178e976c5f6c4a0e938a463dde29554))
|
||||
|
||||
## [1.0.16](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.15...medusa-plugin-brightpearl@1.0.16) (2020-10-05)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** automatic token refresh ([34eb53f](https://github.com/medusajs/medusa/commit/34eb53f72e8bb6f1f18a39ac6838991bbed86660))
|
||||
|
||||
## [1.0.15](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.14...medusa-plugin-brightpearl@1.0.15) (2020-09-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.14](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.13...medusa-plugin-brightpearl@1.0.14) (2020-09-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- cron jobs and brightpearl auto refresh ([#107](https://github.com/medusajs/medusa/issues/107)) ([c7bd783](https://github.com/medusajs/medusa/commit/c7bd7838aa620d6f23d9f5e17592cc5a82818c9e))
|
||||
|
||||
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.12...medusa-plugin-brightpearl@1.0.13) (2020-09-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-brightpearl@1.0.11...medusa-plugin-brightpearl@1.0.12) (2020-09-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-brightpearl
|
||||
|
||||
## 1.0.11 (2020-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- use correct auth type ([27052ca](https://github.com/medusajs/medusa/commit/27052cae27b447eff465f9c92ba5d017f00591ee))
|
||||
|
||||
## 1.0.10 (2020-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
|
||||
|
||||
## 1.0.7 (2020-09-07)
|
||||
|
||||
## 1.0.1 (2020-09-05)
|
||||
|
||||
## 1.0.1-beta.0 (2020-09-04)
|
||||
|
||||
# 1.0.0 (2020-09-03)
|
||||
|
||||
# 1.0.0-y.23 (2020-09-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- send response ([1f6ec9d](https://github.com/medusajs/medusa/commit/1f6ec9d2f02aa44072931c26bd2aad2200afc824))
|
||||
|
||||
# 1.0.0-y.22 (2020-09-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- rounds values when sending to brightpearl ([60bbd12](https://github.com/medusajs/medusa/commit/60bbd120eac873ea56533cc9313b04a0084c2b12))
|
||||
|
||||
# 1.0.0-y.21 (2020-09-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- adds endpoint for manual brightpearl uploads ([2609cdc](https://github.com/medusajs/medusa/commit/2609cdcd0d07e58af78c349e01c9bb6aef685541))
|
||||
|
||||
# 1.0.0-y.19 (2020-09-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** set redirect uri ([4006cad](https://github.com/medusajs/medusa/commit/4006cad45a4498541f5d2684c1a816cbf15e3d7e))
|
||||
|
||||
# 1.0.0-alpha.33 (2020-08-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- normal string matching available ([bd3c755](https://github.com/medusajs/medusa/commit/bd3c755260f9856ca76f584fa218f2d68bf8fb7d))
|
||||
|
||||
# 1.0.0-alpha.32 (2020-08-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** id matcihgin ([df4698a](https://github.com/medusajs/medusa/commit/df4698ad811e6d5a8e366e884f426473d85c7314))
|
||||
|
||||
# 1.0.0-alpha.31 (2020-08-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- better rounding of totals ([3093cba](https://github.com/medusajs/medusa/commit/3093cba610992225ab51bee05ec1e5c84c7e0fed))
|
||||
|
||||
# 1.0.0-alpha.30 (2020-08-28)
|
||||
|
||||
# 1.0.0-alpha.29 (2020-08-28)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** more gentle inventory syncs ([e254780](https://github.com/medusajs/medusa/commit/e25478034b82520f8de797edaba8adbf1c7d03b3))
|
||||
|
||||
# 1.0.0-alpha.28 (2020-08-27)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** allow status updates ([9025020](https://github.com/medusajs/medusa/commit/902502092f596cd72b946e8ae8b7aea57d0bdfe4))
|
||||
|
||||
# 1.0.0-alpha.27 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.25 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.24 (2020-08-27)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** only update inventory levels that are out of sync ([db205bf](https://github.com/medusajs/medusa/commit/db205bf79024bc54f6bc73a90ea7427f65c642be))
|
||||
|
||||
# 1.0.0-alpha.23 (2020-08-26)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-brightpearl:** ignore goods out created if channel id not medusa ([a6a3520](https://github.com/medusajs/medusa/commit/a6a35204fe364c81fa76655a0342b7c2f338045f))
|
||||
|
||||
# 1.0.0-alpha.22 (2020-08-25)
|
||||
|
||||
# 1.0.0-alpha.21 (2020-08-25)
|
||||
|
||||
# 1.0.0-alpha.20 (2020-08-23)
|
||||
|
||||
# 1.0.0-alpha.19 (2020-08-23)
|
||||
|
||||
# 1.0.0-alpha.18 (2020-08-23)
|
||||
|
||||
# 1.0.0-alpha.17 (2020-08-23)
|
||||
|
||||
# 1.0.0-alpha.16 (2020-08-23)
|
||||
|
||||
# 1.0.0-alpha.3 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.2 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.1 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.0 (2020-08-20)
|
||||
|
||||
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
|
||||
@@ -1,108 +0,0 @@
|
||||
# Brightpearl
|
||||
|
||||
Manage and streamline your business processes using Brightpearl.
|
||||
|
||||
[Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
|
||||
|
||||
## Features
|
||||
|
||||
- Send and sync orders with Brightpearl.
|
||||
- Listen for inventory and stock movements in Brightpearl.
|
||||
- Handle order returns through Brightpearl.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
|
||||
- [Brightpearl account](https://www.brightpearl.com)
|
||||
|
||||
---
|
||||
|
||||
## How to Install
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend:
|
||||
|
||||
```bash
|
||||
npm install medusa-plugin-brightpearl
|
||||
```
|
||||
|
||||
2\. Set the following environment variables in `.env`:
|
||||
|
||||
```bash
|
||||
BRIGHTPEARL_ACCOUNT=<YOUR_ACCOUNT>
|
||||
BRIGHTPEARL_CHANNEL_ID=<YOUR_CHANNEL_ID>
|
||||
BRIGHTPEARL_BACKEND_URL=<YOUR_BACKEND_URL>
|
||||
BRIGHTPEARL_EVENT_OWNER=<YOUR_EVENT_OWNER>
|
||||
BRIGHTPEARL_WAREHOUSE=<YOUR_WAREHOUSE>
|
||||
BRIGHTPEARL_DEFAULT_STATUS_ID=<YOUR_DEFAULT_STATUS_ID>
|
||||
BRIGHTPEARL_SWAP_STATUS_ID=<YOUR_SWAP_STATUS_ID>
|
||||
BRIGHTPEARL_CLAIM_STATUS_ID=<YOUR_CLAIM_STATUS_ID>
|
||||
BRIGHTPEARL_PAYMENT_METHOD_CODE=<YOUR_PAYMENT_METHOD_CODE>
|
||||
BRIGHTPEARL_SALES_ACCOUNT_CODE=<YOUR_SALES_ACCOUNT_CODE>
|
||||
BRIGHTPEARL_SHIPPING_ACCOUNT_CODE=<YOUR_SHIPPING_ACCOUNT_CODE>
|
||||
BRIGHTPEARL_DISCOUNT_ACCOUNT_CODE=<YOUR_DISCOUNT_ACCOUNT_CODE>
|
||||
BRIGHTPEARL_GIFT_CARD_ACCOUNT_CODE=<YOUR_GIFT_CARD_ACCOUNT_CODE>
|
||||
BRIGHTPEARL_INVENTORY_SYNC_CRON=<YOUR_INVENTORY_SYNC_CRON>
|
||||
BRIGHTPEARL_COST_PRICE_LIST=<YOUR_COST_PRICE_LIST>
|
||||
BRIGHTPEARL_BASE_CURRENCY=<YOUR_BASE_CURRENCY>
|
||||
```
|
||||
|
||||
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
||||
|
||||
```js
|
||||
const plugins = [
|
||||
// ...
|
||||
{
|
||||
resolve: `medusa-plugin-brightpearl`,
|
||||
options: {
|
||||
account: process.env.BRIGHTPEARL_ACCOUNT, // required, the Brightpearl account
|
||||
channel_id: process.env.BRIGHTPEARL_CHANNEL_ID, // required, channel id to map sales and credits to
|
||||
backend_url: process.env.BRIGHTPEARL_BACKEND_URL, // required, the url where the Medusa server is running, needed for webhooks
|
||||
event_owner: process.env.BRIGHTPEARL_EVENT_OWNER, // required, the id of the user who will own goods out events]
|
||||
warehouse: process.env.BRIGHTPEARL_WAREHOUSE, // required, the warehouse id to allocate orders from
|
||||
default_status_id: process.env.BRIGHTPEARL_DEFAULT_STATUS_ID, // (default: `3`), the status id to assign new orders with
|
||||
swap_status_id: process.env.BRIGHTPEARL_SWAP_STATUS_ID, // (default: `3`), the status id to assign new swaps
|
||||
claim_status_id: process.env.BRIGHTPEARL_CLAIM_STATUS_ID, // (default: `3`), the status id to assign new claims
|
||||
payment_method_code: process.env.BRIGHTPEARL_PAYMENT_METHOD_CODE, // (default: `1220`), the method code to register payments with
|
||||
sales_account_code: process.env.BRIGHTPEARL_SALES_ACCOUNT_CODE, // (defaults: `4000`), nominal code to assign line items to
|
||||
shipping_account_code: process.env.BRIGHTPEARL_SHIPPING_ACCOUNT_CODE, // (default: `4040`), nominal code to assign shipping line to
|
||||
discount_account_code: process.env.BRIGHTPEARL_DISCOUNT_ACCOUNT_CODE, // optional, nominal code to use for Discount-type refunds
|
||||
gift_card_account_code: process.env.BRIGHTPEARL_GIFT_CARD_ACCOUNT_CODE, // (default: `4000`), nominal code to use for gift card products and redeems
|
||||
inventory_sync_cron: process.env.BRIGHTPEARL_INVENTORY_SYNC_CRON, // optional, cron pattern for inventory sync, if left out the job will not be created
|
||||
cost_price_list: process.env.BRIGHTPEARL_COST_PRICE_LIST, // (default: `1`) the ID of the price list to assign to created claims
|
||||
base_currency: process.env.BRIGHTPEARL_BASE_CURRENCY, // (default: `EUR`) the ISO 3 character code of the currency to assign to created claims.
|
||||
},
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test the Plugin
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend to run the backend:
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
2\. On placing an order, you should see that order appear on Brightpearl.
|
||||
|
||||
---
|
||||
|
||||
## Additional Information
|
||||
|
||||
### Orders
|
||||
|
||||
When an order is created in Medusa it will automatically be sent to Brightpearl and allocated there. Once allocated it is up to Brightpearl to figure out how the order is to be fulfilled - the plugin listens for goods out notes and tries to map each of these to a Medusa order, if the matching succeeds Medusa will send the order to the fulfillment provider associated with the shipping method selected by the Customer.
|
||||
|
||||
When line items on an order are returned the plugin will generate a sales credit in Brightpearl.
|
||||
|
||||
### Products
|
||||
|
||||
The plugin doesn't automatically create products in Medusa, but listens for inventory changes in Brightpearl. The plugin updates each product variant to reflect the inventory quantity listed in Brightpearl, thereby ensuring that the inventory levels in Medusa are always in sync with Brightpearl.
|
||||
|
||||
### OAuth
|
||||
|
||||
The plugin registers an OAuth app in Medusa allowing installation at https://medusa-commerce.com/a/settings/apps. The OAuth tokens are refreshed every hour to prevent unauthorized requests.
|
||||
@@ -1 +0,0 @@
|
||||
// noop
|
||||
@@ -1,59 +0,0 @@
|
||||
{
|
||||
"name": "medusa-plugin-brightpearl",
|
||||
"version": "1.3.13",
|
||||
"description": "Brightpearl plugin for Medusa Commerce",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/medusa-plugin-brightpearl"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"author": "Sebastian Rindom",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.5",
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/node": "^7.7.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
||||
"@babel/preset-env": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"@babel/runtime": "^7.9.6",
|
||||
"@medusajs/medusa": "^1.17.4",
|
||||
"axios-mock-adapter": "^1.18.2",
|
||||
"axios-mock-server": "^0.19.1",
|
||||
"client-sessions": "^0.8.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-interfaces": "^1.3.7",
|
||||
"medusa-test-utils": "^1.1.40"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "cross-env NODE_ENV=production yarn run build",
|
||||
"test": "jest --silent --bail --maxWorkers=50% --forceExit",
|
||||
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
|
||||
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@medusajs/medusa": "^1.12.0",
|
||||
"medusa-interfaces": "^1.3.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/utils": "^1.10.5",
|
||||
"axios": "^0.19.2",
|
||||
"axios-rate-limit": "^1.2.1",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.2.0",
|
||||
"randomatic": "^3.1.1"
|
||||
},
|
||||
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e",
|
||||
"keywords": [
|
||||
"medusa-plugin",
|
||||
"medusa-plugin-erp"
|
||||
]
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
import { Router } from "express"
|
||||
import bodyParser from "body-parser"
|
||||
|
||||
const BP_SECRET_TOKEN = process.env.BP_SECRET_TOKEN || ""
|
||||
|
||||
export default (container) => {
|
||||
const app = Router()
|
||||
|
||||
app.post("/brightpearl/product", bodyParser.json(), async (req, res) => {
|
||||
const { id, lifecycle_event } = req.body
|
||||
|
||||
if (lifecycle_event === "created") {
|
||||
const eventBus = req.scope.resolve("eventBusService")
|
||||
const brightpearlService = req.scope.resolve("brightpearlService")
|
||||
const bpProduct = await brightpearlService.retrieveProduct(id)
|
||||
|
||||
eventBus.emit("brightpearl-product.created", bpProduct)
|
||||
}
|
||||
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
app.post("/brightpearl/goods-out", bodyParser.json(), async (req, res) => {
|
||||
const { id, lifecycle_event } = req.body
|
||||
const eventBusService = req.scope.resolve("eventBusService")
|
||||
|
||||
if (lifecycle_event === "created") {
|
||||
eventBusService.emit("brightpearl.goods_out_note", { id })
|
||||
}
|
||||
|
||||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
app.post(
|
||||
"/brightpearl/inventory-update",
|
||||
bodyParser.json(),
|
||||
async (req, res) => {
|
||||
const { id } = req.body
|
||||
const brightpearlService = req.scope.resolve("brightpearlService")
|
||||
await brightpearlService.updateInventory(id)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
)
|
||||
|
||||
app.post("/brightpearl/orders/:id", async (req, res) => {
|
||||
const { access_token } = req.query
|
||||
const { id } = req.params
|
||||
|
||||
if (
|
||||
!access_token ||
|
||||
!id ||
|
||||
!BP_SECRET_TOKEN ||
|
||||
access_token !== BP_SECRET_TOKEN
|
||||
) {
|
||||
res.sendStatus(401)
|
||||
return
|
||||
}
|
||||
|
||||
const brightpearlService = req.scope.resolve("brightpearlService")
|
||||
const orderService = req.scope.resolve("orderService")
|
||||
|
||||
try {
|
||||
const order = await orderService.retrieve(id)
|
||||
if (order.metadata && order.metadata.brightpearl_sales_order_id) {
|
||||
throw new Error("Already sent to BP")
|
||||
}
|
||||
|
||||
await brightpearlService.createSalesOrder(order.id)
|
||||
res.sendStatus(200)
|
||||
} catch (err) {
|
||||
res.status(400).json(err)
|
||||
}
|
||||
})
|
||||
|
||||
return app
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
const inventorySync = async (container, options) => {
|
||||
if (!options.inventory_sync_cron) {
|
||||
return
|
||||
} else {
|
||||
const brightpearlService = container.resolve("brightpearlService")
|
||||
const jobSchedulerService = container.resolve("jobSchedulerService")
|
||||
try {
|
||||
const pattern = options.inventory_sync_cron
|
||||
jobSchedulerService.create("inventory-sync", {}, pattern, () =>
|
||||
brightpearlService.syncInventory()
|
||||
)
|
||||
} catch (err) {
|
||||
if (err.name === "not_allowed") {
|
||||
return
|
||||
}
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default inventorySync
|
||||
@@ -1,14 +0,0 @@
|
||||
const webhookLoader = async (container) => {
|
||||
const brightpearlService = container.resolve("brightpearlService")
|
||||
try {
|
||||
const client = await brightpearlService.getClient()
|
||||
await brightpearlService.verifyWebhooks()
|
||||
} catch (err) {
|
||||
if (err.name === "not_allowed") {
|
||||
return
|
||||
}
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
export default webhookLoader
|
||||
@@ -1,418 +0,0 @@
|
||||
jest.unmock("axios")
|
||||
|
||||
import BrightpearlService from "../brightpearl"
|
||||
import { mockCreateOrder, mockCreateCredit } from "../../utils/brightpearl"
|
||||
import MockAdapter from "axios-mock-adapter"
|
||||
|
||||
jest.mock("../../utils/brightpearl")
|
||||
|
||||
const order = {
|
||||
region: {
|
||||
tax_code: "1234",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
title: "Test",
|
||||
variant: {
|
||||
sku: "TEST",
|
||||
},
|
||||
unit_price: 1100,
|
||||
quantity: 2,
|
||||
},
|
||||
],
|
||||
shipping_total: 12399,
|
||||
shipping_methods: [
|
||||
{
|
||||
name: "standard",
|
||||
price: 12399,
|
||||
subtotal: 12399,
|
||||
},
|
||||
],
|
||||
payment_method: {
|
||||
id: "123",
|
||||
},
|
||||
tax_rate: 23.1,
|
||||
currency_code: "DKK",
|
||||
display_id: "1234",
|
||||
id: "12355",
|
||||
discounts: [],
|
||||
shipping_address: {
|
||||
first_name: "Test",
|
||||
last_name: "Testson",
|
||||
address_1: "Test",
|
||||
address_2: "TEst",
|
||||
postal_code: "1234",
|
||||
country_code: "DK",
|
||||
phone: "12345678",
|
||||
},
|
||||
email: "test@example.com",
|
||||
}
|
||||
|
||||
const krwOrder = {
|
||||
region: {
|
||||
tax_code: "1234",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
title: "Test",
|
||||
variant: {
|
||||
sku: "TEST",
|
||||
},
|
||||
unit_price: 1100,
|
||||
quantity: 2,
|
||||
},
|
||||
],
|
||||
shipping_total: 12399,
|
||||
shipping_methods: [
|
||||
{
|
||||
name: "standard",
|
||||
price: 12399,
|
||||
subtotal: 12399,
|
||||
},
|
||||
],
|
||||
payment_method: {
|
||||
id: "123",
|
||||
},
|
||||
tax_rate: 0,
|
||||
currency_code: "KRW",
|
||||
display_id: "1234",
|
||||
id: "12355",
|
||||
discounts: [],
|
||||
shipping_address: {
|
||||
first_name: "Test",
|
||||
last_name: "Testson",
|
||||
address_1: "Test",
|
||||
address_2: "TEst",
|
||||
postal_code: "1234",
|
||||
country_code: "DK",
|
||||
phone: "12345678",
|
||||
},
|
||||
email: "test@example.com",
|
||||
}
|
||||
|
||||
const roundingOrder = {
|
||||
region: {
|
||||
tax_code: "1234",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
id: "rounding-item",
|
||||
title: "Test",
|
||||
allow_discounts: true,
|
||||
variant: {
|
||||
sku: "TEST",
|
||||
},
|
||||
unit_price: 31600,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
shipping_total: 0,
|
||||
shipping_methods: [
|
||||
{
|
||||
name: "standard",
|
||||
price: 0,
|
||||
subtotal: 0,
|
||||
},
|
||||
],
|
||||
discounts: [
|
||||
{
|
||||
code: "testdiscount",
|
||||
rule: {
|
||||
type: "percentage",
|
||||
allocation: "total",
|
||||
value: 50,
|
||||
},
|
||||
},
|
||||
],
|
||||
payment_method: {
|
||||
id: "123",
|
||||
},
|
||||
tax_rate: 25,
|
||||
currency_code: "DKK",
|
||||
display_id: "1234",
|
||||
id: "rounding",
|
||||
shipping_address: {
|
||||
first_name: "Test",
|
||||
last_name: "Testson",
|
||||
address_1: "Test",
|
||||
address_2: "TEst",
|
||||
postal_code: "1234",
|
||||
country_code: "DK",
|
||||
phone: "12345678",
|
||||
},
|
||||
email: "test@example.com",
|
||||
}
|
||||
|
||||
const OrderService = {
|
||||
retrieve: (id) => {
|
||||
if (id === "rounding") {
|
||||
return Promise.resolve(roundingOrder)
|
||||
}
|
||||
return Promise.resolve(order)
|
||||
},
|
||||
update: () => {
|
||||
return Promise.resolve()
|
||||
},
|
||||
}
|
||||
|
||||
const TotalsService = {
|
||||
getTotal: () => {
|
||||
return Promise.resolve(123)
|
||||
},
|
||||
getShippingMethodTotals: () => {
|
||||
return {
|
||||
price: 0,
|
||||
subtotal: 0,
|
||||
discount_total: 0,
|
||||
tax_total: 0,
|
||||
}
|
||||
},
|
||||
getLineItemTotals: () => {
|
||||
return {
|
||||
subtotal: 15800,
|
||||
discount_total: 0,
|
||||
tax_total: 3950,
|
||||
}
|
||||
},
|
||||
getLineDiscounts: (o) => {
|
||||
if (o.id === "rounding") {
|
||||
return [
|
||||
{
|
||||
item: { id: "rounding-item", quantity: 1 },
|
||||
amount: 15800,
|
||||
},
|
||||
]
|
||||
}
|
||||
return []
|
||||
},
|
||||
getShippingTotal: (o) => {
|
||||
if (o.id === "rounding") {
|
||||
return 0
|
||||
}
|
||||
return 12399
|
||||
},
|
||||
rounded: (value) => {
|
||||
return Math.round(value)
|
||||
// const decimalPlaces = 4
|
||||
// return Number(
|
||||
// Math.round(parseFloat(value + "e" + decimalPlaces)) + "e-" + decimalPlaces
|
||||
// )
|
||||
},
|
||||
}
|
||||
|
||||
const OAuthService = {
|
||||
retrieveByName: () => {
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
access_token: "12345",
|
||||
},
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const RegionService = {
|
||||
retrieve: () => {
|
||||
return Promise.resolve({
|
||||
tax_code: "1234",
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
describe("BrightpearlService", () => {
|
||||
describe("getClient", () => {
|
||||
it("creates client", async () => {
|
||||
let token = "bad"
|
||||
const oauth = {
|
||||
refreshToken: () => {
|
||||
token = "good"
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
access_token: "good",
|
||||
},
|
||||
})
|
||||
},
|
||||
retrieveByName: () => {
|
||||
return Promise.resolve({
|
||||
data: {
|
||||
access_token: token,
|
||||
},
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const bpService = new BrightpearlService({ oauthService: oauth }, {})
|
||||
const client = await bpService.getClient()
|
||||
|
||||
const mockServer = new MockAdapter(client.client)
|
||||
|
||||
mockServer.onGet("/success").reply(() => {
|
||||
return [200]
|
||||
})
|
||||
mockServer.onGet("/fail").reply((req) => {
|
||||
if (req.headers.Authorization === "Bearer good") {
|
||||
return [200]
|
||||
}
|
||||
return [401]
|
||||
})
|
||||
|
||||
await client.test.fail()
|
||||
await client.test.fail()
|
||||
})
|
||||
})
|
||||
|
||||
describe("rounding", () => {
|
||||
const bpService = new BrightpearlService(
|
||||
{
|
||||
orderService: OrderService,
|
||||
totalsService: TotalsService,
|
||||
oauthService: OAuthService,
|
||||
regionService: RegionService,
|
||||
},
|
||||
{ account: "test" }
|
||||
)
|
||||
|
||||
it("rounds correctly", async () => {
|
||||
jest.clearAllMocks()
|
||||
await bpService.createSalesOrder("rounding")
|
||||
|
||||
expect(mockCreateOrder).toHaveBeenCalledTimes(1)
|
||||
expect(mockCreateOrder).toHaveBeenCalledWith({
|
||||
currency: { code: "DKK" },
|
||||
ref: "1234",
|
||||
externalRef: "rounding",
|
||||
channelId: "1",
|
||||
installedIntegrationInstanceId: undefined,
|
||||
statusId: "3",
|
||||
customer: {
|
||||
id: "12345",
|
||||
address: {
|
||||
addressFullName: "Test Testson",
|
||||
addressLine1: "Test",
|
||||
addressLine2: "TEst",
|
||||
postalCode: "1234",
|
||||
countryIsoCode: "DK",
|
||||
telephone: "12345678",
|
||||
email: "test@example.com",
|
||||
},
|
||||
},
|
||||
delivery: {
|
||||
shippingMethodId: 0,
|
||||
address: {
|
||||
addressFullName: "Test Testson",
|
||||
addressLine1: "Test",
|
||||
addressLine2: "TEst",
|
||||
postalCode: "1234",
|
||||
countryIsoCode: "DK",
|
||||
telephone: "12345678",
|
||||
email: "test@example.com",
|
||||
},
|
||||
},
|
||||
rows: [
|
||||
{
|
||||
name: "Test",
|
||||
net: 158,
|
||||
tax: 39.5,
|
||||
quantity: 1,
|
||||
taxCode: "1234",
|
||||
externalRef: "rounding-item",
|
||||
nominalCode: "4000",
|
||||
},
|
||||
{
|
||||
name: "Shipping: standard",
|
||||
quantity: 1,
|
||||
net: 0,
|
||||
tax: 0,
|
||||
taxCode: "1234",
|
||||
nominalCode: "4040",
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it("rounds correctly", async () => {
|
||||
jest.clearAllMocks()
|
||||
await bpService.createSalesOrder("rounding")
|
||||
|
||||
expect(mockCreateOrder).toHaveBeenCalledTimes(1)
|
||||
expect(mockCreateOrder).toHaveBeenCalledWith({
|
||||
currency: { code: "DKK" },
|
||||
ref: "1234",
|
||||
externalRef: "rounding",
|
||||
channelId: "1",
|
||||
installedIntegrationInstanceId: undefined,
|
||||
statusId: "3",
|
||||
customer: {
|
||||
id: "12345",
|
||||
address: {
|
||||
addressFullName: "Test Testson",
|
||||
addressLine1: "Test",
|
||||
addressLine2: "TEst",
|
||||
postalCode: "1234",
|
||||
countryIsoCode: "DK",
|
||||
telephone: "12345678",
|
||||
email: "test@example.com",
|
||||
},
|
||||
},
|
||||
delivery: {
|
||||
shippingMethodId: 0,
|
||||
address: {
|
||||
addressFullName: "Test Testson",
|
||||
addressLine1: "Test",
|
||||
addressLine2: "TEst",
|
||||
postalCode: "1234",
|
||||
countryIsoCode: "DK",
|
||||
telephone: "12345678",
|
||||
email: "test@example.com",
|
||||
},
|
||||
},
|
||||
rows: [
|
||||
{
|
||||
name: "Test",
|
||||
net: 158,
|
||||
tax: 39.5,
|
||||
quantity: 1,
|
||||
taxCode: "1234",
|
||||
externalRef: "rounding-item",
|
||||
nominalCode: "4000",
|
||||
},
|
||||
{
|
||||
name: "Shipping: standard",
|
||||
quantity: 1,
|
||||
net: 0,
|
||||
tax: 0,
|
||||
taxCode: "1234",
|
||||
nominalCode: "4040",
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("bpnum_", () => {
|
||||
const bpService = new BrightpearlService(
|
||||
{
|
||||
orderService: OrderService,
|
||||
totalsService: TotalsService,
|
||||
oauthService: OAuthService,
|
||||
regionService: RegionService,
|
||||
},
|
||||
{ account: "test" }
|
||||
)
|
||||
|
||||
it("sales credit diff. calc - KRW", async () => {
|
||||
jest.clearAllMocks()
|
||||
const total = 100000
|
||||
const refund_amount = 100000
|
||||
const difference = bpService.bpnum_(refund_amount, "krw") - total
|
||||
expect(difference).toEqual(0)
|
||||
})
|
||||
|
||||
it("sales credit diff. calc - DKK", async () => {
|
||||
jest.clearAllMocks()
|
||||
const total = 100000
|
||||
const refund_amount = 100000
|
||||
const difference = bpService.bpnum_(refund_amount, "dkk") - total
|
||||
expect(difference).toEqual(-99000)
|
||||
})
|
||||
})
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,51 +0,0 @@
|
||||
import randomize from "randomatic"
|
||||
import { OauthService } from "medusa-interfaces"
|
||||
import Brightpearl from "../utils/brightpearl"
|
||||
|
||||
const CLIENT_SECRET = process.env.BP_CLIENT_SECRET || ""
|
||||
|
||||
class BrightpearlOauth extends OauthService {
|
||||
constructor({}, options) {
|
||||
super()
|
||||
|
||||
this.account_ = options.account
|
||||
}
|
||||
|
||||
static getAppDetails(options) {
|
||||
const client_id = "medusa-dev"
|
||||
const client_secret = CLIENT_SECRET
|
||||
const state = randomize("A0", 16)
|
||||
const redirect = "https://tekla.medusa-commerce.com/a/oauth/brightpearl"
|
||||
return {
|
||||
application_name: "brightpearl",
|
||||
display_name: "Brightpearl",
|
||||
install_url: `https://oauth.brightpearl.com/authorize/${options.account}?response_type=code&client_id=${client_id}&redirect_uri=${redirect}&state=${state}`,
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
async refreshToken(refreshToken) {
|
||||
const params = {
|
||||
refresh_token: refreshToken,
|
||||
client_id: "medusa-dev",
|
||||
client_secret: CLIENT_SECRET,
|
||||
}
|
||||
|
||||
const data = await Brightpearl.refreshToken(this.account_, params)
|
||||
return data
|
||||
}
|
||||
|
||||
async generateToken(code) {
|
||||
const params = {
|
||||
client_id: "medusa-dev",
|
||||
client_secret: CLIENT_SECRET,
|
||||
redirect: "https://tekla.medusa-commerce.com/a/oauth/brightpearl",
|
||||
code,
|
||||
}
|
||||
|
||||
const data = await Brightpearl.createToken(this.account_, params)
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
export default BrightpearlOauth
|
||||
@@ -1,232 +0,0 @@
|
||||
class OrderSubscriber {
|
||||
constructor({
|
||||
eventBusService,
|
||||
orderService,
|
||||
swapService,
|
||||
returnService,
|
||||
paymentProviderService,
|
||||
brightpearlService,
|
||||
claimService,
|
||||
fulfillmentService,
|
||||
featureFlagRouter,
|
||||
}) {
|
||||
this.orderService_ = orderService
|
||||
this.brightpearlService_ = brightpearlService
|
||||
this.swapService_ = swapService
|
||||
this.returnService_ = returnService
|
||||
this.paymentProviderService_ = paymentProviderService
|
||||
this.fulfillmentService_ = fulfillmentService
|
||||
this.claimService_ = claimService
|
||||
this.featureFlagRouter = featureFlagRouter
|
||||
|
||||
eventBusService.subscribe("order.placed", this.sendToBrightpearl)
|
||||
|
||||
eventBusService.subscribe(
|
||||
"brightpearl.goods_out_note",
|
||||
this.createFulfillmentFromGoodsOut
|
||||
)
|
||||
|
||||
eventBusService.subscribe("claim.created", this.registerClaim)
|
||||
|
||||
eventBusService.subscribe("order.refund_created", this.registerRefund)
|
||||
|
||||
eventBusService.subscribe("order.items_returned", this.registerReturn)
|
||||
|
||||
eventBusService.subscribe(
|
||||
"order.payment_captured",
|
||||
this.registerCapturedPayment
|
||||
)
|
||||
|
||||
eventBusService.subscribe("order.shipment_created", this.registerShipment)
|
||||
eventBusService.subscribe("swap.shipment_created", this.registerShipment)
|
||||
eventBusService.subscribe("claim.shipment_created", this.registerShipment)
|
||||
|
||||
// Before we initiate a swap we wait for the payment and the return
|
||||
eventBusService.subscribe(
|
||||
"swap.payment_completed",
|
||||
this.registerSwapPayment
|
||||
)
|
||||
eventBusService.subscribe("swap.received", this.registerSwap)
|
||||
|
||||
eventBusService.subscribe(
|
||||
"reservation-item.created",
|
||||
this.registerMedusaReservation
|
||||
)
|
||||
|
||||
eventBusService.subscribe(
|
||||
"reservation-items.bulk-created",
|
||||
this.registerMedusaBulkReservation
|
||||
)
|
||||
}
|
||||
|
||||
registerMedusaReservation = (data) => {
|
||||
return this.brightpearlService_.createReservation(data)
|
||||
}
|
||||
|
||||
registerMedusaBulkReservation = (data) => {
|
||||
return this.brightpearlService_.bulkCreateReservation(data)
|
||||
}
|
||||
|
||||
sendToBrightpearl = (data) => {
|
||||
return this.brightpearlService_.createSalesOrder(data.id)
|
||||
}
|
||||
|
||||
registerCapturedPayment = ({ id }) => {
|
||||
return this.brightpearlService_.createPayment(id)
|
||||
}
|
||||
|
||||
createFulfillmentFromGoodsOut = ({ id }) => {
|
||||
return this.brightpearlService_.createFulfillmentFromGoodsOut(id)
|
||||
}
|
||||
|
||||
registerSwapPayment = async (data) => {
|
||||
return this.registerSwap({ id: data.id, swap_id: data.id })
|
||||
}
|
||||
|
||||
registerSwap = async (data) => {
|
||||
const { id } = data
|
||||
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
|
||||
const fromSwap = await this.swapService_.retrieve(id, {
|
||||
relations: [
|
||||
"return_order",
|
||||
"return_order.items",
|
||||
"return_order.shipping_method",
|
||||
"return_order.shipping_method.tax_lines",
|
||||
"additional_items",
|
||||
"additional_items.variant",
|
||||
"additional_items.variant.product",
|
||||
"additional_items.tax_lines",
|
||||
"shipping_address",
|
||||
"shipping_methods",
|
||||
"shipping_methods.shipping_option",
|
||||
"shipping_methods.tax_lines",
|
||||
],
|
||||
})
|
||||
|
||||
const relations = [
|
||||
"payments",
|
||||
"region",
|
||||
"swaps",
|
||||
"discounts",
|
||||
"discounts.rule",
|
||||
]
|
||||
if (this.featureFlagRouter.isFeatureEnabled("sales_channels")) {
|
||||
relations.push("sales_channel")
|
||||
}
|
||||
|
||||
const fromOrder = await this.orderService_.retrieve(fromSwap.order_id, {
|
||||
relations,
|
||||
})
|
||||
|
||||
if (
|
||||
!(
|
||||
fromSwap.confirmed_at !== null &&
|
||||
fromSwap.return_order.status === "received"
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
await this.brightpearlService_.createSwapCredit(fromOrder, fromSwap)
|
||||
await this.brightpearlService_.createSwapOrder(fromOrder, fromSwap)
|
||||
}
|
||||
|
||||
registerClaim = async (data) => {
|
||||
const { id } = data
|
||||
const fromClaim = await this.claimService_.retrieve(id, {
|
||||
relations: [
|
||||
"claim_items",
|
||||
"return_order",
|
||||
"return_order.items",
|
||||
"return_order.shipping_method",
|
||||
"return_order.shipping_method.tax_lines",
|
||||
"additional_items",
|
||||
"additional_items.variant",
|
||||
"additional_items.variant.product",
|
||||
"additional_items.tax_lines",
|
||||
"shipping_address",
|
||||
"shipping_methods.shipping_option",
|
||||
"shipping_methods",
|
||||
],
|
||||
})
|
||||
|
||||
const relations = [
|
||||
"payments",
|
||||
"region",
|
||||
"claims",
|
||||
"discounts",
|
||||
"discounts.rule",
|
||||
]
|
||||
if (this.featureFlagRouter.isFeatureEnabled("sales_channels")) {
|
||||
relations.push("sales_channel")
|
||||
}
|
||||
|
||||
const fromOrder = await this.orderService_.retrieve(fromClaim.order_id, {
|
||||
relations,
|
||||
})
|
||||
|
||||
if (fromClaim.type === "replace") {
|
||||
await this.brightpearlService_.createClaim(fromOrder, fromClaim)
|
||||
} else if (fromClaim.type === "refund") {
|
||||
await this.brightpearlService_.createClaimCredit(fromOrder, fromClaim)
|
||||
}
|
||||
}
|
||||
|
||||
registerShipment = async (data) => {
|
||||
const { fulfillment_id } = data
|
||||
const shipment = await this.fulfillmentService_.retrieve(fulfillment_id)
|
||||
const noteId = shipment.metadata.goods_out_note
|
||||
if (noteId) {
|
||||
await this.brightpearlService_.registerGoodsOutTrackingNumber(
|
||||
noteId,
|
||||
shipment
|
||||
)
|
||||
await this.brightpearlService_.registerGoodsOutShipped(noteId, shipment)
|
||||
}
|
||||
}
|
||||
|
||||
registerReturn = async (data) => {
|
||||
const { id, return_id } = data
|
||||
|
||||
const relations = ["discounts", "discounts.rule", "region", "swaps", "payments"]
|
||||
if (this.featureFlagRouter.isFeatureEnabled("sales_channels")) {
|
||||
relations.push("sales_channel")
|
||||
}
|
||||
|
||||
const order = await this.orderService_.retrieve(id, {
|
||||
relations,
|
||||
})
|
||||
|
||||
const fromReturn = await this.returnService_.retrieve(return_id, {
|
||||
relations: ["items", "shipping_method", "shipping_method.tax_lines"],
|
||||
})
|
||||
|
||||
return this.brightpearlService_
|
||||
.createSalesCredit(order, fromReturn)
|
||||
.catch((err) => console.log(err))
|
||||
}
|
||||
|
||||
registerRefund = async (data) => {
|
||||
const { id, refund_id } = data
|
||||
|
||||
const relations = ["region", "payments"]
|
||||
|
||||
if (this.featureFlagRouter.isFeatureEnabled("sales_channels")) {
|
||||
relations.push("sales_channel")
|
||||
}
|
||||
|
||||
const order = await this.orderService_.retrieve(id, {
|
||||
relations,
|
||||
})
|
||||
const refund = await this.paymentProviderService_.retrieveRefund(refund_id)
|
||||
return this.brightpearlService_
|
||||
.createRefundCredit(order, refund)
|
||||
.catch((err) => console.log(err))
|
||||
}
|
||||
}
|
||||
|
||||
export default OrderSubscriber
|
||||
@@ -1,95 +0,0 @@
|
||||
import axios from "axios"
|
||||
export const mockCreateOrder = jest
|
||||
.fn()
|
||||
.mockReturnValue(Promise.resolve("1234"))
|
||||
|
||||
export const mockCreateCredit = jest
|
||||
.fn()
|
||||
.mockReturnValue(Promise.resolve("1234"))
|
||||
|
||||
const mock = jest.fn().mockImplementation(function (options) {
|
||||
this.tokenStore_ = options.token_store
|
||||
this.token_ = options.access_token
|
||||
this.client = axios.create({
|
||||
baseURL: `https://mock.com`,
|
||||
headers: {
|
||||
"brightpearl-app-ref": "medusa-dev",
|
||||
"brightpearl-dev-ref": "sebrindom",
|
||||
},
|
||||
})
|
||||
|
||||
this.updateAuth = (data) => {
|
||||
this.token_ = data.access_token
|
||||
}
|
||||
|
||||
this.client.interceptors.request.use(async (request) => {
|
||||
const token = await this.tokenStore_.getToken()
|
||||
|
||||
if (token) {
|
||||
request.headers["Authorization"] = `Bearer ${token}`
|
||||
}
|
||||
|
||||
return request
|
||||
})
|
||||
|
||||
this.client.interceptors.response.use(undefined, async (error) => {
|
||||
const response = error.response
|
||||
|
||||
if (response) {
|
||||
if (
|
||||
response.status === 401 &&
|
||||
error.config &&
|
||||
!error.config.__isRetryRequest
|
||||
) {
|
||||
try {
|
||||
await this.tokenStore_.refreshToken()
|
||||
} catch (authError) {
|
||||
// refreshing has failed, but report the original error, i.e. 401
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
// retry the original request
|
||||
error.config.__isRetryRequest = true
|
||||
return this.client(error.config)
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
||||
this.test = {
|
||||
success: () => this.client.get("/success"),
|
||||
fail: () => this.client.get("/fail"),
|
||||
}
|
||||
this.warehouses = {
|
||||
createReservation: jest.fn().mockReturnValue(Promise.resolve()),
|
||||
}
|
||||
this.payments = {
|
||||
create: jest.fn().mockReturnValue(Promise.resolve()),
|
||||
}
|
||||
this.orders = {
|
||||
create: mockCreateOrder,
|
||||
createCredit: mockCreateCredit,
|
||||
retrieve: jest.fn().mockReturnValue(Promise.resolve()),
|
||||
}
|
||||
this.products = {
|
||||
retrieveBySKU: jest.fn().mockReturnValue(
|
||||
Promise.resolve({
|
||||
productId: 1234,
|
||||
})
|
||||
),
|
||||
}
|
||||
this.customers = {
|
||||
retrieveByEmail: jest.fn().mockReturnValue(
|
||||
Promise.resolve([
|
||||
{
|
||||
primaryEmail: "test@example.com",
|
||||
contactId: "12345",
|
||||
},
|
||||
])
|
||||
),
|
||||
}
|
||||
return this
|
||||
})
|
||||
|
||||
export default mock
|
||||
@@ -1,354 +0,0 @@
|
||||
import axios from "axios"
|
||||
import rateLimit from "axios-rate-limit"
|
||||
import qs from "querystring"
|
||||
|
||||
// Brightpearl allows 200 requests per minute
|
||||
const RATE_LIMIT_REQUESTS = 200
|
||||
const RATE_LIMIT_INTERVAL = 60 * 1000
|
||||
|
||||
class BrightpearlClient {
|
||||
static createToken(account, data) {
|
||||
const params = {
|
||||
grant_type: "authorization_code",
|
||||
code: data.code,
|
||||
client_id: data.client_id,
|
||||
client_secret: data.client_secret,
|
||||
redirect_uri: data.redirect,
|
||||
}
|
||||
|
||||
return axios({
|
||||
url: `https://ws-eu1.brightpearl.com/${account}/oauth/token`,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: qs.stringify(params),
|
||||
}).then(({ data }) => data)
|
||||
}
|
||||
|
||||
static refreshToken(account, data) {
|
||||
const params = {
|
||||
grant_type: "refresh_token",
|
||||
refresh_token: data.refresh_token,
|
||||
client_id: data.client_id,
|
||||
client_secret: data.client_secret,
|
||||
}
|
||||
|
||||
return axios({
|
||||
url: `https://ws-eu1.brightpearl.com/${account}/oauth/token`,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: qs.stringify(params),
|
||||
})
|
||||
.then(({ data }) => data)
|
||||
.catch((err) => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
this.client_ = rateLimit(
|
||||
axios.create({
|
||||
baseURL: `https://${options.url}/public-api/${options.account}`,
|
||||
headers: {
|
||||
"brightpearl-app-ref": "medusa-dev",
|
||||
"brightpearl-dev-ref": "sebrindom",
|
||||
},
|
||||
}),
|
||||
{ maxRequests: RATE_LIMIT_REQUESTS, perMilliseconds: RATE_LIMIT_INTERVAL }
|
||||
)
|
||||
|
||||
this.tokenStore_ = options.token_store
|
||||
this.authType_ = options.auth_type
|
||||
this.webhooks = this.buildWebhookEndpoints()
|
||||
this.payments = this.buildPaymentEndpoints()
|
||||
this.warehouses = this.buildWarehouseEndpoints()
|
||||
this.orders = this.buildOrderEndpoints()
|
||||
this.addresses = this.buildAddressEndpoints()
|
||||
this.customers = this.buildCustomerEndpoints()
|
||||
this.products = this.buildProductEndpoints()
|
||||
|
||||
this.buildRefreshTokenInterceptor_()
|
||||
}
|
||||
|
||||
buildRefreshTokenInterceptor_() {
|
||||
this.client_.interceptors.request.use(async (request) => {
|
||||
const token = await this.tokenStore_.getToken()
|
||||
|
||||
if (token) {
|
||||
request.headers["Authorization"] = `Bearer ${token}`
|
||||
}
|
||||
|
||||
return request
|
||||
})
|
||||
|
||||
this.client_.interceptors.response.use(undefined, async (error) => {
|
||||
const response = error.response
|
||||
|
||||
if (response) {
|
||||
if (
|
||||
response.status === 401 &&
|
||||
error.config &&
|
||||
!error.config.__isRetryRequest
|
||||
) {
|
||||
try {
|
||||
await this.tokenStore_.refreshToken()
|
||||
} catch (authError) {
|
||||
// refreshing has failed, but report the original error, i.e. 401
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
// retry the original request
|
||||
error.config.__isRetryRequest = true
|
||||
return this.client_(error.config)
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error)
|
||||
})
|
||||
}
|
||||
|
||||
buildSearchResults_(response) {
|
||||
const { results, metaData } = response
|
||||
// Map the column names to the columns
|
||||
return results.map((resColumns) => {
|
||||
const object = {}
|
||||
for (let i = 0; i < resColumns.length; i++) {
|
||||
const fieldName = metaData.columns[i].name
|
||||
object[fieldName] = resColumns[i]
|
||||
}
|
||||
return object
|
||||
})
|
||||
}
|
||||
|
||||
buildWebhookEndpoints = () => {
|
||||
return {
|
||||
list: () => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/integration-service/webhook`,
|
||||
method: "GET",
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
create: (data) => {
|
||||
return this.client_.request({
|
||||
url: `/integration-service/webhook`,
|
||||
method: "POST",
|
||||
data,
|
||||
})
|
||||
},
|
||||
delete: (id) => {
|
||||
return this.client_.request({
|
||||
url: `/integration-service/webhook/${id}`,
|
||||
method: "DELETE",
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
buildPaymentEndpoints = () => {
|
||||
return {
|
||||
create: (payment) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/accounting-service/customer-payment`,
|
||||
method: "POST",
|
||||
data: payment,
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
buildWarehouseEndpoints = () => {
|
||||
return {
|
||||
retrieveReservation: (orderId) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/warehouse-service/order/${orderId}/reservation`,
|
||||
method: "GET",
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
retrieveGoodsOutNote: (id) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/warehouse-service/order/*/goods-note/goods-out/${id}`,
|
||||
method: "GET",
|
||||
})
|
||||
.then(({ data }) => data.response && data.response[id])
|
||||
},
|
||||
createGoodsOutNote: (orderId, data) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/warehouse-service/order/${orderId}/goods-note/goods-out`,
|
||||
method: "POST",
|
||||
data,
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
updateGoodsOutNote: (noteId, update) => {
|
||||
return this.client_.request({
|
||||
url: `/warehouse-service/goods-note/goods-out/${noteId}`,
|
||||
method: "PUT",
|
||||
data: update,
|
||||
})
|
||||
},
|
||||
registerGoodsOutEvent: (noteId, data) => {
|
||||
return this.client_.request({
|
||||
url: `/warehouse-service/goods-note/goods-out/${noteId}/event`,
|
||||
method: "POST",
|
||||
data,
|
||||
})
|
||||
},
|
||||
updateReservation: (orderId, data) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/warehouse-service/order/${orderId}/reservation`,
|
||||
method: "PUT",
|
||||
data,
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
createReservation: (order, warehouse) => {
|
||||
const id = order.id
|
||||
const data = order.rows.map((r) => ({
|
||||
productId: r.productId,
|
||||
salesOrderRowId: r.id,
|
||||
quantity: r.quantity,
|
||||
}))
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/warehouse-service/order/${id}/reservation/warehouse/${warehouse}`,
|
||||
method: "POST",
|
||||
data: {
|
||||
products: data,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
buildOrderEndpoints = () => {
|
||||
return {
|
||||
retrieve: (orderId) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/order-service/sales-order/${orderId}`,
|
||||
method: "GET",
|
||||
})
|
||||
.then(({ data }) => data.response.length && data.response[0])
|
||||
.catch((err) => console.log(err))
|
||||
},
|
||||
create: (order) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/order-service/sales-order`,
|
||||
method: "POST",
|
||||
data: order,
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
createCredit: (salesCredit) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/order-service/sales-credit`,
|
||||
method: "POST",
|
||||
data: salesCredit,
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
buildAddressEndpoints = () => {
|
||||
return {
|
||||
create: (address) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/contact-service/postal-address`,
|
||||
method: "POST",
|
||||
data: address,
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
buildProductEndpoints = () => {
|
||||
return {
|
||||
retrieveAvailability: (productId) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/warehouse-service/product-availability/${productId}`,
|
||||
})
|
||||
.then(({ data }) => data.response && data.response)
|
||||
},
|
||||
retrieve: (productId) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/product-service/product/${productId}`,
|
||||
})
|
||||
.then(({ data }) => data.response && data.response[0])
|
||||
},
|
||||
search: (search) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/product-service/product-search?${search}`,
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return {
|
||||
products: this.buildSearchResults_(data.response),
|
||||
metadata: data.response.metaData,
|
||||
}
|
||||
})
|
||||
},
|
||||
retrieveBySKU: (sku) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/product-service/product-search?SKU=${sku}`,
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return this.buildSearchResults_(data.response)
|
||||
})
|
||||
},
|
||||
retrievePrice: (productId) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/product-service/product-price/${productId}`,
|
||||
})
|
||||
.then(({ data }) => data.response.length && data.response[0])
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
buildCustomerEndpoints = () => {
|
||||
return {
|
||||
retrieveByEmail: (email) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/contact-service/contact-search?primaryEmail=${email}`,
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return this.buildSearchResults_(data.response)
|
||||
})
|
||||
},
|
||||
|
||||
create: (customerData) => {
|
||||
return this.client_
|
||||
.request({
|
||||
url: `/contact-service/contact`,
|
||||
method: "POST",
|
||||
data: customerData,
|
||||
})
|
||||
.then(({ data }) => data.response)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default BrightpearlClient
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-instanceof",
|
||||
"@babel/plugin-transform-classes"
|
||||
],
|
||||
"presets": ["@babel/preset-env"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
}
|
||||
}
|
||||
15
packages/medusa-plugin-economic/.gitignore
vendored
15
packages/medusa-plugin-economic/.gitignore
vendored
@@ -1,15 +0,0 @@
|
||||
/lib
|
||||
node_modules
|
||||
.DS_store
|
||||
.env*
|
||||
/*.js
|
||||
!index.js
|
||||
!jest.config.js
|
||||
|
||||
/dist
|
||||
|
||||
/api
|
||||
/services
|
||||
/models
|
||||
/subscribers
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
.DS_store
|
||||
src
|
||||
dist
|
||||
yarn.lock
|
||||
.babelrc
|
||||
jest.config.js
|
||||
|
||||
.turbo
|
||||
.yarn
|
||||
@@ -1,281 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 1.1.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
|
||||
|
||||
## 1.1.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3763](https://github.com/medusajs/medusa/pull/3763) [`4104d9ccb`](https://github.com/medusajs/medusa/commit/4104d9ccb25276c85b5363f85e14b3093e64df85) Thanks [@StephixOne](https://github.com/StephixOne)! - fix(plugin-discount-generator,plugin-economic,plugin-mailchimp,plugin-restock-notification,plugin-sendgrid,plugin-wishlist): Temporarily remove payload validation in some plugins
|
||||
|
||||
## 1.1.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0
|
||||
- medusa-interfaces@1.3.7
|
||||
- medusa-test-utils@1.1.40
|
||||
|
||||
## 1.1.43-rc.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0-rc.0
|
||||
- medusa-interfaces@1.3.7-rc.0
|
||||
- medusa-test-utils@1.1.40-rc.0
|
||||
|
||||
## 1.1.42
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
|
||||
|
||||
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
|
||||
- medusa-core-utils@1.1.39
|
||||
- medusa-interfaces@1.3.6
|
||||
|
||||
## 1.1.41
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
|
||||
|
||||
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
|
||||
- medusa-core-utils@1.1.38
|
||||
- medusa-interfaces@1.3.5
|
||||
|
||||
## 1.1.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
|
||||
|
||||
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
|
||||
- medusa-interfaces@1.3.4
|
||||
|
||||
## 1.1.39
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
|
||||
|
||||
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
|
||||
- medusa-core-utils@1.1.37
|
||||
|
||||
## 1.1.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2069](https://github.com/medusajs/medusa/pull/2069) [`ad717b953`](https://github.com/medusajs/medusa/commit/ad717b9533a0500e20c4e312d1ee48b35ea9d5e1) Thanks [@olivermrbl](https://github.com/olivermrbl)! - Remove deprecated dependency `@hapi/joi`
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.36...medusa-plugin-economic@1.1.37) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.35...medusa-plugin-economic@1.1.36) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.34...medusa-plugin-economic@1.1.35) (2021-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.33...medusa-plugin-economic@1.1.34) (2021-12-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.32...medusa-plugin-economic@1.1.33) (2021-11-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.31...medusa-plugin-economic@1.1.32) (2021-11-22)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.30...medusa-plugin-economic@1.1.31) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.29...medusa-plugin-economic@1.1.30) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.28...medusa-plugin-economic@1.1.29) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.27...medusa-plugin-economic@1.1.28) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.25...medusa-plugin-economic@1.1.27) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.25...medusa-plugin-economic@1.1.26) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.24...medusa-plugin-economic@1.1.25) (2021-09-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.23...medusa-plugin-economic@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.22...medusa-plugin-economic@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.21...medusa-plugin-economic@1.1.22) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.19...medusa-plugin-economic@1.1.21) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.19...medusa-plugin-economic@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.18...medusa-plugin-economic@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.17...medusa-plugin-economic@1.1.18) (2021-06-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.16...medusa-plugin-economic@1.1.17) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.15...medusa-plugin-economic@1.1.16) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.14...medusa-plugin-economic@1.1.15) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.13...medusa-plugin-economic@1.1.14) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.12...medusa-plugin-economic@1.1.13) (2021-06-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [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)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.9...medusa-plugin-economic@1.1.10) (2021-04-20)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.8...medusa-plugin-economic@1.1.9) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
|
||||
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
|
||||
|
||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.7...medusa-plugin-economic@1.1.8) (2021-04-13)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.6...medusa-plugin-economic@1.1.7) (2021-03-30)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.5...medusa-plugin-economic@1.1.6) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.3...medusa-plugin-economic@1.1.5) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.3...medusa-plugin-economic@1.1.4) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.2...medusa-plugin-economic@1.1.3) (2021-02-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.1...medusa-plugin-economic@1.1.2) (2021-02-03)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.1.0...medusa-plugin-economic@1.1.1) (2021-01-27)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.0.13...medusa-plugin-economic@1.1.0) (2021-01-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.0.12...medusa-plugin-economic@1.0.13) (2020-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-economic@1.0.11...medusa-plugin-economic@1.0.12) (2020-11-24)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-economic
|
||||
|
||||
## 1.0.11 (2020-10-19)
|
||||
|
||||
## 1.0.10 (2020-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
|
||||
|
||||
## 1.0.7 (2020-09-07)
|
||||
|
||||
## 1.0.1 (2020-09-05)
|
||||
|
||||
## 1.0.1-beta.0 (2020-09-04)
|
||||
|
||||
# 1.0.0 (2020-09-03)
|
||||
|
||||
# 1.0.0-alpha.30 (2020-08-28)
|
||||
|
||||
# 1.0.0-alpha.27 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.26 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.24 (2020-08-27)
|
||||
|
||||
# 1.0.0-alpha.3 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.2 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.1 (2020-08-20)
|
||||
|
||||
# 1.0.0-alpha.0 (2020-08-20)
|
||||
|
||||
## [1.0.10](https://github.com/medusajs/medusa/compare/v1.0.9...v1.0.10) (2020-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- updates license ([db519fb](https://github.com/medusajs/medusa/commit/db519fbaa6f8ad02c19cbecba5d4f28ba1ee81aa))
|
||||
@@ -1,84 +0,0 @@
|
||||
# e-conomic
|
||||
|
||||
Manage your commerce accounting with e-conomic.
|
||||
|
||||
> This plugin is not ready for production use. Community contributions are highly appreciated. You can learn more about contributing in [our repository](https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md).
|
||||
|
||||
[Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
|
||||
|
||||
## Features
|
||||
|
||||
- Create draft and book e-conomic invoices automatically when an order is placed.
|
||||
- Provide endpoints to manually trigger booking and creating draft e-comonic invoices.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
|
||||
- [Visma e-conomic account](https://www.e-conomic.com/developer/connect)
|
||||
- [Redis](https://docs.medusajs.com/development/backend/prepare-environment#redis)
|
||||
|
||||
---
|
||||
|
||||
## How to Install
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend:
|
||||
|
||||
```bash
|
||||
npm install medusa-plugin-economic
|
||||
```
|
||||
|
||||
2\. Set the following environment variables in `.env`:
|
||||
|
||||
```bash
|
||||
ECONOMIC_SECRET_TOKEN=<YOUR_SECRET_TOKEN>
|
||||
ECONOMIC_AGREEMENT_TOKEN=<YOUR_AGREEMENT_TOKEN>
|
||||
ECONOMIC_CUSTOMER_NUMBER_DK=<YOUR_CUSTOMER_NUMBER_DK>
|
||||
ECONOMIC_CUSTOMER_NUMBER_EU=<YOUR_CUSTOMER_NUMBER_EU>
|
||||
ECONOMIC_CUSTOMER_NUMBER_WORLD=<YOUR_CUSTOMER_NUMBER_WORLD>
|
||||
ECONOMIC_UNIT_NUMBER=<YOUR_UNIT_NUMBER>
|
||||
ECONOMIC_PAYMENT_TERMS_NUMBER=<YOUR_PAYMENT_TERMS_NUMBER>
|
||||
ECONOMIC_LAYOUT_NUMBER=<YOUR_LAYOUT_NUMBER>
|
||||
ECONOMIC_VATZONE_NUMBER_DK=<YOUR_VATZONE_NUMBER_DK>
|
||||
ECONOMIC_VATZONE_NUMBER_EU=<YOUR_VATZONE_NUMBER_EU>
|
||||
ECONOMIC_VATZONE_NUMBER_WORLD=<YOUR_VATZONE_NUMBER_WORLD>
|
||||
ECONOMIC_RECIPIENT_NAME=<YOUR_RECIPIENT_NAME>
|
||||
```
|
||||
|
||||
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
||||
|
||||
```js
|
||||
const plugins = [
|
||||
// other plugins...
|
||||
{
|
||||
resolve: `medusa-plugin-economic`,
|
||||
options: {
|
||||
secret_token: process.env.ECONOMIC_SECRET_TOKEN,
|
||||
agreement_token: process.env.ECONOMIC_AGREEMENT_TOKEN,
|
||||
customer_number_dk: process.env.ECONOMIC_CUSTOMER_NUMBER_DK,
|
||||
customer_number_eu: process.env.ECONOMIC_CUSTOMER_NUMBER_EU,
|
||||
customer_number_world: process.env.ECONOMIC_CUSTOMER_NUMBER_WORLD,
|
||||
unit_number: process.env.ECONOMIC_UNIT_NUMBER,
|
||||
payment_terms_number: process.env.ECONOMIC_PAYMENT_TERMS_NUMBER,
|
||||
layout_number: process.env.ECONOMIC_LAYOUT_NUMBER,
|
||||
vatzone_number_dk: process.env.ECONOMIC_VATZONE_NUMBER_DK,
|
||||
vatzone_number_eu: process.env.ECONOMIC_VATZONE_NUMBER_EU,
|
||||
vatzone_number_world: process.env.ECONOMIC_VATZONE_NUMBER_WORLD,
|
||||
recipient_name: process.env.ECONOMIC_RECIPIENT_NAME,
|
||||
},
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test the Plugin
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend to run the backend:
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
2\. Try creating an order using the storefront or the [Store APIs](https://docs.medusajs.com/api/store#tag/Cart). Once the order is placed, a draft invoice will be created in e-conomic.
|
||||
@@ -1 +0,0 @@
|
||||
// noop
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "medusa-plugin-economic",
|
||||
"version": "1.1.45",
|
||||
"description": "E-conomic financial reporting",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/medusa-plugin-economic"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"author": "Oliver Juhl",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.5",
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/node": "^7.7.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
||||
"@babel/preset-env": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"@babel/runtime": "^7.9.6",
|
||||
"client-sessions": "^0.8.0",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-interfaces": "^1.3.7",
|
||||
"medusa-test-utils": "^1.1.40"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "cross-env NODE_ENV=production yarn run build",
|
||||
"test": "jest --passWithNoTests src",
|
||||
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
|
||||
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"medusa-interfaces": "^1.3.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"axios": "^0.19.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.2.0",
|
||||
"moment": "^2.27.0"
|
||||
},
|
||||
"gitHead": "3bbd1e8507e00bc471de6ae3c30207999a4a4011"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Router } from "express"
|
||||
import routes from "./routes"
|
||||
|
||||
export default (container) => {
|
||||
const app = Router()
|
||||
|
||||
routes(app)
|
||||
|
||||
return app
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export default (fn) => (...args) => fn(...args).catch(args[2])
|
||||
@@ -1,5 +0,0 @@
|
||||
import { default as wrap } from "./await-middleware"
|
||||
|
||||
export default {
|
||||
wrap,
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export default async (req, res) => {
|
||||
const economicService = req.scope.resolve("economicService")
|
||||
await economicService.bookEconomicInvoice(req.body.orderId)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export default async (req, res) => {
|
||||
const economicService = req.scope.resolve("economicService")
|
||||
await economicService.draftEconomicInvoice(req.body.orderId)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { Router } from "express"
|
||||
import middlewares from "../../middlewares"
|
||||
|
||||
const route = Router()
|
||||
|
||||
export default (app) => {
|
||||
app.use("/economic", route)
|
||||
|
||||
route.post(
|
||||
"/draft-invoice",
|
||||
middlewares.wrap(require("./create-draft-invoice").default)
|
||||
)
|
||||
|
||||
route.post(
|
||||
"/book-invoice",
|
||||
middlewares.wrap(require("./book-invoice").default)
|
||||
)
|
||||
|
||||
return app
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
import axios from "axios"
|
||||
import moment from "moment"
|
||||
import { BaseService } from "medusa-interfaces"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import EUCountries from "../utils/eu-countries"
|
||||
|
||||
const ECONOMIC_BASE_URL = "https://restapi.e-conomic.com"
|
||||
|
||||
class EconomicService extends BaseService {
|
||||
/**
|
||||
* @param {Object} options - options defined in `medusa-config.js`
|
||||
* {
|
||||
* secret_token: "foo",
|
||||
* agreement_token: "bar",
|
||||
* customer_number_dk: 012
|
||||
* customer_number_eu: 345
|
||||
* customer_number_world: 678,
|
||||
* unit_number: 42,
|
||||
* payment_terms_number: 42,
|
||||
* layout_number: 42,
|
||||
* vatzone_number_eu: 42,
|
||||
* vatzone_number_dk: 42,
|
||||
* vatzone_number_world: 42,
|
||||
* recipient_name: "Webshop customer"
|
||||
* }
|
||||
*/
|
||||
constructor({ orderService, totalsService, regionService }, options) {
|
||||
super()
|
||||
|
||||
this.orderService_ = orderService
|
||||
|
||||
this.totalsService_ = totalsService
|
||||
|
||||
this.regionService_ = regionService
|
||||
|
||||
this.options_ = options
|
||||
|
||||
this.economic_ = axios.create({
|
||||
baseURL: ECONOMIC_BASE_URL,
|
||||
headers: {
|
||||
"X-AppSecretToken": options.secret_token,
|
||||
"X-AgreementGrantToken": options.agreement_token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
decideCustomerAndVatNumber_(country_code) {
|
||||
const upperCased = country_code.toUpperCase()
|
||||
if (EUCountries.includes(upperCased)) {
|
||||
return {
|
||||
vat: this.options_.vatzone_number_eu,
|
||||
customer: this.options_.customer_number_eu,
|
||||
}
|
||||
}
|
||||
|
||||
if (upperCased === "DK") {
|
||||
return {
|
||||
vat: this.options_.vatzone_number_dk,
|
||||
customer: this.options_.customer_number_dk,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
vat: this.options_.vatzone_number_world,
|
||||
customer: this.options_.customer_number_world,
|
||||
}
|
||||
}
|
||||
|
||||
async createEconomicLinesFromOrder(order) {
|
||||
let order_lines = []
|
||||
// Find the discount, that is not free shipping
|
||||
const discount = order.discounts.find(
|
||||
({ rule }) => rule.type !== "free_shipping"
|
||||
)
|
||||
// If the discount has an item specific allocation method,
|
||||
// we need to fetch the discount for each item
|
||||
let itemDiscounts = []
|
||||
if (discount) {
|
||||
itemDiscounts = await this.totalsService_.getAllocationItemDiscounts(
|
||||
discount,
|
||||
order
|
||||
)
|
||||
}
|
||||
|
||||
order.items.forEach((item) => {
|
||||
// For bundles, we create an order line for each item in the bundle
|
||||
if (Array.isArray(item.content)) {
|
||||
item.content.forEach((c) => {
|
||||
const total_amount = c.unit_price * c.quantity * (taxRate + 1)
|
||||
|
||||
order_lines.push({
|
||||
lineNumber: order_lines.length + 1,
|
||||
sortKey: 1,
|
||||
unit: {
|
||||
unitNumber: this.options_.unit_number,
|
||||
},
|
||||
product: {
|
||||
productNumber: c.product.sku,
|
||||
},
|
||||
quantity: c.quantity,
|
||||
// Do we include taxes on this bad boy?
|
||||
unitNetPrice: total_amount,
|
||||
})
|
||||
})
|
||||
} else {
|
||||
const total_amount = item.content.unit_price * item.content.quantity
|
||||
|
||||
// Find the discount for current item and default to 0
|
||||
const itemDiscount =
|
||||
(itemDiscounts &&
|
||||
itemDiscounts.find((el) => el.lineItem._id === item._id)) ||
|
||||
0
|
||||
|
||||
// Withdraw discount from the total item amount
|
||||
const total_discount_amount = total_amount - itemDiscount
|
||||
|
||||
order_lines.push({
|
||||
lineNumber: order_lines.length + 1,
|
||||
sortKey: 1,
|
||||
unit: {
|
||||
unitNumber: this.options_.unit_number,
|
||||
},
|
||||
product: {
|
||||
productNumber: item.content.product.sku,
|
||||
},
|
||||
quantity: item.content.quantity,
|
||||
// Do we include taxes on this bad boy?
|
||||
unitNetPrice: total_discount_amount,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async createInvoiceFromOrder(order) {
|
||||
// Fetch currency code from order region
|
||||
const { currency_code } = await this.regionService_.retrieve(
|
||||
order.region_id
|
||||
)
|
||||
|
||||
const vatZoneAndCustomer = this.decideCustomerAndVatNumber_(
|
||||
order.billing_address.country_code
|
||||
)
|
||||
|
||||
const lines = await this.createEconomicLinesFromOrder(order)
|
||||
|
||||
return {
|
||||
date: moment().format("YYYY-MM-DD"),
|
||||
currency: currency_code,
|
||||
paymentTerms: {
|
||||
paymentTermsNumber: this.options_.payment_terms_number,
|
||||
},
|
||||
references: {
|
||||
other: order._id,
|
||||
},
|
||||
customer: {
|
||||
customerNumber: vatZoneAndCustomer.customer,
|
||||
},
|
||||
recipient: {
|
||||
name: this.options_.recipient_name,
|
||||
vatZone: {
|
||||
vatZoneNumber: vatZoneAndCustomer.vat,
|
||||
},
|
||||
},
|
||||
layout: {
|
||||
layoutNumber: this.options_.layout_number,
|
||||
},
|
||||
lines,
|
||||
}
|
||||
}
|
||||
|
||||
async draftEconomicInvoice(orderId) {
|
||||
const order = await this.orderService_.retrieve(orderId)
|
||||
const invoice = await this.createInvoiceFromOrder(order)
|
||||
try {
|
||||
const draftInvoice = await this.economic_.post(
|
||||
`${ECONOMIC_BASE_URL}/invoices/drafts`,
|
||||
invoice
|
||||
)
|
||||
|
||||
await this.orderService_.setMetadata(
|
||||
order._id,
|
||||
"economicDraftId",
|
||||
draftInvoice.data.draftInvoiceNumber
|
||||
)
|
||||
|
||||
const invoiceOrder = await this.orderService_.retrieve(order._id)
|
||||
return invoiceOrder
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async bookEconomicInvoice(orderId) {
|
||||
try {
|
||||
const order = await this.orderService_.retrieve(orderId)
|
||||
const { economicDraftId } = order.metadata
|
||||
|
||||
if (!economicDraftId) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_ARGUMENT,
|
||||
"The order does not have an invoice number"
|
||||
)
|
||||
}
|
||||
|
||||
const bookInvoiceRequest = {
|
||||
draftInvoice: {
|
||||
draftInvoiceNumber: parseInt(economicDraftId),
|
||||
},
|
||||
}
|
||||
|
||||
return this.economic_.post(
|
||||
`${ECONOMIC_BASE_URL}/invoices/booked`,
|
||||
bookInvoiceRequest
|
||||
)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default EconomicService
|
||||
@@ -1,17 +0,0 @@
|
||||
class OrderSubscriber {
|
||||
constructor({ economicService, eventBusService }) {
|
||||
this.economicService_ = economicService
|
||||
|
||||
this.eventBus_ = eventBusService
|
||||
|
||||
this.eventBus_.subscribe("order.placed", async (order) => {
|
||||
await this.economicService_.draftEconomicInvoice(order)
|
||||
})
|
||||
|
||||
this.eventBus_.subscribe("order.completed", async (order) => {
|
||||
await this.economicService_.bookEconomicInvoice(order._id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default OrderSubscriber
|
||||
@@ -1,30 +0,0 @@
|
||||
export default [
|
||||
"BE",
|
||||
"BG",
|
||||
"CZ",
|
||||
"DK",
|
||||
"DE",
|
||||
"EE",
|
||||
"IE",
|
||||
"EL",
|
||||
"ES",
|
||||
"FR",
|
||||
"HR",
|
||||
"IT",
|
||||
"CY",
|
||||
"LV",
|
||||
"LT",
|
||||
"LU",
|
||||
"HU",
|
||||
"MT",
|
||||
"NL",
|
||||
"AT",
|
||||
"PL",
|
||||
"PT",
|
||||
"RO",
|
||||
"SI",
|
||||
"SK",
|
||||
"FI",
|
||||
"SE",
|
||||
"UK",
|
||||
]
|
||||
@@ -1,8 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
var _default = ["BE", "BG", "CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR", "HR", "IT", "CY", "LV", "LT", "LU", "HU", "MT", "NL", "AT", "PL", "PT", "RO", "SI", "SK", "FI", "SE", "UK"];
|
||||
exports["default"] = _default;
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-instanceof",
|
||||
"@babel/plugin-transform-classes"
|
||||
],
|
||||
"presets": ["@babel/preset-env"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
}
|
||||
}
|
||||
15
packages/medusa-plugin-mailchimp/.gitignore
vendored
15
packages/medusa-plugin-mailchimp/.gitignore
vendored
@@ -1,15 +0,0 @@
|
||||
/lib
|
||||
node_modules
|
||||
.DS_store
|
||||
.env*
|
||||
/*.js
|
||||
!index.js
|
||||
!jest.config.js
|
||||
|
||||
/dist
|
||||
|
||||
/api
|
||||
/services
|
||||
/models
|
||||
/subscribers
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
.DS_store
|
||||
src
|
||||
dist
|
||||
yarn.lock
|
||||
.babelrc
|
||||
jest.config.js
|
||||
|
||||
.turbo
|
||||
.yarn
|
||||
@@ -1,280 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 1.1.50
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4276](https://github.com/medusajs/medusa/pull/4276) [`afd1b67f1`](https://github.com/medusajs/medusa/commit/afd1b67f1c7de8cf07fd9fcbdde599a37914e9b5) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Use caret range
|
||||
|
||||
## 1.1.49
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#4040](https://github.com/medusajs/medusa/pull/4040) [`ddc90db53`](https://github.com/medusajs/medusa/commit/ddc90db5302286afa27282b38b28961ee0edf9e8) Thanks [@tomekpur](https://github.com/tomekpur)! - feat(medusa-plugin-mailchimp): Added PUT method for the /mailchimp/subscribe endpoint.
|
||||
|
||||
- Updated dependencies [[`0a35f21af`](https://github.com/medusajs/medusa/commit/0a35f21af7ac8b6cdc1af12a403e95f9bf6142fe), [`4fb443c0e`](https://github.com/medusajs/medusa/commit/4fb443c0ea38bde3148bce059c0ee3b91dfff3d4), [`0476f5251`](https://github.com/medusajs/medusa/commit/0476f52519237c622b37d29de0718f9774b6add7), [`0f87d3d64`](https://github.com/medusajs/medusa/commit/0f87d3d642b56bf19de8136e1f5bfedf364c5193), [`ed382f2ee`](https://github.com/medusajs/medusa/commit/ed382f2ee510cbf96164991efa7ff75e3ce659ff), [`92f01cefb`](https://github.com/medusajs/medusa/commit/92f01cefbc4a190defce425fb237d2d68728fa9a), [`e3cfbcd4a`](https://github.com/medusajs/medusa/commit/e3cfbcd4a78073c63ecd9829bc531e50d3944f07), [`6998666c6`](https://github.com/medusajs/medusa/commit/6998666c6edd6617ca61a8d39c26435bad1273e3), [`81eeaa329`](https://github.com/medusajs/medusa/commit/81eeaa32942b1a7148126a7218ceb168ce8d6cac), [`e2d29d35c`](https://github.com/medusajs/medusa/commit/e2d29d35c4c477bc9b4a3ddce1279276fd072875), [`3a38c84f8`](https://github.com/medusajs/medusa/commit/3a38c84f88b05f74ee0a172af3e3f78b2ec8c2d2), [`4f3c8f5d7`](https://github.com/medusajs/medusa/commit/4f3c8f5d70b5ae4a11e9d4a2fea4a8410b2daf47), [`a91987fab`](https://github.com/medusajs/medusa/commit/a91987fab33745f9864eab21bd1c27e8e3e24571), [`bf18bd0c8`](https://github.com/medusajs/medusa/commit/bf18bd0c8a284dd0042d4c54d84acb2e7c10edd3), [`db4199530`](https://github.com/medusajs/medusa/commit/db419953075e0907b8c4d27ab5188e9bd3e3d72b)]:
|
||||
- @medusajs/medusa@1.12.0
|
||||
|
||||
## 1.1.48
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3763](https://github.com/medusajs/medusa/pull/3763) [`4104d9ccb`](https://github.com/medusajs/medusa/commit/4104d9ccb25276c85b5363f85e14b3093e64df85) Thanks [@StephixOne](https://github.com/StephixOne)! - fix(plugin-discount-generator,plugin-economic,plugin-mailchimp,plugin-restock-notification,plugin-sendgrid,plugin-wishlist): Temporarily remove payload validation in some plugins
|
||||
|
||||
## 1.1.47
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0
|
||||
- medusa-interfaces@1.3.7
|
||||
- medusa-test-utils@1.1.40
|
||||
|
||||
## 1.1.47-rc.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0-rc.0
|
||||
- medusa-interfaces@1.3.7-rc.0
|
||||
- medusa-test-utils@1.1.40-rc.0
|
||||
|
||||
## 1.1.46
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3217](https://github.com/medusajs/medusa/pull/3217) [`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0) Thanks [@adrien2p](https://github.com/adrien2p)! - chore: Fix npm packages files included
|
||||
|
||||
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
|
||||
- medusa-core-utils@1.1.39
|
||||
- medusa-interfaces@1.3.6
|
||||
|
||||
## 1.1.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3185](https://github.com/medusajs/medusa/pull/3185) [`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4) Thanks [@olivermrbl](https://github.com/olivermrbl)! - chore: Patches all dependencies + minor bumps `winston` to include a [fix for a significant memory leak](https://github.com/winstonjs/winston/pull/2057)
|
||||
|
||||
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
|
||||
- medusa-core-utils@1.1.38
|
||||
- medusa-interfaces@1.3.5
|
||||
|
||||
## 1.1.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
|
||||
|
||||
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
|
||||
- medusa-interfaces@1.3.4
|
||||
|
||||
## 1.1.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
|
||||
|
||||
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
|
||||
- medusa-core-utils@1.1.37
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.42](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.41...medusa-plugin-mailchimp@1.1.42) (2022-07-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.41](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.39...medusa-plugin-mailchimp@1.1.41) (2022-06-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.40](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.39...medusa-plugin-mailchimp@1.1.40) (2022-05-31)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.39](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.38...medusa-plugin-mailchimp@1.1.39) (2022-02-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release ([fc3fbc8](https://github.com/medusajs/medusa/commit/fc3fbc897fad5c8a5d3eea828ac7277fba9d70af))
|
||||
|
||||
## [1.1.38](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.37...medusa-plugin-mailchimp@1.1.38) (2022-02-06)
|
||||
|
||||
### Features
|
||||
|
||||
- medusa-react admin hooks ([#978](https://github.com/medusajs/medusa/issues/978)) ([2e38484](https://github.com/medusajs/medusa/commit/2e384842d5b2e9742a86b96f28a8f00357795b86)), closes [#1019](https://github.com/medusajs/medusa/issues/1019)
|
||||
|
||||
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.36...medusa-plugin-mailchimp@1.1.37) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.35...medusa-plugin-mailchimp@1.1.36) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.34...medusa-plugin-mailchimp@1.1.35) (2021-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.33...medusa-plugin-mailchimp@1.1.34) (2021-12-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.32...medusa-plugin-mailchimp@1.1.33) (2021-11-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.31...medusa-plugin-mailchimp@1.1.32) (2021-11-22)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.30...medusa-plugin-mailchimp@1.1.31) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.29...medusa-plugin-mailchimp@1.1.30) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.28...medusa-plugin-mailchimp@1.1.29) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.27...medusa-plugin-mailchimp@1.1.28) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.25...medusa-plugin-mailchimp@1.1.27) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.25...medusa-plugin-mailchimp@1.1.26) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.24...medusa-plugin-mailchimp@1.1.25) (2021-09-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.23...medusa-plugin-mailchimp@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.22...medusa-plugin-mailchimp@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.21...medusa-plugin-mailchimp@1.1.22) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.19...medusa-plugin-mailchimp@1.1.21) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.19...medusa-plugin-mailchimp@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.18...medusa-plugin-mailchimp@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.17...medusa-plugin-mailchimp@1.1.18) (2021-06-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.16...medusa-plugin-mailchimp@1.1.17) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.15...medusa-plugin-mailchimp@1.1.16) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.14...medusa-plugin-mailchimp@1.1.15) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.13...medusa-plugin-mailchimp@1.1.14) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.12...medusa-plugin-mailchimp@1.1.13) (2021-06-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [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)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.9...medusa-plugin-mailchimp@1.1.10) (2021-04-20)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.8...medusa-plugin-mailchimp@1.1.9) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
|
||||
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
|
||||
|
||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.7...medusa-plugin-mailchimp@1.1.8) (2021-04-13)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.6...medusa-plugin-mailchimp@1.1.7) (2021-03-30)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.5...medusa-plugin-mailchimp@1.1.6) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.3...medusa-plugin-mailchimp@1.1.5) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.3...medusa-plugin-mailchimp@1.1.4) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.2...medusa-plugin-mailchimp@1.1.3) (2021-02-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.1...medusa-plugin-mailchimp@1.1.2) (2021-02-03)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.1.0...medusa-plugin-mailchimp@1.1.1) (2021-01-27)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.0.15...medusa-plugin-mailchimp@1.1.0) (2021-01-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.0.15](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.0.14...medusa-plugin-mailchimp@1.0.15) (2020-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.0.14](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.0.13...medusa-plugin-mailchimp@1.0.14) (2020-11-24)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## [1.0.13](https://github.com/medusajs/medusa/compare/medusa-plugin-mailchimp@1.0.12...medusa-plugin-mailchimp@1.0.13) (2020-10-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-mailchimp
|
||||
|
||||
## 1.0.12 (2020-10-05)
|
||||
|
||||
### Features
|
||||
|
||||
- **plugins:** Adds Mailchimp newsletter subscription ([89c21f2](https://github.com/medusajs/medusa/commit/89c21f2f5b317b2de368d4429c1eacc373937217))
|
||||
@@ -1,67 +0,0 @@
|
||||
# Mailchimp
|
||||
|
||||
Manage newsletter subscriptions in your commerce application with Mailchimp.
|
||||
|
||||
[Mailchimp Plugin Documentation](https://docs.medusajs.com/plugins/notifications/mailchimp) | [Medusa Website](https://medusajs.com/) | [Medusa Repository](https://github.com/medusajs/medusa)
|
||||
|
||||
## Features
|
||||
|
||||
- Allow customers to subscribe to your newsletter.
|
||||
- Provides custom services and endpoints to give developers flexibility in how to implement newsletter subscription.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
|
||||
- [Mailchimp account](https://mailchimp.com/signup)
|
||||
|
||||
---
|
||||
|
||||
## How to Install
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend:
|
||||
|
||||
```bash
|
||||
npm install medusa-plugin-mailchimp
|
||||
```
|
||||
|
||||
2\. Set the following environment variables in `.env`:
|
||||
|
||||
```bash
|
||||
MAILCHIMP_API_KEY=<YOUR_API_KEY>
|
||||
MAILCHIMP_NEWSLETTER_LIST_ID=<YOUR_NEWSLETTER_LIST_ID>
|
||||
```
|
||||
|
||||
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
||||
|
||||
```js
|
||||
const plugins = [
|
||||
// ...,
|
||||
{
|
||||
resolve: `medusa-plugin-mailchimp`,
|
||||
options: {
|
||||
api_key: process.env.MAILCHIMP_API_KEY,
|
||||
newsletter_list_id: process.env.MAILCHIMP_NEWSLETTER_LIST_ID,
|
||||
},
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test the Plugin
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend to run the backend:
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
2\. Use the POST or PUT `/mailchimp/subscribe` endpoint or the `MailchimpService` to subscribe to the newsletter.
|
||||
|
||||
---
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- [Mailchimp Plugin Documentation](https://docs.medusajs.com/plugins/notifications/mailchimp)
|
||||
@@ -1 +0,0 @@
|
||||
// noop
|
||||
@@ -1,6 +0,0 @@
|
||||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
transform: {
|
||||
"^.+\\.[jt]s?$": `../../jest-transformer.js`,
|
||||
},
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"name": "medusa-plugin-mailchimp",
|
||||
"version": "1.1.50",
|
||||
"description": "Mailchimp newsletter subscriptions",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/medusa-plugin-mailchimp"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"author": "Oliver Juhl, Tomek Pur",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@medusajs/medusa": "^1.12.1",
|
||||
"@types/express": "^4.17.17",
|
||||
"client-sessions": "^0.8.0",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^25.5.4",
|
||||
"rimraf": "^5.0.1",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
|
||||
"test": "jest --passWithNoTests src",
|
||||
"build": "rimraf dist && tsc",
|
||||
"watch": "tsc --watch"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@medusajs/medusa": "^1.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"mailchimp-api-v3": "^1.14.0",
|
||||
"medusa-core-utils": "^1.2.0",
|
||||
"medusa-test-utils": "^1.1.40"
|
||||
},
|
||||
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e",
|
||||
"keywords": [
|
||||
"medusa-plugin",
|
||||
"medusa-plugin-notification"
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Router } from "express"
|
||||
import routes from "./routes"
|
||||
|
||||
export default function (rootDirectory: string): Router | Router[] {
|
||||
const app = Router()
|
||||
|
||||
routes(app, rootDirectory)
|
||||
|
||||
return app
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import { Router } from "express"
|
||||
import * as cors from "cors"
|
||||
import * as bodyParser from "body-parser"
|
||||
import configLoader from "@medusajs/medusa/dist/loaders/config"
|
||||
import { parseCorsOrigins } from "medusa-core-utils"
|
||||
import { wrapHandler } from "@medusajs/medusa"
|
||||
import {
|
||||
update as subscribeNewsletterUpdate,
|
||||
add as subscribeNewsletterAdd,
|
||||
} from "./subscribe-newsletter"
|
||||
|
||||
const router = Router()
|
||||
|
||||
export default (app: Router, rootDirectory) => {
|
||||
const config = configLoader(rootDirectory)
|
||||
|
||||
const corsOptions = {
|
||||
origin: parseCorsOrigins(config.projectConfig.store_cors || ""),
|
||||
credentials: true,
|
||||
}
|
||||
|
||||
app.use("/mailchimp", router)
|
||||
|
||||
router.use(cors(corsOptions))
|
||||
|
||||
router.post(
|
||||
"/subscribe",
|
||||
bodyParser.json(),
|
||||
wrapHandler(subscribeNewsletterAdd)
|
||||
)
|
||||
|
||||
router.put(
|
||||
"/subscribe",
|
||||
bodyParser.json(),
|
||||
wrapHandler(subscribeNewsletterUpdate)
|
||||
)
|
||||
|
||||
return app
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Request, Response } from "express"
|
||||
|
||||
export async function add(req: Request, res: Response) {
|
||||
const mailchimpService = req.scope.resolve("mailchimpService")
|
||||
await mailchimpService.subscribeNewsletterAdd(
|
||||
req.body.email,
|
||||
req.body.data || {}
|
||||
)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
|
||||
export async function update(req: Request, res: Response) {
|
||||
const mailchimpService = req.scope.resolve("mailchimpService")
|
||||
await mailchimpService.subscribeNewsletterUpdate(
|
||||
req.body.email,
|
||||
req.body.data || {}
|
||||
)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
const MailchimpMock = jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
subscribeNewsletterAdd: jest
|
||||
.fn()
|
||||
.mockReturnValue(Promise.resolve("success")),
|
||||
subscribeNewsletterUpdate: jest
|
||||
.fn()
|
||||
.mockReturnValue(Promise.resolve("success")),
|
||||
}
|
||||
})
|
||||
|
||||
describe("MailchimpService", () => {
|
||||
describe("newsletterSubscribe", () => {
|
||||
let result
|
||||
beforeAll(async () => {
|
||||
jest.clearAllMocks()
|
||||
const mailchimpService = new MailchimpMock()
|
||||
|
||||
result = await mailchimpService.subscribeNewsletterAdd(
|
||||
"medusa@medusa.com"
|
||||
)
|
||||
})
|
||||
|
||||
it("resolves successfully", () => {
|
||||
expect(result).toEqual("success")
|
||||
})
|
||||
}),
|
||||
describe("newsletterSubscribeUpdate", () => {
|
||||
let result
|
||||
beforeAll(async () => {
|
||||
jest.clearAllMocks()
|
||||
const mailchimpService = new MailchimpMock()
|
||||
|
||||
result = await mailchimpService.subscribeNewsletterUpdate(
|
||||
"medusa@medusa.com"
|
||||
)
|
||||
})
|
||||
|
||||
it("resolves successfully", () => {
|
||||
expect(result).toEqual("success")
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,71 +0,0 @@
|
||||
import { TransactionBaseService } from "@medusajs/medusa"
|
||||
import Mailchimp = require("mailchimp-api-v3")
|
||||
import * as crypto from "crypto"
|
||||
import { MailchimpPluginOptions } from "../types"
|
||||
|
||||
class MailchimpService extends TransactionBaseService {
|
||||
protected options_: MailchimpPluginOptions
|
||||
protected mailchimp_: Mailchimp
|
||||
|
||||
/**
|
||||
* @param {Object} options - options defined in `medusa-config.js`
|
||||
* e.g.
|
||||
* {
|
||||
* api_key: Mailchimp api key
|
||||
* newsletter_list_id: "123456789"
|
||||
* }
|
||||
*/
|
||||
constructor(_, options: MailchimpPluginOptions) {
|
||||
super(_, options)
|
||||
|
||||
this.options_ = options
|
||||
|
||||
this.mailchimp_ = new Mailchimp(options.api_key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes an email to a newsletter.
|
||||
* @param {string} email - email to use for the subscription
|
||||
* @param {Object} data - additional data (see https://mailchimp.com/developer/marketing/api/list-merges/)
|
||||
* @return {Promise} result of newsletter subscription
|
||||
*/
|
||||
async subscribeNewsletterAdd(email: string, data: any) {
|
||||
return this.mailchimp_.post(
|
||||
`/lists/${this.options_.newsletter_list_id}/members`,
|
||||
{
|
||||
email_address: email,
|
||||
status: "subscribed",
|
||||
...data,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an email to a newsletter.
|
||||
* @param {string} email - email to use for the subscription
|
||||
* @param {Object} data - additional data (see https://mailchimp.com/developer/marketing/api/list-merges/)
|
||||
* @return {Promise} result of newsletter subscription
|
||||
*/
|
||||
|
||||
async subscribeNewsletterUpdate(
|
||||
email: string,
|
||||
data: any,
|
||||
statusIfNew?: string,
|
||||
status?: string
|
||||
) {
|
||||
const lowercase = email.toLowerCase()
|
||||
const hash = crypto.createHash("md5").update(lowercase).digest("hex")
|
||||
|
||||
return this.mailchimp_.put(
|
||||
`/lists/${this.options_.newsletter_list_id}/members/${hash}`,
|
||||
{
|
||||
email_address: email,
|
||||
status_if_new: statusIfNew || "subscribed",
|
||||
status: status || "subscribed",
|
||||
...data,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default MailchimpService
|
||||
@@ -1,4 +0,0 @@
|
||||
export type MailchimpPluginOptions = {
|
||||
newsletter_list_id: string
|
||||
api_key: string
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es5", "es6"],
|
||||
"target": "esnext",
|
||||
"allowJs": true,
|
||||
"esModuleInterop": false,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"skipDefaultLibCheck": true,
|
||||
"declaration": false,
|
||||
"sourceMap": false,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "src",
|
||||
"baseUrl": "src"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": [
|
||||
"dist",
|
||||
"./src/**/__tests__",
|
||||
"./src/**/__mocks__",
|
||||
"./src/**/__fixtures__",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-instanceof",
|
||||
"@babel/plugin-transform-classes"
|
||||
],
|
||||
"presets": ["@babel/preset-env"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
}
|
||||
}
|
||||
15
packages/medusa-plugin-twilio-sms/.gitignore
vendored
15
packages/medusa-plugin-twilio-sms/.gitignore
vendored
@@ -1,15 +0,0 @@
|
||||
/lib
|
||||
node_modules
|
||||
.DS_store
|
||||
.env*
|
||||
/*.js
|
||||
!index.js
|
||||
!jest.config.js
|
||||
|
||||
/dist
|
||||
|
||||
/api
|
||||
/services
|
||||
/models
|
||||
/subscribers
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
.DS_store
|
||||
src
|
||||
dist
|
||||
yarn.lock
|
||||
.babelrc
|
||||
jest.config.js
|
||||
|
||||
.turbo
|
||||
.yarn
|
||||
@@ -1,253 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 1.2.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0
|
||||
- medusa-interfaces@1.3.7
|
||||
- medusa-test-utils@1.1.40
|
||||
|
||||
## 1.2.8-rc.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0-rc.0
|
||||
- medusa-interfaces@1.3.7-rc.0
|
||||
- medusa-test-utils@1.1.40-rc.0
|
||||
|
||||
## 1.2.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
|
||||
- medusa-core-utils@1.1.39
|
||||
- medusa-interfaces@1.3.6
|
||||
|
||||
## 1.2.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
|
||||
- medusa-core-utils@1.1.38
|
||||
- medusa-interfaces@1.3.5
|
||||
|
||||
## 1.2.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
|
||||
|
||||
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
|
||||
- medusa-interfaces@1.3.4
|
||||
|
||||
## 1.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
|
||||
|
||||
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
|
||||
- medusa-core-utils@1.1.37
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.2.3](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.2.2...medusa-plugin-twilio-sms@1.2.3) (2022-07-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.2.2](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.2.0...medusa-plugin-twilio-sms@1.2.2) (2022-06-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.2.0...medusa-plugin-twilio-sms@1.2.1) (2022-05-31)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.37...medusa-plugin-twilio-sms@1.2.0) (2022-05-01)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **medusa-plugin-twilio-sms:** fix name in README ([#1457](https://github.com/medusajs/medusa/issues/1457)) ([56e79d3](https://github.com/medusajs/medusa/commit/56e79d334ecd2a67cad43c8ebd58e364f9e9fb59))
|
||||
|
||||
## [1.1.37](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.36...medusa-plugin-twilio-sms@1.1.37) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.36](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.35...medusa-plugin-twilio-sms@1.1.36) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.35](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.34...medusa-plugin-twilio-sms@1.1.35) (2021-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.34](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.33...medusa-plugin-twilio-sms@1.1.34) (2021-12-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.33](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.32...medusa-plugin-twilio-sms@1.1.33) (2021-11-23)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.31...medusa-plugin-twilio-sms@1.1.32) (2021-11-22)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.30...medusa-plugin-twilio-sms@1.1.31) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.30](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.29...medusa-plugin-twilio-sms@1.1.30) (2021-11-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.29](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.28...medusa-plugin-twilio-sms@1.1.29) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.28](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.27...medusa-plugin-twilio-sms@1.1.28) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.27](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.25...medusa-plugin-twilio-sms@1.1.27) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.26](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.25...medusa-plugin-twilio-sms@1.1.26) (2021-10-18)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.25](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.24...medusa-plugin-twilio-sms@1.1.25) (2021-09-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.24](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.23...medusa-plugin-twilio-sms@1.1.24) (2021-09-14)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.23](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.22...medusa-plugin-twilio-sms@1.1.23) (2021-08-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.22](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.21...medusa-plugin-twilio-sms@1.1.22) (2021-07-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.21](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.19...medusa-plugin-twilio-sms@1.1.21) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.20](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.19...medusa-plugin-twilio-sms@1.1.20) (2021-07-15)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.19](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.18...medusa-plugin-twilio-sms@1.1.19) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.18](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.17...medusa-plugin-twilio-sms@1.1.18) (2021-06-22)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release assist ([668e8a7](https://github.com/medusajs/medusa/commit/668e8a740200847fc2a41c91d2979097f1392532))
|
||||
|
||||
## [1.1.17](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.16...medusa-plugin-twilio-sms@1.1.17) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.16](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.15...medusa-plugin-twilio-sms@1.1.16) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.15](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.14...medusa-plugin-twilio-sms@1.1.15) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.14](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.13...medusa-plugin-twilio-sms@1.1.14) (2021-06-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.13](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.12...medusa-plugin-twilio-sms@1.1.13) (2021-06-08)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [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)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.10](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.9...medusa-plugin-twilio-sms@1.1.10) (2021-04-20)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.9](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.8...medusa-plugin-twilio-sms@1.1.9) (2021-04-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- merge develop ([2982a8e](https://github.com/medusajs/medusa/commit/2982a8e682e90beb4549d969d9d3b04d78a46a2d))
|
||||
- merge develop ([a468c45](https://github.com/medusajs/medusa/commit/a468c451e82c68f41b5005a2e480057f6124aaa6))
|
||||
|
||||
## [1.1.8](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.7...medusa-plugin-twilio-sms@1.1.8) (2021-04-13)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.7](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.6...medusa-plugin-twilio-sms@1.1.7) (2021-03-30)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.6](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.5...medusa-plugin-twilio-sms@1.1.6) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.5](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.3...medusa-plugin-twilio-sms@1.1.5) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.4](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.3...medusa-plugin-twilio-sms@1.1.4) (2021-03-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.3](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.2...medusa-plugin-twilio-sms@1.1.3) (2021-02-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.1...medusa-plugin-twilio-sms@1.1.2) (2021-02-03)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.1.0...medusa-plugin-twilio-sms@1.1.1) (2021-01-27)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.0.12...medusa-plugin-twilio-sms@1.1.0) (2021-01-26)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.0.12](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.0.11...medusa-plugin-twilio-sms@1.0.12) (2020-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.0.11](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.0.10...medusa-plugin-twilio-sms@1.0.11) (2020-11-24)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.0.10](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.0.9...medusa-plugin-twilio-sms@1.0.10) (2020-10-19)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## [1.0.9](https://github.com/medusajs/medusa/compare/medusa-plugin-twilio-sms@1.0.8...medusa-plugin-twilio-sms@1.0.9) (2020-09-09)
|
||||
|
||||
**Note:** Version bump only for package medusa-plugin-twilio-sms
|
||||
|
||||
## 1.0.8 (2020-09-09)
|
||||
|
||||
### Features
|
||||
|
||||
- **plugins:** Adds Twilio SMS plugin ([35a91ae](https://github.com/medusajs/medusa/commit/35a91ae6a179e750b77df97f46a6b88d6b45819d))
|
||||
@@ -1,62 +0,0 @@
|
||||
# Twilio SMS
|
||||
|
||||
Utilize Twilio's SMS APIs to send customers SMS notifications.
|
||||
|
||||
[Twilio SMS Plugin Documentation](https://docs.medusajs.com/plugins/notifications/twilio-sms) | [Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
|
||||
|
||||
## Features
|
||||
|
||||
- Access Twilio's SMS APIs easily using the `TwilioSmsService`.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
|
||||
- [Twilio account](https://www.twilio.com/sms)
|
||||
|
||||
---
|
||||
|
||||
## How to Install
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend:
|
||||
|
||||
```bash
|
||||
npm install medusa-plugin-twilio-sms
|
||||
```
|
||||
|
||||
2\. Set the following environment variable in `.env`:
|
||||
|
||||
```bash
|
||||
TWILIO_SMS_ACCOUNT_SID=<YOUR_ACCOUNT_SID>
|
||||
TWILIO_SMS_AUTH_TOKEN=<YOUR_AUTH_TOKEN>
|
||||
TWILIO_SMS_FROM_NUMBER=<YOUR_TWILIO_NUMBER>
|
||||
```
|
||||
|
||||
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
||||
|
||||
```js
|
||||
const plugins = [
|
||||
// ...
|
||||
{
|
||||
resolve: `medusa-plugin-twilio-sms`,
|
||||
options: {
|
||||
account_sid: process.env.TWILIO_SMS_ACCOUNT_SID,
|
||||
auth_token: process.env.TWILIO_SMS_AUTH_TOKEN,
|
||||
from_number: process.env.TWILIO_SMS_FROM_NUMBER,
|
||||
},
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test the Plugin
|
||||
|
||||
In your code, use the `TwilioSmsService` where necessary to send your customers notifications.
|
||||
|
||||
---
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- [Twilio SMS Plugin Documentation](https://docs.medusajs.com/plugins/notifications/twilio-sms)
|
||||
@@ -1 +0,0 @@
|
||||
// noop
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "medusa-plugin-twilio-sms",
|
||||
"version": "1.2.8",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/medusa-plugin-twilio-sms"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"author": "Oliver Juhl",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.7.5",
|
||||
"@babel/core": "^7.7.5",
|
||||
"@babel/node": "^7.7.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
||||
"@babel/preset-env": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"@babel/runtime": "^7.9.6",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-interfaces": "^1.3.7",
|
||||
"medusa-test-utils": "^1.1.40"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "cross-env NODE_ENV=production yarn run build",
|
||||
"test": "jest --passWithNoTests src",
|
||||
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
|
||||
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"medusa-interfaces": "^1.3.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"body-parser": "^1.19.0",
|
||||
"medusa-core-utils": "^1.2.0",
|
||||
"twilio": "^3.49.1"
|
||||
},
|
||||
"gitHead": "c46300d58fbfd0b2dc2c02745ae143e6247e885b",
|
||||
"keywords": [
|
||||
"medusa-plugin",
|
||||
"medusa-plugin-notification"
|
||||
]
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import { BaseService } from "medusa-interfaces"
|
||||
import twilio from "twilio"
|
||||
|
||||
class TwilioSmsService extends BaseService {
|
||||
/**
|
||||
* @param {Object} options - options defined in `medusa-config.js`
|
||||
* e.g.
|
||||
* {
|
||||
* account_sid: "1234",
|
||||
* auth_token: "XXX",
|
||||
* from_number: "+4512345678"
|
||||
* }
|
||||
*/
|
||||
constructor({}, options) {
|
||||
super()
|
||||
|
||||
this.options_ = options
|
||||
|
||||
this.twilioClient = twilio(options.account_sid, options.auth_token)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} data - Twilio message options
|
||||
* see: https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource
|
||||
*/
|
||||
async sendSms(data) {
|
||||
return this.twilioClient.messages.create({
|
||||
from: this.options_.from_number,
|
||||
...data,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default TwilioSmsService
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-optional-chaining",
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-instanceof",
|
||||
"@babel/plugin-transform-classes"
|
||||
],
|
||||
"presets": ["@babel/preset-env"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
}
|
||||
}
|
||||
16
packages/medusa-source-shopify/.gitignore
vendored
16
packages/medusa-source-shopify/.gitignore
vendored
@@ -1,16 +0,0 @@
|
||||
/lib
|
||||
node_modules
|
||||
.DS_store
|
||||
.env*
|
||||
/*.js
|
||||
!index.js
|
||||
!jest.config.js
|
||||
|
||||
/dist
|
||||
/api
|
||||
/services
|
||||
/utils
|
||||
/subscribers
|
||||
/loaders
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
.DS_store
|
||||
src
|
||||
dist
|
||||
yarn.lock
|
||||
.babelrc
|
||||
jest.config.js
|
||||
|
||||
.turbo
|
||||
.yarn
|
||||
@@ -1,142 +0,0 @@
|
||||
# Change Log
|
||||
|
||||
## 1.2.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5543](https://github.com/medusajs/medusa/pull/5543) [`f90ba0208`](https://github.com/medusajs/medusa/commit/f90ba02087778d8131aed3a59a6dc9c8ca3c95f4) Thanks [@adrien2p](https://github.com/adrien2p)! - feat(utils): Introduce promiseAll util
|
||||
|
||||
- Updated dependencies [[`c39bf69a5`](https://github.com/medusajs/medusa/commit/c39bf69a5e5cae75d7fa12aa6022b10903557a32), [`154c9b43b`](https://github.com/medusajs/medusa/commit/154c9b43bde1fdff562aba9da8a79af2660b29b3)]:
|
||||
- @medusajs/utils@1.10.5
|
||||
|
||||
## 1.2.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
|
||||
|
||||
- upgrade typeorm from 0.2.51 to 0.3.11
|
||||
- Plugin repository loader to work with Typeorm update
|
||||
|
||||
- [#3187](https://github.com/medusajs/medusa/pull/3187) [`f97b3d7cc`](https://github.com/medusajs/medusa/commit/f97b3d7ccee381d3491337ab5144bb44520382a7) Thanks [@fPolic](https://github.com/fPolic)! - feat(medusa, cache-redis, cache-inmemory): Added cache modules
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0
|
||||
- medusa-interfaces@1.3.7
|
||||
- medusa-test-utils@1.1.40
|
||||
|
||||
## 1.2.8-rc.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3041](https://github.com/medusajs/medusa/pull/3041) [`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724) Thanks [@riqwan](https://github.com/riqwan)! - chore(medusa): Typeorm fixes / enhancements
|
||||
|
||||
- upgrade typeorm from 0.2.51 to 0.3.11
|
||||
- Plugin repository loader to work with Typeorm update
|
||||
|
||||
- [#3187](https://github.com/medusajs/medusa/pull/3187) [`f97b3d7cc`](https://github.com/medusajs/medusa/commit/f97b3d7ccee381d3491337ab5144bb44520382a7) Thanks [@fPolic](https://github.com/fPolic)! - feat(medusa, cache-redis, cache-inmemory): Added cache modules
|
||||
|
||||
- Updated dependencies [[`121b42acf`](https://github.com/medusajs/medusa/commit/121b42acfe98c12dd593f9b1f2072ff0f3b61724), [`aa690beed`](https://github.com/medusajs/medusa/commit/aa690beed775646cbc86b445fb5dc90dcac087d5), [`54dcc1871`](https://github.com/medusajs/medusa/commit/54dcc1871c8f28bea962dbb9df6e79b038d56449), [`77d46220c`](https://github.com/medusajs/medusa/commit/77d46220c23bfe19e575cbc445874eb6c22f3c73)]:
|
||||
- medusa-core-utils@1.2.0-rc.0
|
||||
- medusa-interfaces@1.3.7-rc.0
|
||||
- medusa-test-utils@1.1.40-rc.0
|
||||
|
||||
## 1.2.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8c5219a31`](https://github.com/medusajs/medusa/commit/8c5219a31ef76ee571fbce84d7d57a63abe56eb0)]:
|
||||
- medusa-core-utils@1.1.39
|
||||
- medusa-interfaces@1.3.6
|
||||
|
||||
## 1.2.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`08324355a`](https://github.com/medusajs/medusa/commit/08324355a4466b017a0bc7ab1d333ee3cd27b8c4)]:
|
||||
- medusa-core-utils@1.1.38
|
||||
- medusa-interfaces@1.3.5
|
||||
|
||||
## 1.2.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#3025](https://github.com/medusajs/medusa/pull/3025) [`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2) Thanks [@adrien2p](https://github.com/adrien2p)! - fix(medusa): test, build and watch scripts
|
||||
|
||||
- Updated dependencies [[`93d0dc1bd`](https://github.com/medusajs/medusa/commit/93d0dc1bdcb54cf6e87428a7bb9b0dac196b4de2)]:
|
||||
- medusa-interfaces@1.3.4
|
||||
|
||||
## 1.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2808](https://github.com/medusajs/medusa/pull/2808) [`0a9c89185`](https://github.com/medusajs/medusa/commit/0a9c891853c4d16b553d38268a3408ca1daa71f0) Thanks [@patrick-medusajs](https://github.com/patrick-medusajs)! - chore: explicitly add devDependencies for monorepo peerDependencies
|
||||
|
||||
- Updated dependencies [[`7cced6006`](https://github.com/medusajs/medusa/commit/7cced6006a9a6f9108009e9f3e191e9f3ba1b168)]:
|
||||
- medusa-core-utils@1.1.37
|
||||
|
||||
## 1.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`c97ccd3fb`](https://github.com/medusajs/medusa/commit/c97ccd3fb5dbe796b0e4fbf37def5bb6e8201557)]:
|
||||
- medusa-interfaces@1.3.3
|
||||
|
||||
## 1.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#1914](https://github.com/medusajs/medusa/pull/1914) [`1dec44287`](https://github.com/medusajs/medusa/commit/1dec44287df5ac69b4c5769b59f9ebef58d3da68) Thanks [@fPolic](https://github.com/fPolic)! - Version bump due to missing changesets in merged PRs
|
||||
|
||||
- Updated dependencies [[`1dec44287`](https://github.com/medusajs/medusa/commit/1dec44287df5ac69b4c5769b59f9ebef58d3da68), [`b8ddb31f6`](https://github.com/medusajs/medusa/commit/b8ddb31f6fe296a11d2d988276ba8e991c37fa9b)]:
|
||||
- medusa-interfaces@1.3.2
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.2.1](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.2.0...medusa-source-shopify@1.2.1) (2022-07-05)
|
||||
|
||||
**Note:** Version bump only for package medusa-source-shopify
|
||||
|
||||
# [1.2.0](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.1.1...medusa-source-shopify@1.2.0) (2022-05-01)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- source shopify handle duplicate unique values and more efficient updates ([#1154](https://github.com/medusajs/medusa/issues/1154)) ([eb8e247](https://github.com/medusajs/medusa/commit/eb8e247e7de6ca0894eee640758748d5f21b6122))
|
||||
- source-shopify tests ([#1192](https://github.com/medusajs/medusa/issues/1192)) ([4be991c](https://github.com/medusajs/medusa/commit/4be991c15648c633f619947a38ad9fefad5b8f07))
|
||||
|
||||
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.0.5...medusa-source-shopify@1.1.1) (2022-02-28)
|
||||
|
||||
**Note:** Version bump only for package medusa-source-shopify
|
||||
|
||||
# [1.1.0](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.0.5...medusa-source-shopify@1.1.0) (2022-02-25)
|
||||
|
||||
**Note:** Version bump only for package medusa-source-shopify
|
||||
|
||||
## [1.0.5](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.0.4...medusa-source-shopify@1.0.5) (2022-02-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- release ([fc3fbc8](https://github.com/medusajs/medusa/commit/fc3fbc897fad5c8a5d3eea828ac7277fba9d70af))
|
||||
|
||||
## [1.0.4](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.0.3...medusa-source-shopify@1.0.4) (2022-02-06)
|
||||
|
||||
**Note:** Version bump only for package medusa-source-shopify
|
||||
|
||||
## [1.0.3](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.0.2...medusa-source-shopify@1.0.3) (2022-01-11)
|
||||
|
||||
**Note:** Version bump only for package medusa-source-shopify
|
||||
|
||||
## [1.0.2](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.0.1...medusa-source-shopify@1.0.2) (2021-12-29)
|
||||
|
||||
**Note:** Version bump only for package medusa-source-shopify
|
||||
|
||||
## [1.0.1](https://github.com/medusajs/medusa/compare/medusa-source-shopify@1.0.0...medusa-source-shopify@1.0.1) (2021-12-17)
|
||||
|
||||
**Note:** Version bump only for package medusa-source-shopify
|
||||
|
||||
# 1.0.0 (2021-12-08)
|
||||
|
||||
### Features
|
||||
|
||||
- medusa-source-shopify loader ([#563](https://github.com/medusajs/medusa/issues/563)) ([577bcc2](https://github.com/medusajs/medusa/commit/577bcc23d44c87b91b2b685fd4ddfc5d21a0aa47))
|
||||
@@ -1,61 +0,0 @@
|
||||
# Shopify Source
|
||||
|
||||
Migrate your products and categories from Shopify to Medusa.
|
||||
|
||||
[Medusa Website](https://medusajs.com) | [Medusa Repository](https://github.com/medusajs/medusa)
|
||||
|
||||
## Features
|
||||
|
||||
- Migrate data related to products from Shopify to Medusa.
|
||||
- Consistently keep data in sync between Shopify and Medusa.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Medusa backend](https://docs.medusajs.com/development/backend/install)
|
||||
- [Shopify account](https://shopify.dev/)
|
||||
|
||||
---
|
||||
|
||||
## How to Install
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend:
|
||||
|
||||
```bash
|
||||
npm install medusa-source-shopify
|
||||
```
|
||||
|
||||
2\. Set the following environment variable in `.env`:
|
||||
|
||||
```bash
|
||||
SHOPIFY_DOMAIN=<YOUR_SHOPIFY_DOMAIN>
|
||||
SHOPIFY_PASSWORD=<YOUR_SHOPIFY_PASSWORD>
|
||||
```
|
||||
|
||||
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
|
||||
|
||||
```js
|
||||
const plugins = [
|
||||
// ...,
|
||||
{
|
||||
resolve: 'medusa-source-shopify',
|
||||
options: {
|
||||
domain: process.env.SHOPIFY_DOMAIN,
|
||||
password: process.env.SHOPIFY_PASSWORD
|
||||
}
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test the Plugin
|
||||
|
||||
1\. Run the following command in the directory of the Medusa backend to run the backend:
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
2\. The data migration runs on server start-up. You should see your Shopify products in Medusa.
|
||||
@@ -1,6 +0,0 @@
|
||||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
transform: {
|
||||
"^.+\\.[jt]s?$": `../../jest-transformer.js`,
|
||||
},
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"name": "medusa-source-shopify",
|
||||
"version": "1.2.9",
|
||||
"description": "Source plugin that allows users to import products from a Shopify store",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa",
|
||||
"directory": "packages/medusa-source-shopify"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"author": "Kasper Fabrcius Kristensen <kasper@medusa-commerce.com>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"prepare": "cross-env NODE_ENV=production yarn run build",
|
||||
"test": "jest --passWithNoTests src",
|
||||
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
|
||||
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"medusa-interfaces": "^1.3.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.15.4",
|
||||
"@medusajs/utils": "^1.10.5",
|
||||
"@shopify/shopify-api": "^1.4.1",
|
||||
"axios": "^0.21.4",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"ioredis": "^4.27.9",
|
||||
"lodash": "^4.17.21",
|
||||
"medusa-core-utils": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.15.4",
|
||||
"@babel/core": "^7.15.5",
|
||||
"@babel/node": "^7.15.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
||||
"@babel/plugin-transform-instanceof": "^7.14.5",
|
||||
"@babel/plugin-transform-runtime": "^7.15.0",
|
||||
"@babel/preset-env": "^7.15.6",
|
||||
"@babel/register": "^7.15.3",
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"client-sessions": "^0.8.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-interfaces": "^1.3.7",
|
||||
"medusa-test-utils": "^1.1.40"
|
||||
},
|
||||
"gitHead": "cd1f5afa5aa8c0b15ea957008ee19f1d695cbd2e",
|
||||
"keywords": [
|
||||
"medusa-plugin",
|
||||
"medusa-plugin-source"
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
export default async (container, options) => {
|
||||
try {
|
||||
const shopifyService = container.resolve("shopifyService")
|
||||
await shopifyService.importShopify()
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user