Book Image

Magento Extensions Development

By : Bouchet
Book Image

Magento Extensions Development

By: Bouchet

Overview of this book

Magento has been revealed as the best and the most popular open source e-commerce platform in the world, with about 250k+ online stores. Magento 2 is the most recent version of this awesome toolset: every new and modern development techniques are used to offer a real modular approach and powerful architecture. The book will support you in the writing of innovative and complex extensions. Starting from the beginning, we will cover how to set up a development environment that allows you to be really efficient in your functionality writing, including GIT registering and many other development tools. We then move on to provide a large overview of the best practices to scale your module in a high-load environment. After these foundations, you will see how to use test driven-development (TDD) and unit tests to handle your code. We then build a complex extension together, step by step, and internationally-ready. Next, you will find out how to protect the users’ data. Finally, we will take a look a publishing the extension on the new Magento Connect marketplace and how to protect your intellectual property. After you read this book, you will know everything you need to know to become an invaluable extension editor, whether it is for your customers’ needs or for your own requirements.
Table of Contents (11 chapters)
10
Index

Developing your own payment method


Magento 2 completely remastered the checkout steps and based the date exchange on a REST API. Server-side web APIs are built with a new M2 Service Contracts approach. One of the benefits of this new method is that checkout form is now designed to be compact enough to easily fill in all the data using a mobile or tablet.

We will see here how to propose to your customer a new custom offline payment method, which can be coupled to your extension. We will call it money.

Implementing the method

The method will be rendered as an UI component, in a dedicated javascript file:

  1. Create the file [extension_path]/view/frontend/web/js/view/payment/method-renderer/ticketblaster-money.js and add the following code:

    define(
        [
            'Magento_Checkout/js/view/payment/default'
        ],
        function (Component) {
            'use strict';
            return Component.extend({
                defaults: {
                    template: 'Blackbird_TicketBlaster/payment/ticketblaster-money'
     ...