subjectReader = $subjectReader; } /** * Builds ENV request * * @param array $buildSubject * @return array */ public function build(array $buildSubject) { $paymentDO = $this->subjectReader->readPayment($buildSubject); /** @var Payment $payment */ $payment = $paymentDO->getPayment(); $amount = null; try { $amount = $this->formatPrice($this->subjectReader->readAmount($buildSubject)); } catch (\InvalidArgumentException $e) { // pass } /* * we should remember that Payment sets Capture txn id of current Invoice into ParentTransactionId Field * We should also support previous implementations of Magento Braintree - * and cut off '-capture' postfix from transaction ID to support backward compatibility */ $txnId = str_replace( '-' . TransactionInterface::TYPE_CAPTURE, '', $payment->getParentTransactionId() ); return [ 'transaction_id' => $txnId, PaymentDataBuilder::AMOUNT => $amount ]; } }