Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CaptureDataBuilder.php
Go to the documentation of this file.
1 <?php
7 
11 use Magento\Payment\Helper\Formatter;
12 
17 {
18  use Formatter;
19 
20  const TRANSACTION_ID = 'transaction_id';
21 
25  private $subjectReader;
26 
32  public function __construct(SubjectReader $subjectReader)
33  {
34  $this->subjectReader = $subjectReader;
35  }
36 
40  public function build(array $buildSubject)
41  {
42  $paymentDO = $this->subjectReader->readPayment($buildSubject);
43 
44  $payment = $paymentDO->getPayment();
45 
46  $transactionId = $payment->getCcTransId();
47  if (!$transactionId) {
48  throw new LocalizedException(__('No authorization transaction to proceed capture.'));
49  }
50 
51  return [
52  self::TRANSACTION_ID => $transactionId,
53  PaymentDataBuilder::AMOUNT => $this->formatPrice($this->subjectReader->readAmount($buildSubject))
54  ];
55  }
56 }
__()
Definition: __.php:13
$payment
Definition: order.php:17