fix: allow passing idempotency key to service layer create (#2701)
**What** Allow DraftOrders to be created with an IdempotencyKey. Note this doesn't implement idempotency for the DraftOrder create endpoint but allows the service layer to ingest the key and store it in the database. This is a preliminary step to being able to support an idempotent API request.
This commit is contained in:
1 parent
0764c6f994
commit
198fe78c13
3 files changed
+14
-2
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): allow passing idempotency key to service layer create
|
||||||
@@ -259,8 +259,13 @@ class DraftOrderService extends TransactionBaseService {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { shipping_methods, no_notification_order, items, ...rawCart } =
|
const {
|
||||||
data
|
shipping_methods,
|
||||||
|
no_notification_order,
|
||||||
|
items,
|
||||||
|
idempotency_key,
|
||||||
|
...rawCart
|
||||||
|
} = data
|
||||||
|
|
||||||
const cartServiceTx =
|
const cartServiceTx =
|
||||||
this.cartService_.withTransaction(transactionManager)
|
this.cartService_.withTransaction(transactionManager)
|
||||||
@@ -285,6 +290,7 @@ class DraftOrderService extends TransactionBaseService {
|
|||||||
const draftOrder = draftOrderRepo.create({
|
const draftOrder = draftOrderRepo.create({
|
||||||
cart_id: createdCart.id,
|
cart_id: createdCart.id,
|
||||||
no_notification_order,
|
no_notification_order,
|
||||||
|
idempotency_key,
|
||||||
})
|
})
|
||||||
const result = await draftOrderRepo.save(draftOrder)
|
const result = await draftOrderRepo.save(draftOrder)
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export type DraftOrderCreateProps = {
|
|||||||
no_notification_order?: boolean
|
no_notification_order?: boolean
|
||||||
shipping_methods: ShippingMethod[]
|
shipping_methods: ShippingMethod[]
|
||||||
metadata?: Record<string, unknown>
|
metadata?: Record<string, unknown>
|
||||||
|
idempotency_key?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShippingMethod = {
|
type ShippingMethod = {
|
||||||
|
|||||||
Reference in new issue
Block a user