@reactionary/medusa 0.9.25 → 0.9.27
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.
|
@@ -72,6 +72,20 @@ class MedusaCheckoutFactory {
|
|
|
72
72
|
region: ""
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
+
isReadyForFinalization(price, paymentInstructions, billingAddress, shippingAddress, shippingInstruction) {
|
|
76
|
+
if (!billingAddress)
|
|
77
|
+
return false;
|
|
78
|
+
if (!shippingInstruction)
|
|
79
|
+
return false;
|
|
80
|
+
if (!shippingAddress && !shippingInstruction.pickupPoint)
|
|
81
|
+
return false;
|
|
82
|
+
if (paymentInstructions.length === 0)
|
|
83
|
+
return false;
|
|
84
|
+
const authorizedPayments = paymentInstructions.filter((paymentInstruction) => paymentInstruction.status === "authorized").map((paymentInstruction) => paymentInstruction.amount.value).reduce((sum, value) => sum + value, 0);
|
|
85
|
+
if (price.grandTotal.value !== authorizedPayments)
|
|
86
|
+
return false;
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
75
89
|
parseCheckout(context, data) {
|
|
76
90
|
const identifier = {
|
|
77
91
|
key: data.id
|
|
@@ -161,6 +175,13 @@ class MedusaCheckoutFactory {
|
|
|
161
175
|
display_id: Number(data.metadata?.["order_display_id"] + "" || "0")
|
|
162
176
|
};
|
|
163
177
|
}
|
|
178
|
+
const readyForFinalization = this.isReadyForFinalization(
|
|
179
|
+
price,
|
|
180
|
+
paymentInstructions,
|
|
181
|
+
billingAddress,
|
|
182
|
+
shippingAddress,
|
|
183
|
+
shippingInstruction
|
|
184
|
+
);
|
|
164
185
|
const result = {
|
|
165
186
|
identifier,
|
|
166
187
|
name,
|
|
@@ -169,7 +190,7 @@ class MedusaCheckoutFactory {
|
|
|
169
190
|
items,
|
|
170
191
|
originalCartReference,
|
|
171
192
|
paymentInstructions,
|
|
172
|
-
readyForFinalization
|
|
193
|
+
readyForFinalization,
|
|
173
194
|
billingAddress,
|
|
174
195
|
resultingOrder,
|
|
175
196
|
shippingAddress,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/medusa",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@medusajs/js-sdk": "^2.13.3",
|
|
9
|
-
"@reactionary/core": "0.9.
|
|
9
|
+
"@reactionary/core": "0.9.27",
|
|
10
10
|
"debug": "^4.4.3",
|
|
11
11
|
"@medusajs/types": "^2.13.3",
|
|
12
12
|
"zod": "4.1.9"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoreCart, StoreCartAddress, StoreCartLineItem, StoreCartShippingOptionWithServiceZone, StorePaymentProvider } from '@medusajs/types';
|
|
2
|
-
import { type Address, type AnyCheckoutSchema, type AnyPaymentMethodSchema, type AnyShippingMethodSchema, type CheckoutFactory, type CheckoutItem, type CheckoutSchema, type CostBreakDown, type Currency, type ItemCostBreakdown, type PaymentMethodSchema, type RequestContext, type ShippingMethodSchema } from '@reactionary/core';
|
|
2
|
+
import { type Address, type AnyCheckoutSchema, type AnyPaymentMethodSchema, type AnyShippingMethodSchema, type CheckoutFactory, type CheckoutItem, type CheckoutSchema, type CostBreakDown, type Currency, type ItemCostBreakdown, type PaymentInstruction, type PaymentMethodSchema, type RequestContext, type ShippingInstruction, type ShippingMethodSchema } from '@reactionary/core';
|
|
3
3
|
import type * as z from 'zod';
|
|
4
4
|
export declare class MedusaCheckoutFactory<TCheckoutSchema extends AnyCheckoutSchema = typeof CheckoutSchema, TShippingMethodSchema extends AnyShippingMethodSchema = typeof ShippingMethodSchema, TPaymentMethodSchema extends AnyPaymentMethodSchema = typeof PaymentMethodSchema> implements CheckoutFactory<TCheckoutSchema, TShippingMethodSchema, TPaymentMethodSchema> {
|
|
5
5
|
readonly checkoutSchema: TCheckoutSchema;
|
|
@@ -32,6 +32,7 @@ export declare class MedusaCheckoutFactory<TCheckoutSchema extends AnyCheckoutSc
|
|
|
32
32
|
* @returns
|
|
33
33
|
*/
|
|
34
34
|
protected parseAddress(_context: RequestContext, storeAddress: StoreCartAddress): Address;
|
|
35
|
+
protected isReadyForFinalization(price: CostBreakDown, paymentInstructions: PaymentInstruction[], billingAddress?: Address, shippingAddress?: Address, shippingInstruction?: ShippingInstruction): boolean;
|
|
35
36
|
parseCheckout(context: RequestContext, data: StoreCart): z.output<TCheckoutSchema>;
|
|
36
37
|
parseShippingMethod(_context: RequestContext, data: StoreCartShippingOptionWithServiceZone): z.output<TShippingMethodSchema>;
|
|
37
38
|
parsePaymentMethod(_context: RequestContext, data: StorePaymentProvider): z.output<TPaymentMethodSchema>;
|