You are here

class PaymentLineItem in Payment 7

A payment line item.

Hierarchy

Expanded class hierarchy of PaymentLineItem

See also

Payment::setLineItem()

File

./payment.classes.inc, line 1080
The API and related functions for executing and managing payments.

View source
class PaymentLineItem extends PaymentCommon {

  /**
   * The payment amount, excluding tax. The number of decimals depends on the
   * ISO 4217 currency used.
   *
   * @var float
   */
  public $amount = 0.0;

  /**
   * A US English human-readable description for this line item. May contain
   * HTML.
   *
   * @var string
   */
  public $description = '';

  /**
   * Arguments to pass on to t() when translating $this->description.
   *
   * @var string[]
   */
  public $description_arguments = array();

  /**
   * The unique machine name (for a certain payment).
   *
   * @var string
   */
  public $name = '';

  /**
   * The tax rate that applies to PaymentLineItem::amount. Should be a float
   * between 0 and 1.
   *
   * @var float
   */
  public $tax_rate = 0.0;

  /**
   * Quantity.
   *
   * @var float
   */
  public $quantity = 1.0;

  /**
   * Return this line item's unit amount.
   *
   * @param boolean $tax
   *   Whether to include taxes or not.
   *
   * @return float
   */
  function unitAmount($tax) {
    return $this->amount * ($tax ? $this->tax_rate + 1 : 1);
  }

  /**
   * Return this line item's total amount.
   *
   * @param boolean $tax
   *   Whether to include taxes or not.
   *
   * @return float
   */
  function totalAmount($tax) {
    return $this->amount * $this->quantity * ($tax ? $this->tax_rate + 1 : 1);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PaymentCommon::__construct function 2
PaymentLineItem::$amount public property The payment amount, excluding tax. The number of decimals depends on the ISO 4217 currency used.
PaymentLineItem::$description public property A US English human-readable description for this line item. May contain HTML.
PaymentLineItem::$description_arguments public property Arguments to pass on to t() when translating $this->description.
PaymentLineItem::$name public property The unique machine name (for a certain payment).
PaymentLineItem::$quantity public property Quantity.
PaymentLineItem::$tax_rate public property The tax rate that applies to PaymentLineItem::amount. Should be a float between 0 and 1.
PaymentLineItem::totalAmount function Return this line item's total amount.
PaymentLineItem::unitAmount function Return this line item's unit amount.