protected function PaymentGatewayBase::assertPaymentMethod in Commerce Core 8.2
Asserts that the payment method is neither empty nor expired.
Parameters
\Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method: The payment method.
Throws
\InvalidArgumentException Thrown when the payment method is empty.
\Drupal\commerce_payment\Exception\HardDeclineException Thrown when the payment method has expired.
2 calls to PaymentGatewayBase::assertPaymentMethod()
- Onsite::createPayment in modules/
payment_example/ src/ Plugin/ Commerce/ PaymentGateway/ Onsite.php - Creates a payment.
- StoredOffsiteRedirect::createPayment in modules/
payment_example/ src/ Plugin/ Commerce/ PaymentGateway/ StoredOffsiteRedirect.php - Creates a payment.
File
- modules/
payment/ src/ Plugin/ Commerce/ PaymentGateway/ PaymentGatewayBase.php, line 553
Class
- PaymentGatewayBase
- Provides the base class for payment gateways.
Namespace
Drupal\commerce_payment\Plugin\Commerce\PaymentGatewayCode
protected function assertPaymentMethod(PaymentMethodInterface $payment_method = NULL) {
if (empty($payment_method)) {
throw new \InvalidArgumentException('The provided payment has no payment method referenced.');
}
if ($payment_method
->isExpired()) {
throw new HardDeclineException('The provided payment method has expired');
}
}