Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

730 B
Raw Blame
import { SubscriberArgs, SubscriberConfig } from "@medusajs/framework"
import { OrderWorkflowEvents } from "@medusajs/framework/utils"

import {
  resolveSplitOrderCartId,
  voidCanceledCartPaymentWorkflow,
} from "../workflows/payment"

export default async function splitOrderCanceledHandler({
  event,
  container,
}: SubscriberArgs<{ id: string }>) {
  const cartId = await resolveSplitOrderCartId(container, {
    order_id: event.data.id,
  })

  if (!cartId) {
    return
  }

  await voidCanceledCartPaymentWorkflow(container).run({
    input: { cart_id: cartId },
  })
}

export const config: SubscriberConfig = {
  event: OrderWorkflowEvents.CANCELED,
  context: {
    subscriberId: "mercur-split-order-canceled",
  },
}