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?

1 Answer 1


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) {

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

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

            if (emailValidationResult && this.validate() && additionalValidators.validate()) {

                var setPaymentInfo = setPaymentInformationAction(this.messageContainer, self.getData());
                    $.when(setPaymentInfo).fail(function () {
                    return true;
            return false;
        selectPaymentMethod: function () {
            return true;
        afterPlaceOrder: function () {

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.