How do i update the price OR add a custom discount to an existing order?

New Member
1 0 0

Hello to you all!

i am developing a custom app to manage bundles.
Basically the idea is that once an order is received, if there is a "bundle-product" in it, i replace it with all the products contained in the bundle itself.
So for example, if I have configured a bundleX with productA and productB, i basically removed bundleX from the line-items and add productA and productB.
it all works great, except for the total!!

Main problem is: if bundleX costs 20$, and productA / productB costs 13$, once i do the changes my final order's price is 26$, so it's like the customer owns me 6$!!
What i am trying to achieve is to keep the total at the original cost of the bundleX (20$ in this example), so i either need to modify the total of the order or to apply a custom discount to it.

I cannot find a way by using REST nor GRAPHQL to achieve what i need. 
Any help would be really blessed!
thanks in advance.