PledgePayment statuses used doesn't correspond to reported options available.
When using the API (v3 or v4) a pledgepayment status accepts either "Completed", "Pending", "Cancelled" or "Overdue":
However, in practice a wider set of values are supported. To demonstrate this:
- Create a new pledge
- Mark a payment against the first pledge
- View the created pledge payment. Click edit and set the payment contribution status to "Refunded". Save the payment.
- The pledge payment now has a status of "Refunded" which was not one of the statuses shown by the API explorer.
Looking at the config for a pledgepayment I can see that the status field uses the contribution_status
pseudoconstant. However, in CRM_Pledge_BAO_PledgePayment::buildOptions
the options are retrieved from CRM_Pledge_BAO_Pledge::buildOptions
which uses the pledge_status
pseudoconstant.
I highly suspect CRM_Pledge_BAO_PledgePayment::buildOptions
should just return the contribution_status
options, maybe with some of the less relevant options filtered out. It seems mad that internal Civi logic would put a pledgepayment into a state which isn't shown as valid through the API.
It appears the available options are not validated, so if you hand-build the API query it does seem to be possible to use a pledgepayment/contribution_status which does not correspond to one of "Completed", "Pending", "Cancelled" or "Overdue".