You are here

interface PaymentOptionsBuilderInterface in Commerce Core 8.2

Builds payment options for an order.

Hierarchy

Expanded class hierarchy of PaymentOptionsBuilderInterface

All classes that implement PaymentOptionsBuilderInterface

2 files declare their use of PaymentOptionsBuilderInterface
PaymentAddForm.php in modules/payment/src/Form/PaymentAddForm.php
PaymentInformation.php in modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentInformation.php

File

modules/payment/src/PaymentOptionsBuilderInterface.php, line 10

Namespace

Drupal\commerce_payment
View source
interface PaymentOptionsBuilderInterface {

  /**
   * Builds the payment options for the given order's payment gateways.
   *
   * The payment options will be derived from the given payment gateways
   * in the following order:
   * 1) The customer's stored payment methods.
   * 2) The order's payment method (if not added in the previous step).
   * 3) Options to create new payment methods of valid types.
   * 4) Options for the remaining gateways (off-site, manual, etc).
   *
   * @param \Drupal\commerce_order\Entity\OrderInterface $order
   *   The order.
   * @param \Drupal\commerce_payment\Entity\PaymentGatewayInterface[] $payment_gateways
   *   The payment gateways. When empty, defaults to all available gateways.
   *
   * @return \Drupal\commerce_payment\PaymentOption[]
   *   The payment options, keyed by option ID.
   */
  public function buildOptions(OrderInterface $order, array $payment_gateways = []);

  /**
   * Selects the default payment option for the given order.
   *
   * Priority:
   * 1) The order's payment method
   * 2) The order's payment gateway (if it does not support payment methods)
   * 3) First defined option.
   *
   * @param \Drupal\commerce_order\Entity\OrderInterface $order
   *   The order.
   * @param array $options
   *   The options.
   *
   * @return \Drupal\commerce_payment\PaymentOption
   *   The selected option.
   */
  public function selectDefaultOption(OrderInterface $order, array $options);

}

Members

Namesort descending Modifiers Type Description Overrides
PaymentOptionsBuilderInterface::buildOptions public function Builds the payment options for the given order's payment gateways. 1
PaymentOptionsBuilderInterface::selectDefaultOption public function Selects the default payment option for the given order. 1