You are here

protected function PaymentProcess::createPayment in Commerce Core 8.2

Creates the payment to be processed.

Parameters

\Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway: The payment gateway in use.

Return value

\Drupal\commerce_payment\Entity\PaymentInterface The created payment.

1 call to PaymentProcess::createPayment()
PaymentProcess::buildPaneForm in modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php
Builds the pane form.

File

modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php, line 305

Class

PaymentProcess
Provides the payment process pane.

Namespace

Drupal\commerce_payment\Plugin\Commerce\CheckoutPane

Code

protected function createPayment(PaymentGatewayInterface $payment_gateway) {
  $payment_storage = $this->entityTypeManager
    ->getStorage('commerce_payment');

  /** @var \Drupal\commerce_payment\Entity\PaymentInterface $payment */
  $payment = $payment_storage
    ->create([
    'state' => 'new',
    'amount' => $this->order
      ->getBalance(),
    'payment_gateway' => $payment_gateway
      ->id(),
    'order_id' => $this->order
      ->id(),
  ]);
  return $payment;
}