/**
  * {@inheritdoc}
  */
 public function viewElements(FieldItemListInterface $items, $langcode)
 {
     $payment_line_items = new LineItemCollection();
     /** @var \Drupal\plugin\Plugin\Field\FieldType\PluginCollectionItemInterface $item */
     foreach ($items as $delta => $item) {
         $payment_line_items->setLineItem($item->getContainedPluginInstance());
     }
     $entity = $items->getEntity();
     if ($entity instanceof LineItemCollectionInterface) {
         $payment_line_items->setCurrencyCode($entity->getCurrencyCode());
     }
     $build[0] = array('#payment_line_items' => $payment_line_items, '#type' => 'payment_line_items_display');
     return $build;
 }
 /**
  * @covers ::getCurrencyCode
  * @covers ::setCurrencyCode
  */
 public function testGetCurrencyCode()
 {
     $currency_code = $this->randomMachineName();
     $this->assertSame($this->sut, $this->sut->setCurrencyCode($currency_code));
     $this->assertSame($currency_code, $this->sut->getCurrencyCode());
 }