Implement payment modification API

This implements:

- capture payment
- cancel payment
- refund payment
- cancel or refund payment

Also some bugfixes and cleanup in the authorise payment API.