Merge branch 'master' into develop

This commit is contained in:
olivermrbl
2022-11-10 19:35:57 +01:00
175 changed files with 2939 additions and 1989 deletions
@@ -1,5 +1,11 @@
# Change Log
## 1.1.47
### Patch Changes
- [#2581](https://github.com/medusajs/medusa/pull/2581) [`04e894ec3`](https://github.com/medusajs/medusa/commit/04e894ec39e1008be893a6cf313c3822a085579c) Thanks [@olivermrbl](https://github.com/olivermrbl)! - Support provider specific intent options
## 1.1.46
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-payment-stripe",
"version": "1.1.46",
"version": "1.1.47",
"description": "Stripe Payment provider for Meduas Commerce",
"main": "index.js",
"repository": {
@@ -1,5 +1,5 @@
import Stripe from "stripe"
import { AbstractPaymentService, PaymentSessionData } from "@medusajs/medusa"
import Stripe from "stripe"
class StripeBase extends AbstractPaymentService {
static identifier = null
@@ -58,6 +58,25 @@ class StripeBase extends AbstractPaymentService {
this.manager_ = manager
}
getPaymentIntentOptions() {
const options = {}
if (this?.paymentIntentOptions?.capture_method) {
options.capture_method = this.paymentIntentOptions.capture_method
}
if (this?.paymentIntentOptions?.setup_future_usage) {
options.setup_future_usage = this.paymentIntentOptions.setup_future_usage
}
if (this?.paymentIntentOptions?.payment_method_types) {
options.payment_method_types =
this.paymentIntentOptions.payment_method_types
}
return options
}
/**
* Fetches Stripe payment intent. Check its status and returns the
* corresponding Medusa status.
@@ -104,19 +123,13 @@ class StripeBase extends AbstractPaymentService {
* @return {Promise<PaymentSessionData>} Stripe payment intent
*/
async createPayment(cart) {
const intentRequest = {
payment_method_types: this.paymentMethodTypes,
capture_method: "automatic",
}
const intentRequest = this.getPaymentIntentOptions()
return await this.stripeProviderService_.createPayment(cart, intentRequest)
}
async createPaymentNew(paymentInput) {
const intentRequest = {
payment_method_types: this.paymentMethodTypes,
capture_method: "automatic",
}
const intentRequest = this.getPaymentIntentOptions()
return await this.stripeProviderService_.createPaymentNew(
paymentInput,
@@ -21,10 +21,16 @@ class BancontactProviderService extends StripeBase {
regionService,
manager,
},
options,
["bancontact"]
options
)
}
get paymentIntentOptions() {
return {
payment_method_types: ["bancontact"],
capture_method: "automatic",
}
}
}
export default BancontactProviderService
@@ -21,10 +21,16 @@ class BlikProviderService extends StripeBase {
regionService,
manager,
},
options,
["blik"]
options
)
}
get paymentIntentOptions() {
return {
payment_method_types: ["blik"],
capture_method: "automatic",
}
}
}
export default BlikProviderService
@@ -21,10 +21,16 @@ class GiropayProviderService extends StripeBase {
regionService,
manager,
},
options,
["giropay"]
options
)
}
get paymentIntentOptions() {
return {
payment_method_types: ["giropay"],
capture_method: "automatic",
}
}
}
export default GiropayProviderService
@@ -21,10 +21,16 @@ class IdealProviderService extends StripeBase {
regionService,
manager,
},
options,
["ideal"]
options
)
}
get paymentIntentOptions() {
return {
payment_method_types: ["ideal"],
capture_method: "automatic",
}
}
}
export default IdealProviderService
@@ -1,9 +1,9 @@
import Stripe from "stripe"
import {
AbstractPaymentService,
PaymentSessionData,
PaymentSessionStatus,
} from "@medusajs/medusa"
import Stripe from "stripe"
class StripeProviderService extends AbstractPaymentService {
static identifier = "stripe"
@@ -89,7 +89,7 @@ class StripeProviderService extends AbstractPaymentService {
/**
* Fetches a Stripe customer
* @param {string} customerId - Stripe customer id
* @returns {Promise<object>} Stripe customer
* @return {Promise<object>} Stripe customer
*/
async retrieveCustomer(customerId) {
if (!customerId) {
@@ -101,7 +101,7 @@ class StripeProviderService extends AbstractPaymentService {
/**
* Creates a Stripe customer using a Medusa customer.
* @param {object} customer - Customer data from Medusa
* @returns {Promise<object>} Stripe customer
* @return {Promise<object>} Stripe customer
*/
async createCustomer(customer) {
try {
@@ -144,7 +144,6 @@ class StripeProviderService extends AbstractPaymentService {
amount: Math.round(amount),
currency: currency_code,
metadata: { cart_id: `${cart.id}` },
setup_future_usage: "on_session",
capture_method: this.options_.capture ? "automatic" : "manual",
...intentRequestData,
}
@@ -183,14 +182,13 @@ class StripeProviderService extends AbstractPaymentService {
const { customer, currency_code, amount, resource_id, cart } = paymentInput
const { id: customer_id, email } = customer
let intentRequest = {
const intentRequest = {
description:
cart?.context?.payment_description ??
this.options_?.payment_description,
amount: Math.round(amount),
currency: currency_code,
metadata: { resource_id },
setup_future_usage: "on_session",
capture_method: this.options_.capture ? "automatic" : "manual",
...intentRequestData,
}
@@ -333,7 +331,7 @@ class StripeProviderService extends AbstractPaymentService {
* Updates customer of Stripe payment intent.
* @param {string} paymentIntentId - id of payment intent to update
* @param {string} customerId - id of new Stripe customer
* @returns {object} Stripe payment intent
* @return {object} Stripe payment intent
*/
async updatePaymentIntentCustomer(paymentIntentId, customerId) {
try {
@@ -408,7 +406,7 @@ class StripeProviderService extends AbstractPaymentService {
* @param {object} data - the data of the webhook request: req.body
* @param {object} signature - the Stripe signature on the event, that
* ensures integrity of the webhook event
* @returns {object} Stripe Webhook event
* @return {object} Stripe Webhook event
*/
constructWebhookEvent(data, signature) {
return this.stripe_.webhooks.constructEvent(
@@ -21,10 +21,16 @@ class Przelewy24ProviderService extends StripeBase {
regionService,
manager,
},
options,
["p24"]
options
)
}
get paymentIntentOptions() {
return {
payment_method_types: ["p24"],
capture_method: "automatic",
}
}
}
export default Przelewy24ProviderService
+6
View File
@@ -1,5 +1,11 @@
# Change Log
## 1.6.3
### Patch Changes
- [#2583](https://github.com/medusajs/medusa/pull/2583) [`699bb1d57`](https://github.com/medusajs/medusa/commit/699bb1d57bfe532a6bcff1aea7a75bc793c135cd) Thanks [@adrien2p](https://github.com/adrien2p)! - Retrieve deleted regions on orders
## 1.6.2
### Patch Changes
+14 -48
View File
@@ -14,7 +14,7 @@
</h4>
<p align="center">
An open-source composable commerce engine built for developers.
An open source composable commerce engine built for developers.
</p>
<p align="center">
<a href="https://github.com/medusajs/medusa/blob/master/LICENSE">
@@ -37,34 +37,11 @@ An open-source composable commerce engine built for developers.
## Getting Started
You can install Medusa by either following our [Quickstart guide](https://docs.medusajs.com/quickstart/quick-start) or the following steps:
1. **Install Medusa CLI**
```bash
npm install @medusajs/medusa-cli -g
```
2. **Create a new Medusa project**
```bash
medusa new my-medusa-store --seed
```
3. **Start your Medusa engine**
```bash
cd my-medusa-store
medusa develop
```
Follow our [quickstart guide](https://docs.medusajs.com/quickstart/quick-start) to learn how to set up a Medusa server.
### Requirements
- Node v14.0 or higher.
- SQLite or PostgreSQL (SQLite is only for getting started; PostgreSQL is recommended)
- Redis
You can check out [this documentation for more details about setting up your environment](https://docs.medusajs.com/tutorial/set-up-your-development-environment).
You can check out [this documentation for details about setting up your environment](https://docs.medusajs.com/tutorial/set-up-your-development-environment).
## What is Medusa
@@ -74,18 +51,11 @@ You can learn more about [Medusas architecture in our documentation](https://
### Features
- **Orders, Exchanges, and Returns APIs:** Aside from the standard order management that comes with ecommerce platforms, Medusa also provides an easy and automated way to manage swaps, returns, and claims.
- **Products and Collections APIs:** Add products with extensive customization settings and sort them into collections.
- **Region API:** Configure and manage multiple regions and currencies all from one platform.
- **Plugin API:** Easily integrate fulfillment providers, payment providers, notification services, and many other custom tools and third-party services.
- ****PriceList and Promotions APIs:**** Advanced pricing for products with conditions based on its amount in the cart or promotions and discounts.
- **Tax API:** Advanced tax configurations specific to multiple regions, with capability of specifying taxes for specific products.
See more of the [ecommerce features on our documentation](https://docs.medusajs.com/#features).
You can learn about all of the ecommerce features that Medusa provides [in our documentation](https://docs.medusajs.com/#features).
## Roadmap
Write-ups for all features will be made available in [Github discussions](https://github.com/medusajs/medusa/discussions) prior to starting the implementation process.
Write-ups for all features will be made available in [Github discussions](https://github.com/medusajs/medusa/discussions) before starting the implementation process.
### **2022**
@@ -97,24 +67,24 @@ Write-ups for all features will be made available in [Github discussions](https
- [x] Promotions API
- [x] Price Lists API
- [x] Price Selection Strategy
- [ ] Import / Export API
- [ ] Sales Channel API
- [x] Import / Export API
- [x] Sales Channel API
- [ ] Extended Order API (managing placed orders)
- [ ] PaymentCollection API (collecting payments separate from carts and draft orders)
- [ ] Multi-warehouse API
- [ ] Extended Product API (custom fields, publishing control, and more)
- [ ] Extended Order API (managing placed orders, improved inventory control, and more)
- [ ] Multi-warehouse support
- [ ] GraphQL API
## Plugins
As a headless and extendible solution, Medusa allows you to integrate third-party services or add custom features into Medusa by installing Plugins.
Check out [our available plugins](https://github.com/medusajs/medusa/tree/master/packages) that you can install and use instantly on your Medusa server.
## Contributions
Medusa is all about the community. Therefore, we would love for you to help us build the most robust and powerful commerce engine on the market.
Please check [our contribution guide](https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md) for details about how to contribute to both our codebase and our documentation.
Whether it is fixing bugs, improving our documentation or simply spreading the word, please feel free to join in. Please check [our contribution guide](https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md) for further details about how to contribute.
## Upgrade Guides
Follow our [upgrade guides](https://docs.medusajs.com/advanced/backend/upgrade-guides/) on the documentation to keep your Medusa project up-to-date.
## Community & Support
@@ -127,10 +97,6 @@ Use these channels to be part of the community, ask for help while using Medusa,
- [Twitter](https://twitter.com/medusajs)
- [LinkedIn](https://www.linkedin.com/company/medusajs)
## Upgrade Guides
Follow our [upgrade guides](https://docs.medusajs.com/advanced/backend/upgrade-guides/) on the documentation to keep your Medusa project up-to-date.
## License
Licensed under the [MIT License](https://github.com/medusajs/medusa/blob/master/LICENSE)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@medusajs/medusa",
"version": "1.6.2",
"version": "1.6.3",
"description": "E-commerce for JAMstack",
"main": "dist/index.js",
"bin": "./cli.js",
+4 -3
View File
@@ -11,7 +11,7 @@ export class OrderRepository extends Repository<Order> {
const entities = await this.find(optionsWithoutRelations)
const entitiesIds = entities.map(({ id }) => id)
const groupedRelations = {}
const groupedRelations: { [topLevel: string]: string[] } = {}
for (const rel of relations) {
const [topLevel] = rel.split(".")
if (groupedRelations[topLevel]) {
@@ -22,10 +22,11 @@ export class OrderRepository extends Repository<Order> {
}
const entitiesIdsWithRelations = await Promise.all(
Object.entries(groupedRelations).map(async ([_, rels]) => {
Object.entries(groupedRelations).map(async ([topLevel, rels]) => {
return this.findByIds(entitiesIds, {
select: ["id"],
relations: rels as string[],
relations: rels,
withDeleted: topLevel === "region",
})
})
).then(flatten)