public function Manual::buildPaymentOperations in Commerce Core 8.2
Builds the available operations for the given payment.
Parameters
\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment.
Return value
array The operations. Keyed by operation ID, each value is an array with the following keys:
- title: The operation title.
- page_title: The operation page title.
- plugin_form: The plugin form ID.
- access: Whether the operation is allowed for the given payment.
Overrides PaymentGatewayBase::buildPaymentOperations
File
- modules/
payment/ src/ Plugin/ Commerce/ PaymentGateway/ Manual.php, line 159
Class
- Manual
- Provides the Manual payment gateway.
Namespace
Drupal\commerce_payment\Plugin\Commerce\PaymentGatewayCode
public function buildPaymentOperations(PaymentInterface $payment) {
$payment_state = $payment
->getState()
->getId();
$operations = [];
$operations['receive'] = [
'title' => $this
->t('Receive'),
'page_title' => $this
->t('Receive payment'),
'plugin_form' => 'receive-payment',
'access' => $payment_state == 'pending',
];
$operations['void'] = [
'title' => $this
->t('Void'),
'page_title' => $this
->t('Void payment'),
'plugin_form' => 'void-payment',
'access' => $payment_state == 'pending',
];
$operations['refund'] = [
'title' => $this
->t('Refund'),
'page_title' => $this
->t('Refund payment'),
'plugin_form' => 'refund-payment',
'access' => in_array($payment_state, [
'completed',
'partially_refunded',
]),
];
return $operations;
}