Im trying to make a new payment gateway in magento 2.1.1 that when a customer click on place order button he/she will be redirected to a third party url for example is https://example_payment_carrier.com and the custmer will complete his/her payment there. then after completing a payment the https://example_payment_carrier.com will bring him/her back to https://example_mydomain.com/mygateway/paymentaction

The question is where should I put the third party URL, so that when the place order button is clicked it will post a request including the form data to the third party carrrier?

1 Answer 1


To create a redirected Payment gateway you need to create following files. /app/code/vendor/module/view/frontend/web/template/payment/.html

 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
    <div class="payment-method-title field choice">
        <input type="radio"
               data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
        <label data-bind="attr: {'for': getCode()}" class="label"><span data-bind="text: getTitle()"></span></label>
    <div class="payment-method-content">
        <!-- ko foreach: getRegion('messages') -->
        <!-- ko template: getTemplate() --><!-- /ko -->
        <div class="payment-method-billing-address">
            <!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
            <!-- ko template: getTemplate() --><!-- /ko -->
        <div class="checkout-agreements-block">
            <!-- ko foreach: $parent.getRegion('before-place-order') -->
                <!-- ko template: getTemplate() --><!-- /ko -->
        <div class="actions-toolbar">
            <div class="primary">
                <button class="action primary checkout paynow"
                        click: continueToPaymentGateway,
                        attr: {title: $t('Place Order')},
                        css: {disabled: !isPlaceOrderActionAllowed()},
                        enable: (getCode() == isChecked())
                    <span data-bind="i18n: 'Place Order'"></span>


    function ($, Component, setBillingAddressAction, setPaymentMethodAction,  additionalValidators) {
        'use strict';
        return Component.extend({
            defaults: {
                template: '<vendor_module>/payment/<paymentmethod>'
            initialize: function () {
                var self = this;

            continueToPaymentGateway: function () {
                if (additionalValidators.validate()) {
                 //update payment method information if additional data was changed

                 $.mage.redirect(window.checkoutConfig.payment.<paymentmethod>.redirectUrl);//or you can direct pass payment gateway url from here
                 return false;
  • Magento_Checkout/js/action/set-payment-method is no longer there in magento 2.1.1, $.mage.redirect(window.checkoutConfig.payment.<paymentmethod>.redirectUrl); is working good for me
    – Vhanjan
    Commented Oct 12, 2016 at 7:18

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.