You are here

protected function PaymentGatewayBase::assertPaymentState in Commerce Core 8.2

Asserts that the payment state matches one of the allowed states.

Parameters

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

string[] $states: The allowed states.

Throws

\InvalidArgumentException Thrown if the payment state does not match the allowed states.

9 calls to PaymentGatewayBase::assertPaymentState()
Manual::createPayment in modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php
Creates a payment.
Manual::receivePayment in modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php
Receives the given payment.
Manual::refundPayment in modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php
Refunds the given payment.
Manual::voidPayment in modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php
Voids the given payment.
Onsite::capturePayment in modules/payment_example/src/Plugin/Commerce/PaymentGateway/Onsite.php
Captures the given authorized payment.

... See full list

File

modules/payment/src/Plugin/Commerce/PaymentGateway/PaymentGatewayBase.php, line 535

Class

PaymentGatewayBase
Provides the base class for payment gateways.

Namespace

Drupal\commerce_payment\Plugin\Commerce\PaymentGateway

Code

protected function assertPaymentState(PaymentInterface $payment, array $states) {
  $state = $payment
    ->getState()
    ->getId();
  if (!in_array($state, $states)) {
    throw new \InvalidArgumentException(sprintf('The provided payment is in an invalid state ("%s").', $state));
  }
}