Notifications about Deleting External Payment from Order Added to API V8
v8
When attempting to delete an external payment, the method OnPaymentDeleting of the corresponding IPaymentProcessor is called.
Some payment systems require processing the payment in an external system before paying for the order in Syrve, which creates a time gap when the payment has already been processed in the external system, but not yet in Syrve. Previously, a user could delete such a payment without any trace, and since this payment was considered unprocessed in Syrve, it was deleted without cancellation, leading to erroneous extra transactions in the external system.
Now, the payment processor in the OnPaymentDeleting method can, at its discretion:
- do nothing — if the payment has not yet been processed and does not require any actions upon deletion,
- cancel the payment in the external system,
- prohibit the deletion of the payment in Syrve by generating one of the exceptions:
PaymentActionCancelledException— cancellation of deletion without additional messages (for example, if the plugin previously showed a question and the user chose to cancel),PaymentActionFailedException— prohibition of deletion with an error message displayed (for example, if it was not possible to cancel the payment in the external system).
Currently, this only works in the case of attempting to delete from the payment screen. The call to the OnPaymentDeleting method when deleting a payment via the API (DeleteExternalPaymentItem) will be implemented later.