Database

[{type:"out",user:"id1",orderPayment:[{_id:"id1",paid:true,paymentSum:40},{_id:"id2",paid:true,paymentSum:60,},{_id:"id3",paid:false,paymentSum:50,}]},{type:"in",user:"id1",orderPayment:[{_id:"id1",paid:true,paymentSum:10},{_id:"id2",paid:true,paymentSum:10,},{_id:"id3",paid:false,paymentSum:77,}]}]

Query

db.collection.aggregate([{"$unwind":"$orderPayment"},{"$group":{"_id":"$type","paid":{"$sum":{$cond:{if:{$eq:["$orderPayment.paid",true]},then:"$orderPayment.paymentSum",else:0}}},"noPaid":{"$sum":{$cond:{if:{$eq:["$orderPayment.paid",false]},then:"$orderPayment.paymentSum",else:0}}}}}])

Result