Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RefundDataBuilder.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Payment\Helper\Formatter;
13 
15 {
16  use Formatter;
17 
21  private $subjectReader;
22 
28  public function __construct(SubjectReader $subjectReader)
29  {
30  $this->subjectReader = $subjectReader;
31  }
32 
39  public function build(array $buildSubject)
40  {
41  $paymentDO = $this->subjectReader->readPayment($buildSubject);
42 
44  $payment = $paymentDO->getPayment();
45 
46  $amount = null;
47  try {
48  $amount = $this->formatPrice($this->subjectReader->readAmount($buildSubject));
49  } catch (\InvalidArgumentException $e) {
50  // pass
51  }
52 
53  /*
54  * we should remember that Payment sets Capture txn id of current Invoice into ParentTransactionId Field
55  * We should also support previous implementations of Magento Braintree -
56  * and cut off '-capture' postfix from transaction ID to support backward compatibility
57  */
58  $txnId = str_replace(
60  '',
61  $payment->getParentTransactionId()
62  );
63 
64  return [
65  'transaction_id' => $txnId,
67  ];
68  }
69 }
$amount
Definition: order.php:14
$payment
Definition: order.php:17