Payments are entities, so there are several CRUD operations that can be performed by default. In addition to that, there are payment processing related operations:
- cancel
- refund (#1936210: Refund support)
- capture
- more?

See if we can let payment methods provide operations and combine them with existing entity operations.

CommentFileSizeAuthor
#5 payment_1980392_5.patch28.91 KBxano

Comments

xano’s picture

xano’s picture

Version: 7.x-1.x-dev » 8.x-2.x-dev
Status: Postponed » Active
xano’s picture

As we have a number of different operations, and more may be added by payment method plugins, these should be dynamic. In order to let plugins provide them, add the following three methods:

\Drupal\payment\PaymentProcessingInterface::paymentOperations()
Returns operations names and labels.
\Drupal\payment\PaymentProcessingInterface::paymentOperationAccess(PaymentInterface $payment, $operation)
Checks if an operation can be performed on a payment.
\Drupal\payment\PaymentProcessingInterface::executePaymentOperation(PaymentInterface $payment, $operation)
Performs the operation after calling paymentOperationAccess() first.

This will replace PaymentProcessingInterface::validatePayment(), PaymentProcessingInterface::executePayment(), Payment::execute(), and part of Payment::validate().

The future PaymentListController::getOperations() can then call Payment::getPaymentMethod()->getPlugin()->paymentOperations() and merge those with the default entity operations for use in the UI later on.

xano’s picture

Note that this also replaces hook_payment_validate() and the corresponding Rules event. Next to that, operations should have a flag to indicate whether or not they need a permission to be generated for them.

xano’s picture

Status: Active » Fixed
StatusFileSize
new28.91 KB
xano’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.