You are here

public function Manual::createPayment in Commerce Core 8.2

Creates a payment.

Parameters

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

bool $received: Whether the payment was already received.

Overrides ManualPaymentGatewayInterface::createPayment

File

modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php, line 187

Class

Manual
Provides the Manual payment gateway.

Namespace

Drupal\commerce_payment\Plugin\Commerce\PaymentGateway

Code

public function createPayment(PaymentInterface $payment, $received = FALSE) {
  $this
    ->assertPaymentState($payment, [
    'new',
  ]);
  $payment->state = $received ? 'completed' : 'pending';
  $payment
    ->save();
}