@mattwire so my expectation is that the Payment.create api will not change the contribution total - ie we have an order, we pay too much for it - it doesn't change the value of the order it just means we've overpaid (& are probably due a credit). Ideally if you want to change the Order you would use the order api (hopefully it works for that but likely has gaps) or the line item editor.
I agree the status contribution should change. I'm not sure what to.
There is something a bit odd with 'Partially refunded' it implies that a refund became due and was issued in part. In fact you could get a scenario where
I order a cart of events
I pay with a card payment & some cash. The payment is added. It changes to 'Completed'
I come back & say 'OMG please give me the cash back, I'll pay the rest by card'
A refund of the cash payment is added - at this point the right status IMHO is 'Partially Paid' because the finally goal is still to Pay it & for it to be completed.
'Partially refunded' makes sense to me when I cancel the event & it's now 'pending refund' & my cash is returned to me - it's partially refunded because the end goal is 'refunded' (although sometimes partially refunded IS the end goal - sigh).
Although "Currently, viewing a contribution, either in the summary or detail gives no indication of the actual amount paid:" - yes we should show the total paid
Rather than another status - which I know causes @JoeMurray nightmares :-) I think leave it completed but update the UI - perhaps the UI could have something that shows up if the total contribution != the total paid?
We at AGH are in the process of building out the TSYS payment processor integration to issue partial refunds. I am trying to get up to speed on the latest core plans...ideas...schemes... etc. for refunding (this seems to be one of the more recent tickets regarding refunds).
We have been working towards a UI where when viewing a contribution each payment that is eligible to be refunded in TSYS includes a "refund" link next to the edit pencil like in the screenshot below:
When one clicks the refund button they are taken to a form where they can enter the amount to be refunded (the full amount or part of it). On submit of that form the refund is processed in TSYS and the 'Payment.create' api is called using a negative amount to record the refund in CiviCRM. Mostly this is working but we have run into some hurdles like not being able to update a "Completed" contribution status to "Partially Paid" when only refunding part of the contribution which it looks like was discussed in #103 and some other inconsistencies in how the api functions when recording/cancelling/refunding payments (which I will document in a related issue).
Mostly I am commenting to say we would love to help move the ball forward on improving the partial refund workflow.
@alicefrumin Great :-) Did you find the same issue as above where "The Financial Type should be displayed correctly for the refund payment." If you are able to work out why that is happening and do a core PR that would be awesome and I'll certainly put the time in to review.
Moving this forward (and #103) requires lot's of little changes and some agreement about how things should work along the way. And some time :-)
I did some digging on the financial type not showing up for refunds created using Payment.create. I think it boils down to Payment.create not creating a financial item as Eileen suggests. It looks to me like this is intentional based on this issue https://github.com/civicrm/civicrm-core/pull/15143.
More details below:
It looks to me like the Payment Info displayed in the Payment Details table is pulled using this query, name being the financial type, it pulls the Financial Type from the related Financial Item (connected by an civicrm_entity_financial_trxn entry). However, there is no financial_item created when a refund is created using Payment.create, just a financial_transaction (this is discussed here: https://github.com/civicrm/civicrm-core/pull/15143).
I note this comment in there "!! this same should happen for a negative payment although the allocation may be different. There may be a current bug here." - if you think it's wrong then I'd start with a PR to the docs page proposing how it 'should' be