Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TransactionIdHandler.php
Go to the documentation of this file.
1 <?php
7 
11 
13 {
17  private $subjectReader;
18 
23  public function __construct(
24  SubjectReader $subjectReader
25  ) {
26  $this->subjectReader = $subjectReader;
27  }
28 
36  public function handle(array $handlingSubject, array $response)
37  {
38  $paymentDO = $this->subjectReader->readPayment($handlingSubject);
39 
40  if ($paymentDO->getPayment() instanceof Payment) {
42  $transaction = $this->subjectReader->readTransaction($response);
43 
45  $orderPayment = $paymentDO->getPayment();
46  $this->setTransactionId(
47  $orderPayment,
49  );
50 
51  $orderPayment->setIsTransactionClosed($this->shouldCloseTransaction());
52  $closed = $this->shouldCloseParentTransaction($orderPayment);
53  $orderPayment->setShouldCloseParentTransaction($closed);
54  }
55  }
56 
62  protected function setTransactionId(Payment $orderPayment, \Braintree\Transaction $transaction)
63  {
64  $orderPayment->setTransactionId($transaction->id);
65  }
66 
72  protected function shouldCloseTransaction()
73  {
74  return false;
75  }
76 
84  protected function shouldCloseParentTransaction(Payment $orderPayment)
85  {
86  return false;
87  }
88 }
$transaction
$response
Definition: 404.php:11
handle(array $handlingSubject, array $response)
setTransactionId($transactionId)
Definition: Payment.php:224
setTransactionId(Payment $orderPayment, \Braintree\Transaction $transaction)