@reactionary/medusa 0.10.6 → 0.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,10 @@ class MedusaProductAssociationsCapability extends ProductAssociationsCapability
17
17
  config;
18
18
  medusa;
19
19
  factory;
20
+ alwaysIncludedFields = [
21
+ "+metadata",
22
+ "+external_id"
23
+ ];
20
24
  constructor(config, cache, context, medusa, factory) {
21
25
  super(cache, context);
22
26
  this.config = config;
@@ -29,7 +33,7 @@ class MedusaProductAssociationsCapability extends ProductAssociationsCapability
29
33
  external_id: productKey.key,
30
34
  limit: 1,
31
35
  offset: 0,
32
- fields: "metadata.*,external_id"
36
+ fields: this.alwaysIncludedFields.join(",")
33
37
  });
34
38
  let product;
35
39
  if (!productResponse.products || productResponse.products.length === 0)
@@ -39,6 +43,7 @@ class MedusaProductAssociationsCapability extends ProductAssociationsCapability
39
43
  if (!product) {
40
44
  return [];
41
45
  }
46
+ console.log("Product metadata:", product.metadata);
42
47
  const associationsMetadata = (product.metadata?.[attributeName] || "").split(";");
43
48
  if (!associationsMetadata || associationsMetadata.length === 0 || associationsMetadata[0] === "") {
44
49
  return [];
@@ -30,7 +30,7 @@ class MedusaProductCapability extends ProductCapability {
30
30
  medusaApi;
31
31
  config;
32
32
  alwaysIncludedFields = [
33
- "+metadata.*",
33
+ "+metadata",
34
34
  "+categories.external_id",
35
35
  "+external_id"
36
36
  ];
@@ -79,7 +79,7 @@ class MedusaCheckoutFactory {
79
79
  if (!shippingInstruction) return false;
80
80
  if (!shippingAddress && !shippingInstruction.pickupPoint) return false;
81
81
  if (paymentInstructions.length === 0) return false;
82
- const authorizedPayments = paymentInstructions.filter((paymentInstruction) => paymentInstruction.status === "authorized").map((paymentInstruction) => paymentInstruction.amount.value).reduce((sum, value) => sum + value, 0);
82
+ const authorizedPayments = paymentInstructions.filter((paymentInstruction) => paymentInstruction.status === "authorized" || paymentInstruction.status === "captured").map((paymentInstruction) => paymentInstruction.amount.value).reduce((sum, value) => sum + value, 0);
83
83
  if (price.grandTotal.value !== authorizedPayments) return false;
84
84
  return true;
85
85
  }
@@ -230,9 +230,16 @@ class MedusaCheckoutFactory {
230
230
  status = "canceled";
231
231
  break;
232
232
  case "completed":
233
- status = "capture";
233
+ status = "captured";
234
234
  break;
235
235
  }
236
+ if (remotePayment.refunded_amount && remotePayment.refunded_amount > 0) {
237
+ if (remotePayment.refunded_amount === remotePayment.captured_amount) {
238
+ status = "refunded";
239
+ } else {
240
+ status = "partial_refunded";
241
+ }
242
+ }
236
243
  const paymentData = mainSession.data || {};
237
244
  const pi = {
238
245
  identifier: {
@@ -118,9 +118,16 @@ class MedusaOrderFactory {
118
118
  status = "canceled";
119
119
  break;
120
120
  case "completed":
121
- status = "capture";
121
+ status = "captured";
122
122
  break;
123
123
  }
124
+ if (remotePayment.refunded_amount && remotePayment.refunded_amount > 0) {
125
+ if (remotePayment.refunded_amount === remotePayment.captured_amount) {
126
+ status = "refunded";
127
+ } else {
128
+ status = "partial_refunded";
129
+ }
130
+ }
124
131
  const paymentData = mainSession.data || {};
125
132
  const pi = {
126
133
  identifier: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/medusa",
3
- "version": "0.10.6",
3
+ "version": "0.10.8",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@medusajs/js-sdk": "^2.13.3",
13
- "@reactionary/core": "0.10.6",
13
+ "@reactionary/core": "0.10.8",
14
14
  "debug": "^4.4.3",
15
15
  "@medusajs/types": "^2.13.3",
16
16
  "zod": "4.1.9"
@@ -7,6 +7,7 @@ export declare class MedusaProductAssociationsCapability<TFactory extends Produc
7
7
  protected config: MedusaConfiguration;
8
8
  protected medusa: MedusaAPI;
9
9
  protected factory: ProductAssociationsFactoryWithOutput<TFactory>;
10
+ protected alwaysIncludedFields: string[];
10
11
  constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusa: MedusaAPI, factory: ProductAssociationsFactoryWithOutput<TFactory>);
11
12
  protected fetchAssociatedProductsFor(productKey: ProductIdentifier, maxNumberOfAssociations: number, attributeName: string): Promise<import("@medusajs/types").StoreProduct[]>;
12
13
  getAccessories(query: ProductAssociationsGetAccessoriesQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
@@ -50,7 +50,7 @@ export declare class MedusaCheckoutFactory<TCheckoutSchema extends AnyCheckoutSc
50
50
  key: string;
51
51
  value: string;
52
52
  }[];
53
- status: "pending" | "authorized" | "canceled" | "capture";
53
+ status: "pending" | "authorized" | "canceled" | "captured" | "refunded" | "partial_refunded";
54
54
  } | undefined;
55
55
  parsePaymentMethod(_context: RequestContext, data: StorePaymentProvider): z.output<TPaymentMethodSchema>;
56
56
  }
@@ -38,6 +38,6 @@ export declare class MedusaOrderFactory<TOrderSchema extends AnyOrderSchema = ty
38
38
  key: string;
39
39
  value: string;
40
40
  }[];
41
- status: "pending" | "authorized" | "canceled" | "capture";
41
+ status: "pending" | "authorized" | "canceled" | "captured" | "refunded" | "partial_refunded";
42
42
  } | undefined;
43
43
  }