How Redirect to 3rd party payment gateway in Magento2?Help on creating a Payment Gateway that redirects to...

Is it possible to convert a suspension fork to rigid by drilling it?

What could trigger powerful quakes on icy world?

Do higher etale homotopy groups of spectrum of a field always vanish?

What type of postprocessing gives the effect of people standing out

What are all the squawk codes?

How can I be pwned if I'm not registered on the compromised site?

Why can't we make a perpetual motion machine by using a magnet to pull up a piece of metal, then letting it fall back down?

Make me a metasequence

Is the withholding of funding notice allowed?

How do I deal with being jealous of my own players?

Levi-Civita symbol: 3D matrix

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

How to mitigate "bandwagon attacking" from players?

Difference between 'stomach' and 'uterus'

What type of investment is best suited for a 1-year investment on a down payment?

Rationale to prefer local variables over instance variables?

Non-Italian European mafias in USA?

Are small insurances worth it

In iTunes 12 on macOS, how can I reset the skip count of a song?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

How can I create a Table like this in Latex?

What are the issues with an additional (limited) concentration slot instead of Bladesong?

How can I handle a player who pre-plans arguments about my rulings on RAW?

Why doesn't Object.keys return a keyof type in TypeScript?



How Redirect to 3rd party payment gateway in Magento2?


Help on creating a Payment Gateway that redirects to Payment ProviderRedirect to external url after order creationMagento 2 Redirect to 3rd party payment gateway with post dataMagento 2.1.6 CE Direct post configure fields sent to authorize.netHow to get shipping quote on product view page - Magento2?Payment Gateway Redirect UrlHow to post data to a payment provider when placing an order in Magento 2Magento 1.9. - Third party payment gatewayhow to send payment form data to third party url (redirect) using post method in magento 2Magento2: How to add 3rd party payment getaway?













1















In Magento 1 we define the getOrderPlaceRedirectUrl in the model which extends Mage_Payment_Model_Method_Abstract and redirect to a particular controller after checkout submit.



Then from the controller we call $this->getResponse()->setBody($this->getLayout()->createBlock('someblock')->toHtml()) and inside the block we create a form with post data and redirect to a 3rd party payment gateway.



In Magento 2 I heard that getOrderPlaceRedirectUrl is not available and I'm unable to understand how it is handled.



Can someone please guide me to achieve the above scenario in Magento 2.1?










share|improve this question
















bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1















    In Magento 1 we define the getOrderPlaceRedirectUrl in the model which extends Mage_Payment_Model_Method_Abstract and redirect to a particular controller after checkout submit.



    Then from the controller we call $this->getResponse()->setBody($this->getLayout()->createBlock('someblock')->toHtml()) and inside the block we create a form with post data and redirect to a 3rd party payment gateway.



    In Magento 2 I heard that getOrderPlaceRedirectUrl is not available and I'm unable to understand how it is handled.



    Can someone please guide me to achieve the above scenario in Magento 2.1?










    share|improve this question
















    bumped to the homepage by Community 8 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      In Magento 1 we define the getOrderPlaceRedirectUrl in the model which extends Mage_Payment_Model_Method_Abstract and redirect to a particular controller after checkout submit.



      Then from the controller we call $this->getResponse()->setBody($this->getLayout()->createBlock('someblock')->toHtml()) and inside the block we create a form with post data and redirect to a 3rd party payment gateway.



      In Magento 2 I heard that getOrderPlaceRedirectUrl is not available and I'm unable to understand how it is handled.



      Can someone please guide me to achieve the above scenario in Magento 2.1?










      share|improve this question
















      In Magento 1 we define the getOrderPlaceRedirectUrl in the model which extends Mage_Payment_Model_Method_Abstract and redirect to a particular controller after checkout submit.



      Then from the controller we call $this->getResponse()->setBody($this->getLayout()->createBlock('someblock')->toHtml()) and inside the block we create a form with post data and redirect to a 3rd party payment gateway.



      In Magento 2 I heard that getOrderPlaceRedirectUrl is not available and I'm unable to understand how it is handled.



      Can someone please guide me to achieve the above scenario in Magento 2.1?







      magento-2.1 payment-methods redirect-url






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 14 '17 at 5:00









      Prince Patel

      13.9k55279




      13.9k55279










      asked Sep 14 '16 at 11:33









      Magento2 DevloperMagento2 Devloper

      9161135




      9161135





      bumped to the homepage by Community 8 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 8 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You need to override the placeOrder function in your method-render JS function.



              'use strict';

          return Component.extend({
          defaults: {
          template: 'Yuansfer_Yuansfer/payment/form'
          },
          getCode: function () {
          return 'yuansfer_alipay';
          },
          isActive: function () {
          return true;
          },
          getMediaUrl: function () {
          return mediaUrl;
          },
          placeOrder: function (data, event) {
          if(event) {
          event.preventDefault();
          }

          var self = this,
          placeOrder,
          emailValidationResult = customer.isLoggedIn(),
          loginFormSelector = 'form[data-role=email-with-possible-login]';

          if (!customer.isLoggedIn()) {
          $(loginFormSelector).validation();
          emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
          }

          if (emailValidationResult && this.validate() && additionalValidators.validate()) {
          this.isPlaceOrderActionAllowed(false);

          var setPaymentInfo = setPaymentInformationAction(this.messageContainer, self.getData());
          $.when(setPaymentInfo).fail(function () {
          self.isPlaceOrderActionAllowed(true);
          }).done(
          this.afterPlaceOrder.bind(this)
          );
          return true;
          }
          return false;
          },
          selectPaymentMethod: function () {
          selectPaymentMethodAction(this.getData());
          checkoutData.setSelectedPaymentMethod(this.item.method);
          return true;
          },
          afterPlaceOrder: function () {
          window.location.replace(url.build('module_name/controller/action/'));
          }
          });
          }


          );



          The key is here afterPlaceOrder function.
          You should redirect to your save action here.






          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%2f136285%2fhow-redirect-to-3rd-party-payment-gateway-in-magento2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You need to override the placeOrder function in your method-render JS function.



                'use strict';

            return Component.extend({
            defaults: {
            template: 'Yuansfer_Yuansfer/payment/form'
            },
            getCode: function () {
            return 'yuansfer_alipay';
            },
            isActive: function () {
            return true;
            },
            getMediaUrl: function () {
            return mediaUrl;
            },
            placeOrder: function (data, event) {
            if(event) {
            event.preventDefault();
            }

            var self = this,
            placeOrder,
            emailValidationResult = customer.isLoggedIn(),
            loginFormSelector = 'form[data-role=email-with-possible-login]';

            if (!customer.isLoggedIn()) {
            $(loginFormSelector).validation();
            emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
            }

            if (emailValidationResult && this.validate() && additionalValidators.validate()) {
            this.isPlaceOrderActionAllowed(false);

            var setPaymentInfo = setPaymentInformationAction(this.messageContainer, self.getData());
            $.when(setPaymentInfo).fail(function () {
            self.isPlaceOrderActionAllowed(true);
            }).done(
            this.afterPlaceOrder.bind(this)
            );
            return true;
            }
            return false;
            },
            selectPaymentMethod: function () {
            selectPaymentMethodAction(this.getData());
            checkoutData.setSelectedPaymentMethod(this.item.method);
            return true;
            },
            afterPlaceOrder: function () {
            window.location.replace(url.build('module_name/controller/action/'));
            }
            });
            }


            );



            The key is here afterPlaceOrder function.
            You should redirect to your save action here.






            share|improve this answer




























              0














              You need to override the placeOrder function in your method-render JS function.



                  'use strict';

              return Component.extend({
              defaults: {
              template: 'Yuansfer_Yuansfer/payment/form'
              },
              getCode: function () {
              return 'yuansfer_alipay';
              },
              isActive: function () {
              return true;
              },
              getMediaUrl: function () {
              return mediaUrl;
              },
              placeOrder: function (data, event) {
              if(event) {
              event.preventDefault();
              }

              var self = this,
              placeOrder,
              emailValidationResult = customer.isLoggedIn(),
              loginFormSelector = 'form[data-role=email-with-possible-login]';

              if (!customer.isLoggedIn()) {
              $(loginFormSelector).validation();
              emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
              }

              if (emailValidationResult && this.validate() && additionalValidators.validate()) {
              this.isPlaceOrderActionAllowed(false);

              var setPaymentInfo = setPaymentInformationAction(this.messageContainer, self.getData());
              $.when(setPaymentInfo).fail(function () {
              self.isPlaceOrderActionAllowed(true);
              }).done(
              this.afterPlaceOrder.bind(this)
              );
              return true;
              }
              return false;
              },
              selectPaymentMethod: function () {
              selectPaymentMethodAction(this.getData());
              checkoutData.setSelectedPaymentMethod(this.item.method);
              return true;
              },
              afterPlaceOrder: function () {
              window.location.replace(url.build('module_name/controller/action/'));
              }
              });
              }


              );



              The key is here afterPlaceOrder function.
              You should redirect to your save action here.






              share|improve this answer


























                0












                0








                0







                You need to override the placeOrder function in your method-render JS function.



                    'use strict';

                return Component.extend({
                defaults: {
                template: 'Yuansfer_Yuansfer/payment/form'
                },
                getCode: function () {
                return 'yuansfer_alipay';
                },
                isActive: function () {
                return true;
                },
                getMediaUrl: function () {
                return mediaUrl;
                },
                placeOrder: function (data, event) {
                if(event) {
                event.preventDefault();
                }

                var self = this,
                placeOrder,
                emailValidationResult = customer.isLoggedIn(),
                loginFormSelector = 'form[data-role=email-with-possible-login]';

                if (!customer.isLoggedIn()) {
                $(loginFormSelector).validation();
                emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
                }

                if (emailValidationResult && this.validate() && additionalValidators.validate()) {
                this.isPlaceOrderActionAllowed(false);

                var setPaymentInfo = setPaymentInformationAction(this.messageContainer, self.getData());
                $.when(setPaymentInfo).fail(function () {
                self.isPlaceOrderActionAllowed(true);
                }).done(
                this.afterPlaceOrder.bind(this)
                );
                return true;
                }
                return false;
                },
                selectPaymentMethod: function () {
                selectPaymentMethodAction(this.getData());
                checkoutData.setSelectedPaymentMethod(this.item.method);
                return true;
                },
                afterPlaceOrder: function () {
                window.location.replace(url.build('module_name/controller/action/'));
                }
                });
                }


                );



                The key is here afterPlaceOrder function.
                You should redirect to your save action here.






                share|improve this answer













                You need to override the placeOrder function in your method-render JS function.



                    'use strict';

                return Component.extend({
                defaults: {
                template: 'Yuansfer_Yuansfer/payment/form'
                },
                getCode: function () {
                return 'yuansfer_alipay';
                },
                isActive: function () {
                return true;
                },
                getMediaUrl: function () {
                return mediaUrl;
                },
                placeOrder: function (data, event) {
                if(event) {
                event.preventDefault();
                }

                var self = this,
                placeOrder,
                emailValidationResult = customer.isLoggedIn(),
                loginFormSelector = 'form[data-role=email-with-possible-login]';

                if (!customer.isLoggedIn()) {
                $(loginFormSelector).validation();
                emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
                }

                if (emailValidationResult && this.validate() && additionalValidators.validate()) {
                this.isPlaceOrderActionAllowed(false);

                var setPaymentInfo = setPaymentInformationAction(this.messageContainer, self.getData());
                $.when(setPaymentInfo).fail(function () {
                self.isPlaceOrderActionAllowed(true);
                }).done(
                this.afterPlaceOrder.bind(this)
                );
                return true;
                }
                return false;
                },
                selectPaymentMethod: function () {
                selectPaymentMethodAction(this.getData());
                checkoutData.setSelectedPaymentMethod(this.item.method);
                return true;
                },
                afterPlaceOrder: function () {
                window.location.replace(url.build('module_name/controller/action/'));
                }
                });
                }


                );



                The key is here afterPlaceOrder function.
                You should redirect to your save action here.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 11 '18 at 15:33









                RoyalFlushRoyalFlush

                11




                11






























                    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%2f136285%2fhow-redirect-to-3rd-party-payment-gateway-in-magento2%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

                    迭戈·戈丁...

                    A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

                    1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...