Disable the Reserve, Charge, Cancel payment and Return payment buttons
You can enable and disable the these buttons from the payment provider implementation logic.
In the Payments view in back office, there are four buttons to execute operations on the selected payment, Reserve, Charge, Cancel payment and Return payment. However, certain payment methods might not allow some of these operations. For example, a bank direct payment might not support the reserve operation, and an invoice method might not support the return operation.
The following properties in the IPaymentProvider interface defines whether a certain comman button in the menu bar is enabled or not.
- Reserve: IPaymentProvider.CanReserveMoneyFromCustomerAccount
- Charge: IPaymentProvider.CanChargeCustomerAccountDirectly and IPaymentProvider.CanCompleteCurrentTransaction
- Cancel payment: IPaymentProvider.CanCancelCurrentTransaction
- Return payment: IPaymentProvider.CanReturnPayment

By default, these properties are implemented in the PaymentProviderBase class. The default implementation guarantees that the payment status is correct for a given operation. For example, a payment cannot be Returned if it is not yet Paid, therefore, the Return button is enabled only if the payment status is Paid.
This is the default implementation:
- Reserve: Enabled only if the payment status is Init or ChargeFailed or ReserveFailed.
- Charge: Enabled only if the payment status is Init or ChargeFailed or ReserveFailed, or, in a reserve mode payment, if CanCompleteCurrentTransaction is true. CanCompleteCurrentTransaction is by default set to true if the payment status is Reserved or CaptureFailed.
- Cancel payment: Enabled only if the payment status is Reserved or CaptureFailed.
- Return payment: Enabled only if the payment status is Paid or ReturnFailed.
Changing the default behaviour
Suppose that returning money is not supported when paid through a certain payment method. In this case, the default behaviour should be overridden to disbale the Return button.
/// <summary>
/// Gets a value indicating whether payment can be refunded.
/// </summary>
public override bool CanReturnPayment
{
get
{
//call the base implementation first to determine whether payment is in correct state
//additionally check whether current payment method is supporting refunding or not.
//For this example, we assume there is a payment method called "NoRefund",
//and when paid from it return button is disabled.
return base.CanReturnPayment && PaymentInfo.PaymentMethod != PaymentMethod.NoRefund.ToString();
}
}