public function Onsite::voidPayment in Commerce Core 8.2
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
- modules/
payment_example/ src/ Plugin/ Commerce/ PaymentGateway/ Onsite.php, line 147
Class
- Onsite
- Provides the On-site payment gateway.
Namespace
Drupal\commerce_payment_example\Plugin\Commerce\PaymentGatewayCode
public function voidPayment(PaymentInterface $payment) {
$this
->assertPaymentState($payment, [
'authorization',
]);
// Perform the void request here, throw an exception if it fails.
// See \Drupal\commerce_payment\Exception for the available exceptions.
$remote_id = $payment
->getRemoteId();
$payment
->setState('authorization_voided');
$payment
->save();
}