How to get transaction id of an order in magento 2? The Next CEO of Stack OverflowMagento 2 - How to provide transaction?Magento 2 - Get order PayPal information programmaticallyMagento 2: unable to set payment Transaction Id after successful payment processing (solved by myself)How to send transaction email with transaction email id magento2Magento 2 - How to get order id?Magento 2 get transaction status from BraintreeMagento2 how to get the payment method title instead of payment html in new order transaction email?Import Order/Invoice/Credit Memos/ Transaction/ Comment HistoryHow order save before payment in paypal express

My boss doesn't want me to have a side project

How to pronounce fünf in 45

Calculate the Mean mean of two numbers

How to unfasten electrical subpanel attached with ramset

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Gauss' Posthumous Publications?

Compilation of a 2d array and a 1d array

Is it reasonable to ask other researchers to send me their previous grant applications?

Create custom note boxes

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

Why did early computer designers eschew integers?

Calculating discount not working

Free fall ellipse or parabola?

Is a distribution that is normal, but highly skewed, considered Gaussian?

Car headlights in a world without electricity

What did the word "leisure" mean in late 18th Century usage?

Avoiding the "not like other girls" trope?

What steps are necessary to read a Modern SSD in Medieval Europe?

Are British MPs missing the point, with these 'Indicative Votes'?

How exploitable/balanced is this homebrew spell: Spell Permanency?

Is this a new Fibonacci Identity?

Read/write a pipe-delimited file line by line with some simple text manipulation

How can I replace x-axis labels with pre-determined symbols?

How badly should I try to prevent a user from XSSing themselves?



How to get transaction id of an order in magento 2?



The Next CEO of Stack OverflowMagento 2 - How to provide transaction?Magento 2 - Get order PayPal information programmaticallyMagento 2: unable to set payment Transaction Id after successful payment processing (solved by myself)How to send transaction email with transaction email id magento2Magento 2 - How to get order id?Magento 2 get transaction status from BraintreeMagento2 how to get the payment method title instead of payment html in new order transaction email?Import Order/Invoice/Credit Memos/ Transaction/ Comment HistoryHow order save before payment in paypal express










2















How to get transaction id of order in Magento 2?










share|improve this question
























  • do you have any code that you have tried?

    – magefms
    Mar 26 at 10:09











  • I have tried this $transactionFactory = $objectManager->get('MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory'); $transactions = $transactionFactory->create()->addOrderIdFilter($_order->getId()); print_r($transactions->getItems()); but this is not working

    – Amatya Trivedi
    Mar 26 at 10:10












  • payment transaction id or order id?

    – Muhammad Anas
    Mar 26 at 11:04











  • I want payment transaction id

    – Amatya Trivedi
    Mar 26 at 11:06











  • You shouldn't use objectManager directly in your code

    – Shawn Abramson
    Mar 27 at 4:31















2















How to get transaction id of order in Magento 2?










share|improve this question
























  • do you have any code that you have tried?

    – magefms
    Mar 26 at 10:09











  • I have tried this $transactionFactory = $objectManager->get('MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory'); $transactions = $transactionFactory->create()->addOrderIdFilter($_order->getId()); print_r($transactions->getItems()); but this is not working

    – Amatya Trivedi
    Mar 26 at 10:10












  • payment transaction id or order id?

    – Muhammad Anas
    Mar 26 at 11:04











  • I want payment transaction id

    – Amatya Trivedi
    Mar 26 at 11:06











  • You shouldn't use objectManager directly in your code

    – Shawn Abramson
    Mar 27 at 4:31













2












2








2








How to get transaction id of order in Magento 2?










share|improve this question
















How to get transaction id of order in Magento 2?







magento2 magento2.2.4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 10:09







Amatya Trivedi

















asked Mar 26 at 10:02









Amatya TrivediAmatya Trivedi

389




