You are here

public function PurchaseOrderGateway::voidPayment in Commerce Purchase Order 8

Voids the given payment.

Parameters

\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment to void.

Throws

\Drupal\commerce_payment\Exception\PaymentGatewayException Thrown when the transaction fails for any reason.

Overrides SupportsVoidsInterface::voidPayment

File

src/Plugin/Commerce/PaymentGateway/PurchaseOrderGateway.php, line 177

Class

PurchaseOrderGateway
Provides the On-site payment gateway.

Namespace

Drupal\commerce_purchase_order\Plugin\Commerce\PaymentGateway

Code

public function voidPayment(PaymentInterface $payment) {
  $this
    ->assertPaymentState($payment, [
    'completed',
  ]);
  $payment->state = 'voided';
  $payment
    ->save();
}