Magento 2: Call backend before display payment method on checkout page












0















I have my custom payment my_offsite_custom_payment method and onepage-checkout page modified in xml file below.



Before I display that payment method on checkout page I need to get extra data from backend to check what other options have merchant. After getting that data from backend I need to display it with that Payment option.



Could anybody help me to achieve that?



checkout_index_index.xml



<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<head>
<css src="Custom_Payment::css/offsite-custom.css" />
</head>
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="billing-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="renders" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment-custom" xsi:type="array">
<item name="component" xsi:type="string">My_Payment/js/view/payment/custom</item>
<item name="methods" xsi:type="array">
<item name="my_offsite_custom_payment" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>









share|improve this question



























    0















    I have my custom payment my_offsite_custom_payment method and onepage-checkout page modified in xml file below.



    Before I display that payment method on checkout page I need to get extra data from backend to check what other options have merchant. After getting that data from backend I need to display it with that Payment option.



    Could anybody help me to achieve that?



    checkout_index_index.xml



    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
    <head>
    <css src="Custom_Payment::css/offsite-custom.css" />
    </head>
    <body>
    <referenceBlock name="checkout.root">
    <arguments>
    <argument name="jsLayout" xsi:type="array">
    <item name="components" xsi:type="array">
    <item name="checkout" xsi:type="array">
    <item name="children" xsi:type="array">
    <item name="steps" xsi:type="array">
    <item name="children" xsi:type="array">
    <item name="billing-step" xsi:type="array">
    <item name="children" xsi:type="array">
    <item name="payment" xsi:type="array">
    <item name="children" xsi:type="array">
    <item name="renders" xsi:type="array">
    <item name="children" xsi:type="array">
    <item name="payment-custom" xsi:type="array">
    <item name="component" xsi:type="string">My_Payment/js/view/payment/custom</item>
    <item name="methods" xsi:type="array">
    <item name="my_offsite_custom_payment" xsi:type="array">
    <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </item>
    </argument>
    </arguments>
    </referenceBlock>
    </body>
    </page>









    share|improve this question

























      0












      0








      0








      I have my custom payment my_offsite_custom_payment method and onepage-checkout page modified in xml file below.



      Before I display that payment method on checkout page I need to get extra data from backend to check what other options have merchant. After getting that data from backend I need to display it with that Payment option.



      Could anybody help me to achieve that?



      checkout_index_index.xml



      <?xml version="1.0"?>
      <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
      <head>
      <css src="Custom_Payment::css/offsite-custom.css" />
      </head>
      <body>
      <referenceBlock name="checkout.root">
      <arguments>
      <argument name="jsLayout" xsi:type="array">
      <item name="components" xsi:type="array">
      <item name="checkout" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="steps" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="billing-step" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="payment" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="renders" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="payment-custom" xsi:type="array">
      <item name="component" xsi:type="string">My_Payment/js/view/payment/custom</item>
      <item name="methods" xsi:type="array">
      <item name="my_offsite_custom_payment" xsi:type="array">
      <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </argument>
      </arguments>
      </referenceBlock>
      </body>
      </page>









      share|improve this question














      I have my custom payment my_offsite_custom_payment method and onepage-checkout page modified in xml file below.



      Before I display that payment method on checkout page I need to get extra data from backend to check what other options have merchant. After getting that data from backend I need to display it with that Payment option.



      Could anybody help me to achieve that?



      checkout_index_index.xml



      <?xml version="1.0"?>
      <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
      <head>
      <css src="Custom_Payment::css/offsite-custom.css" />
      </head>
      <body>
      <referenceBlock name="checkout.root">
      <arguments>
      <argument name="jsLayout" xsi:type="array">
      <item name="components" xsi:type="array">
      <item name="checkout" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="steps" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="billing-step" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="payment" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="renders" xsi:type="array">
      <item name="children" xsi:type="array">
      <item name="payment-custom" xsi:type="array">
      <item name="component" xsi:type="string">My_Payment/js/view/payment/custom</item>
      <item name="methods" xsi:type="array">
      <item name="my_offsite_custom_payment" xsi:type="array">
      <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </item>
      </argument>
      </arguments>
      </referenceBlock>
      </body>
      </page>






      magento2 onepage-checkout payment-methods






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 8:36









      stanstan

      111




      111






















          2 Answers
          2






          active

          oldest

          votes


















          0














          To change load order, you would need to add sequence in your Custom Module etc/module.xml file. And add 'Magento_Backend' there.



          Check devdocs here, that how does it load sequence work :
          https://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html






          share|improve this answer































            0














            I solved that issue by creating observer with type: sales_order_place_after in etc/events.xml



            <event name="sales_order_place_after">
            <observer name="custom_end_order" instance="MyModulePaymentObserverCustomPaymentObserver" />
            </event>


            than I implemented in observer:



            $paymentInfo->setAdditionalInformation(['stuff here']);


            this additional information was available in javascript.






            share|improve this answer























              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%2f250774%2fmagento-2-call-backend-before-display-payment-method-on-checkout-page%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              To change load order, you would need to add sequence in your Custom Module etc/module.xml file. And add 'Magento_Backend' there.



              Check devdocs here, that how does it load sequence work :
              https://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html






              share|improve this answer




























                0














                To change load order, you would need to add sequence in your Custom Module etc/module.xml file. And add 'Magento_Backend' there.



                Check devdocs here, that how does it load sequence work :
                https://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html






                share|improve this answer


























                  0












                  0








                  0







                  To change load order, you would need to add sequence in your Custom Module etc/module.xml file. And add 'Magento_Backend' there.



                  Check devdocs here, that how does it load sequence work :
                  https://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html






                  share|improve this answer













                  To change load order, you would need to add sequence in your Custom Module etc/module.xml file. And add 'Magento_Backend' there.



                  Check devdocs here, that how does it load sequence work :
                  https://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 21 '18 at 9:51









                  Naveed AsimNaveed Asim

                  2,5362315




                  2,5362315

























                      0














                      I solved that issue by creating observer with type: sales_order_place_after in etc/events.xml



                      <event name="sales_order_place_after">
                      <observer name="custom_end_order" instance="MyModulePaymentObserverCustomPaymentObserver" />
                      </event>


                      than I implemented in observer:



                      $paymentInfo->setAdditionalInformation(['stuff here']);


                      this additional information was available in javascript.






                      share|improve this answer




























                        0














                        I solved that issue by creating observer with type: sales_order_place_after in etc/events.xml



                        <event name="sales_order_place_after">
                        <observer name="custom_end_order" instance="MyModulePaymentObserverCustomPaymentObserver" />
                        </event>


                        than I implemented in observer:



                        $paymentInfo->setAdditionalInformation(['stuff here']);


                        this additional information was available in javascript.






                        share|improve this answer


























                          0












                          0








                          0







                          I solved that issue by creating observer with type: sales_order_place_after in etc/events.xml



                          <event name="sales_order_place_after">
                          <observer name="custom_end_order" instance="MyModulePaymentObserverCustomPaymentObserver" />
                          </event>


                          than I implemented in observer:



                          $paymentInfo->setAdditionalInformation(['stuff here']);


                          this additional information was available in javascript.






                          share|improve this answer













                          I solved that issue by creating observer with type: sales_order_place_after in etc/events.xml



                          <event name="sales_order_place_after">
                          <observer name="custom_end_order" instance="MyModulePaymentObserverCustomPaymentObserver" />
                          </event>


                          than I implemented in observer:



                          $paymentInfo->setAdditionalInformation(['stuff here']);


                          this additional information was available in javascript.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 17 mins ago









                          stanstan

                          111




                          111






























                              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%2f250774%2fmagento-2-call-backend-before-display-payment-method-on-checkout-page%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

                              What other Star Trek series did the main TNG cast show up in?

                              Berlina muro

                              Berlina aerponto