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

                      Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                      Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form