389












  • do you have any code that you have tried?

    – magefms
    Mar 26 at 10:09











  • I have tried this $transactionFactory = $objectManager->get('MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory'); $transactions = $transactionFactory->create()->addOrderIdFilter($_order->getId()); print_r($transactions->getItems()); but this is not working

    – Amatya Trivedi
    Mar 26 at 10:10












  • payment transaction id or order id?

    – Muhammad Anas
    Mar 26 at 11:04











  • I want payment transaction id

    – Amatya Trivedi
    Mar 26 at 11:06











  • You shouldn't use objectManager directly in your code

    – Shawn Abramson
    Mar 27 at 4:31

















  • do you have any code that you have tried?

    – magefms
    Mar 26 at 10:09











  • I have tried this $transactionFactory = $objectManager->get('MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory'); $transactions = $transactionFactory->create()->addOrderIdFilter($_order->getId()); print_r($transactions->getItems()); but this is not working

    – Amatya Trivedi
    Mar 26 at 10:10












  • payment transaction id or order id?

    – Muhammad Anas
    Mar 26 at 11:04











  • I want payment transaction id

    – Amatya Trivedi
    Mar 26 at 11:06











  • You shouldn't use objectManager directly in your code

    – Shawn Abramson
    Mar 27 at 4:31
















do you have any code that you have tried?

– magefms
Mar 26 at 10:09





do you have any code that you have tried?

– magefms
Mar 26 at 10:09













I have tried this $transactionFactory = $objectManager->get('MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory'); $transactions = $transactionFactory->create()->addOrderIdFilter($_order->getId()); print_r($transactions->getItems()); but this is not working

– Amatya Trivedi
Mar 26 at 10:10






I have tried this $transactionFactory = $objectManager->get('MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory'); $transactions = $transactionFactory->create()->addOrderIdFilter($_order->getId()); print_r($transactions->getItems()); but this is not working

– Amatya Trivedi
Mar 26 at 10:10














payment transaction id or order id?

– Muhammad Anas
Mar 26 at 11:04





payment transaction id or order id?

– Muhammad Anas
Mar 26 at 11:04













I want payment transaction id

– Amatya Trivedi
Mar 26 at 11:06





I want payment transaction id

– Amatya Trivedi
Mar 26 at 11:06













You shouldn't use objectManager directly in your code

– Shawn Abramson
Mar 27 at 4:31





You shouldn't use objectManager directly in your code

– Shawn Abramson
Mar 27 at 4:31










3 Answers
3






active

oldest

votes


















1














Edit:



Try to inject MagentoSalesApiDataTransactionSearchResultInterfaceFactory into your constructor:



protected $transactions;

public function __constructor(
MagentoSalesApiDataTransactionSearchResultInterfaceFactory $transactions,
......
)

$this->transactions = $transactions;



In your method:



$transactions = $this->transactions->create()->addOrderIdFilter($orderId);
$transactions->getItems();


If MagentoSalesApiDataTransactionSearchResultInterfaceFactory doesn't work, try to use MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory. I'm not test yet both of them.






share|improve this answer

























  • This is not working.

    – Amatya Trivedi
    Mar 26 at 11:02


















0














This will work.



class MyClass

/**
* @var MagentoSalesApiTransactionRepositoryInterface
*/
private $repository;

/**
* @var MagentoFrameworkApiSearchCriteriaBuilder
*/
private $searchCriteriaBuilder;

/**
* MyClass constructor.
*
* @param MagentoSalesApiTransactionRepositoryInterface $repository
* @param MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
*/
public function __construct(
MagentoSalesApiTransactionRepositoryInterface $repository,
MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
)
$this->repository = $repository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;


/**
* @param int $id
*
* @return MagentoSalesApiDataTransactionInterface[]
*/
public function getTransactionByOrderId($id)

$this->searchCriteriaBuilder->addFilter('order_id', $id);
$list = $this->repository->getList(
$this->searchCriteriaBuilder->create()
);

return $list->getItems();







