fix(core-flows): capture before order created (#9980)

What:
 When `autocapture` is enabled, the webhook is processed before the order was created.
 The payment processing workflows were merged into a single one
 
FIXES: SUP-118, SUP-9

https://github.com/medusajs/medusa/issues/9998
This commit is contained in:
Carlos R. L. Rodrigues
2024-11-12 13:43:48 +00:00
committed by GitHub
parent 9e40f34ba8
commit 2344012d1c
12 changed files with 136 additions and 69 deletions
@@ -1,7 +1,4 @@
import {
onPaymentProcessedWorkflow,
processPaymentWorkflow,
} from "@medusajs/core-flows"
import { processPaymentWorkflow } from "@medusajs/core-flows"
import {
IPaymentModuleService,
ProviderWebhookPayload,
@@ -29,7 +26,7 @@ export default async function paymentWebhookhandler({
const input = event.data
if (
(input.payload.rawData as unknown as SerializedBuffer).type === "Buffer"
(input.payload?.rawData as unknown as SerializedBuffer)?.type === "Buffer"
) {
input.payload.rawData = Buffer.from(
(input.payload.rawData as unknown as SerializedBuffer).data
@@ -49,11 +46,6 @@ export default async function paymentWebhookhandler({
await processPaymentWorkflow(container).run({
input: processedEvent,
})
// We process the intended side effects of payment processing separately.
await onPaymentProcessedWorkflow(container).run({
input: processedEvent,
})
}
export const config: SubscriberConfig = {