I'm trying to build a custom Payment module, but it's very hard to get things to work because there's no real documentation yet. There are a few example extensions, but these are all outdated.

What I got working:

  • The user selects the Payment method
  • The user can select his bank from a list of dutch banks
  • After the user presses 'Place order' the user is redirected to the success page

What I cannot figure out to do:

  • Redirect the user to payment provider after 'Place order' is pressed
  • I should provide a redirect url to the payment provider where the user is redirected to after payment.
    • The ability to fetch the response of the Payment provider and show the success page to the user.

I'm working on this for days now, but I cannot figure out how to do it. Can someone point me in the right direction?


2 Answers 2


Redirection can be maintained by place order button handler.
For example please refer to Paypal Express checkout integration, here are several components required:

  1. Payment Method form template - where you need to define a click event handler which processes a place order button.

Example app/code/Magento/Paypal/view/frontend/web/template/payment/paypal-express.html

<button class="action primary checkout" type="submit" data-bind="click: placeOrderAction, enable: (getCode() == isChecked())" disabled> <span data-bind="i18n: 'Continue to Gateway'"></span> </button>

  1. View model(renderer) - a model for defined template.

Example app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/paypal-express-abstract.js

/** Redirect to Gateway */
        placeOrderAction: function () {
                this.selectPaymentMethod(); // save selected payment method in Quote
                return false;
  1. Define setPaymentMethodAction - which will place order and then redirect user to a gateway.

Example app/code/Magento/Paypal/view/frontend/web/js/action/set-payment-method.js

And "The ability to fetch the response of the Payment provider and show the success page to the user.".

The suggestion depends on Payment Gateway a communication pattern between Store and Payment Gateway. But as I understand your case is Redirect to Payment gateway side and then back to store.

This can be gained by defining a response action and route responsible for handling requests from Payment Gateway with redirect logic to Success page


First you can review https://github.com/magento/magento2-samples/tree/master/sample-module-payment-provider. But it's looks outdated.

Also, you can read http://inchoo.net/magento-2/implementing-payment-gateway-magento-2/.

  • 3
    Thank you for your reply. I already found these examples but unfortunately they are both outdated.
    – Silvan
    Nov 25, 2015 at 12:17
  • Any Updated link or full sample tutorial
    – matinict
    Oct 12, 2017 at 8:50

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.