share|improve this answer






























    0














    You can use MagentoSalesApiDataTransactionSearchResultInterface for transaction Id.



    $transaction = $objectManager->create('MagentoSalesApiDataTransactionSearchResultInterfaceFactory')->create()->addOrderIdFilter($block->getOrderId())->getFirstItem();

    $transactionId = $transaction->getData('txn_id');


    The $transactionId is your required transaction Id.






    share|improve this answer








    New contributor




    Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267408%2fhow-to-get-transaction-id-of-an-order-in-magento-2%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Edit:



      Try to inject MagentoSalesApiDataTransactionSearchResultInterfaceFactory into your constructor:



      protected $transactions;

      public function __constructor(
      MagentoSalesApiDataTransactionSearchResultInterfaceFactory $transactions,
      ......
      )

      $this->transactions = $transactions;



      In your method:



      $transactions = $this->transactions->create()->addOrderIdFilter($orderId);
      $transactions->getItems();


      If MagentoSalesApiDataTransactionSearchResultInterfaceFactory doesn't work, try to use MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory. I'm not test yet both of them.






      share|improve this answer

























      • This is not working.

        – Amatya Trivedi
        Mar 26 at 11:02















      1














      Edit:



      Try to inject MagentoSalesApiDataTransactionSearchResultInterfaceFactory into your constructor:



      protected $transactions;

      public function __constructor(
      MagentoSalesApiDataTransactionSearchResultInterfaceFactory $transactions,
      ......
      )

      $this->transactions = $transactions;



      In your method:



      $transactions = $this->transactions->create()->addOrderIdFilter($orderId);
      $transactions->getItems();


      If MagentoSalesApiDataTransactionSearchResultInterfaceFactory doesn't work, try to use MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory. I'm not test yet both of them.






      share|improve this answer

























      • This is not working.

        – Amatya Trivedi
        Mar 26 at 11:02













      1












      1








      1







      Edit:



      Try to inject MagentoSalesApiDataTransactionSearchResultInterfaceFactory into your constructor:



      protected $transactions;

      public function __constructor(
      MagentoSalesApiDataTransactionSearchResultInterfaceFactory $transactions,
      ......
      )

      $this->transactions = $transactions;



      In your method:



      $transactions = $this->transactions->create()->addOrderIdFilter($orderId);
      $transactions->getItems();


      If MagentoSalesApiDataTransactionSearchResultInterfaceFactory doesn't work, try to use MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory. I'm not test yet both of them.






      share|improve this answer















      Edit:



      Try to inject MagentoSalesApiDataTransactionSearchResultInterfaceFactory into your constructor:



      protected $transactions;

      public function __constructor(
      MagentoSalesApiDataTransactionSearchResultInterfaceFactory $transactions,
      ......
      )

      $this->transactions = $transactions;



      In your method:



      $transactions = $this->transactions->create()->addOrderIdFilter($orderId);
      $transactions->getItems();


      If MagentoSalesApiDataTransactionSearchResultInterfaceFactory doesn't work, try to use MagentoSalesModelResourceModelOrderPaymentTransactionCollectionFactory. I'm not test yet both of them.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 26 at 13:13

























      answered Mar 26 at 10:14









      Ronak RathodRonak Rathod

      869112




      869112












      • This is not working.

        – Amatya Trivedi
        Mar 26 at 11:02

















      • This is not working.

        – Amatya Trivedi
        Mar 26 at 11:02
















      This is not working.

      – Amatya Trivedi
      Mar 26 at 11:02





      This is not working.

      – Amatya Trivedi
      Mar 26 at 11:02













      0














      This will work.



      class MyClass

      /**
      * @var MagentoSalesApiTransactionRepositoryInterface
      */
      private $repository;

      /**
      * @var MagentoFrameworkApiSearchCriteriaBuilder
      */
      private $searchCriteriaBuilder;

      /**
      * MyClass constructor.
      *
      * @param MagentoSalesApiTransactionRepositoryInterface $repository
      * @param MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
      */
      public function __construct(
      MagentoSalesApiTransactionRepositoryInterface $repository,
      MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
      )
      $this->repository = $repository;
      $this->searchCriteriaBuilder = $searchCriteriaBuilder;


      /**
      * @param int $id
      *
      * @return MagentoSalesApiDataTransactionInterface[]
      */
      public function getTransactionByOrderId($id)

      $this->searchCriteriaBuilder->addFilter('order_id', $id);
      $list = $this->repository->getList(
      $this->searchCriteriaBuilder->create()
      );

      return $list->getItems();







      share|improve this answer



























        0














        This will work.



        class MyClass

        /**
        * @var MagentoSalesApiTransactionRepositoryInterface
        */
        private $repository;

        /**
        * @var MagentoFrameworkApiSearchCriteriaBuilder
        */
        private $searchCriteriaBuilder;

        /**
        * MyClass constructor.
        *
        * @param MagentoSalesApiTransactionRepositoryInterface $repository
        * @param MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
        */
        public function __construct(
        MagentoSalesApiTransactionRepositoryInterface $repository,
        MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
        )
        $this->repository = $repository;
        $this->searchCriteriaBuilder = $searchCriteriaBuilder;


        /**
        * @param int $id
        *
        * @return MagentoSalesApiDataTransactionInterface[]
        */
        public function getTransactionByOrderId($id)

        $this->searchCriteriaBuilder->addFilter('order_id', $id);
        $list = $this->repository->getList(
        $this->searchCriteriaBuilder->create()
        );

        return $list->getItems();







        share|improve this answer

























          0












          0








          0







          This will work.



          class MyClass

          /**
          * @var MagentoSalesApiTransactionRepositoryInterface
          */
          private $repository;

          /**
          * @var MagentoFrameworkApiSearchCriteriaBuilder
          */
          private $searchCriteriaBuilder;

          /**
          * MyClass constructor.
          *
          * @param MagentoSalesApiTransactionRepositoryInterface $repository
          * @param MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
          */
          public function __construct(
          MagentoSalesApiTransactionRepositoryInterface $repository,
          MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
          )
          $this->repository = $repository;
          $this->searchCriteriaBuilder = $searchCriteriaBuilder;


          /**
          * @param int $id
          *
          * @return MagentoSalesApiDataTransactionInterface[]
          */
          public function getTransactionByOrderId($id)

          $this->searchCriteriaBuilder->addFilter('order_id', $id);
          $list = $this->repository->getList(
          $this->searchCriteriaBuilder->create()
          );

          return $list->getItems();







          share|improve this answer













          This will work.



          class MyClass

          /**
          * @var MagentoSalesApiTransactionRepositoryInterface
          */
          private $repository;

          /**
          * @var MagentoFrameworkApiSearchCriteriaBuilder
          */
          private $searchCriteriaBuilder;

          /**
          * MyClass constructor.
          *
          * @param MagentoSalesApiTransactionRepositoryInterface $repository
          * @param MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
          */
          public function __construct(
          MagentoSalesApiTransactionRepositoryInterface $repository,
          MagentoFrameworkApiSearchCriteriaBuilder $searchCriteriaBuilder
          )
          $this->repository = $repository;
          $this->searchCriteriaBuilder = $searchCriteriaBuilder;


          /**
          * @param int $id
          *
          * @return MagentoSalesApiDataTransactionInterface[]
          */
          public function getTransactionByOrderId($id)

          $this->searchCriteriaBuilder->addFilter('order_id', $id);
          $list = $this->repository->getList(
          $this->searchCriteriaBuilder->create()
          );

          return $list->getItems();








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 4:36









          Shawn AbramsonShawn Abramson

          2,4871915




          2,4871915





















              0














              You can use MagentoSalesApiDataTransactionSearchResultInterface for transaction Id.



              $transaction = $objectManager->create('MagentoSalesApiDataTransactionSearchResultInterfaceFactory')->create()->addOrderIdFilter($block->getOrderId())->getFirstItem();

              $transactionId = $transaction->getData('txn_id');


              The $transactionId is your required transaction Id.






              share|improve this answer








              New contributor




              Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.
























                0














                You can use MagentoSalesApiDataTransactionSearchResultInterface for transaction Id.



                $transaction = $objectManager->create('MagentoSalesApiDataTransactionSearchResultInterfaceFactory')->create()->addOrderIdFilter($block->getOrderId())->getFirstItem();

                $transactionId = $transaction->getData('txn_id');


                The $transactionId is your required transaction Id.






                share|improve this answer








                New contributor




                Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                  0












                  0








                  0







                  You can use MagentoSalesApiDataTransactionSearchResultInterface for transaction Id.



                  $transaction = $objectManager->create('MagentoSalesApiDataTransactionSearchResultInterfaceFactory')->create()->addOrderIdFilter($block->getOrderId())->getFirstItem();

                  $transactionId = $transaction->getData('txn_id');


                  The $transactionId is your required transaction Id.






                  share|improve this answer








                  New contributor




                  Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  You can use MagentoSalesApiDataTransactionSearchResultInterface for transaction Id.



                  $transaction = $objectManager->create('MagentoSalesApiDataTransactionSearchResultInterfaceFactory')->create()->addOrderIdFilter($block->getOrderId())->getFirstItem();

                  $transactionId = $transaction->getData('txn_id');


                  The $transactionId is your required transaction Id.







                  share|improve this answer








                  New contributor




                  Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 13 hours ago









                  JazzJazz

                  262




                  262




                  New contributor




                  Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Jazz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267408%2fhow-to-get-transaction-id-of-an-order-in-magento-2%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                      Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?