What’s the goal here?
In the same spirit as orders, we’re going to divide a single Payment into several for each store, or to be more transparent, we’re going to create dummy payments for each store. Let me explain. The idea behind perseides is to create a marketplace with as little friction as possible with the Meudsa core. In fact, by creating dummy payments for each child order, we’ll be able to calculate the total amount available for each seller on a specific order and we will not have to update a lot of logic. An example is the refund of an order. With this system, the refund will recalculate the child payment (which will be shown to our seller), but also act on the parent payment, which will execute actions on the PaymentProcessor.Extend the entity
It’s always the same recipe when it comes to extending core features: first, you extend the entity :src/models/payment.ts
Create the migration
Once the entity has been extended, it’s time to migrate and apply our changes :src/migrations/...-add-payment-children.ts
payment_parent_id
should appear:

Override the OrderService.createRefund
function
Another important aspect concerning refunds with these child payments is that when a refund is made on a child order, the payment used to refund must be the one the parent order (the real payment) :
src/services/order.ts
Override the OrderService.capturePayment
function
In this case, we’ll make sure that when the payment for a parent order is captured, the payments for the child orders are also captured.
When we will configure the Stripe plugin, the parent payments will be captured automatically using the medusa-payment-stripe
plugin options.
But we also needs to update child order payments :
src/services/order.ts
Update the OrderPlaced subscriber
Once our Payment entity has been modified, we can update our previously created subscriber to create a Payment for each child Order created within the subscriber. Update your code with the following :src/subscribers/order-placed.ts

src/services/order.ts