How do I refund a payment?
Call refundPayment from your backend (or use the Refund action on the user's page in the console). By default it refunds the full remaining balance and moves the payment to REFUNDED; pass refundAmountCents (or use the Partial refund option in the console) to refund part of it, which leaves the payment PARTIALLY_REFUNDED and still refundable. Only COMPLETED or PARTIALLY_REFUNDED payments qualify, and there is no client-side route — end users can't refund themselves.
Revoke whatever the payment granted before you refund: refunds you initiate don't fire a trigger back into your system.