You are using the Polacin Mastercard Payment Gateway Services (MPGS) for Magento 2 or Magento 1, please see the guide below:

Requirements: Merchant ID, Merchant Name (only apply to Hosted Checkout), API Password, Gateway URL.

- Gateway URL: https://GATEWAY-DOMAIN, for example Your Merchant Administration URL is, You will put

- API Password is not the password in order to log into your Merchant Administration, API Password is formated like 9c94b8edfefdb45adfcf4a2fd880d6e1.

How to get API Password

Log into your Merchant Administation: Admin > Integration Settings

API Password is Password 1 field

- Navigation: REST API Keys

- Create Publishable API Key

- Create Secret API Key

This instruction is for Secure Acceptance integration

Login to Cybersource Business Center to create a Profile

When you are done, it looks like below screenshot

Copy this Profile ID to put in Profile ID field in Configuration Section from Magento Backend

Payment Settings

Choose Credit Cards

Choose Currencies


Create New Key > Generate. You will get Access Key and Secret Key. These will be used in Configuration section from Magento backend

A full theme package you buy from marketplace it commonly included: SQL file, Theme

When you install a Magento 2 by importing database from SQL file, you may get the problem related payment method.

That's your website redirected (Status 302) to Cart page after Place Order instead of Success page. i experienced with Smartwave, Plazetheme ...

How to fix this problem:

- Clear your cache by manually deleting the content of /var/cache/ folder , the /var/page-cache/ folder.

- Remove /var/generation/

- Remove /generated/ if you are using Magento 2.2.0

- Reindex your website by using the SSH command line php bin/magento indexer:reindex

- Deploy again the theme by ysubg the SSH command line php bin/magento setup:static-content:deploy

In case you already did all the steps above but the problem is still not resolved, you can use command line composer update to fixed your core Magento 2

Here is an example of how to upgrade magento 2.1.0 to 2.1.5

You can use following steps with composer update:

composer require magento/product-community-edition 2.1.5 --no-update
composer update
rm -rf var/di var/generation
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex
chmod -R 777 var

After upgrade, check your Magento version with the following command:

php bin/magento --version

How to get IPAddress in Magento 2

Jul 20, 2016 11:44:18 AM

Here is a simple way to get IP Address in Magento 2

protected function getIpAddress()
        $om = \Magento\Framework\App\ObjectManager::getInstance();
        $obj = $om->get('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress');
        $ip =  $obj->getRemoteAddress();
        return $ip;

How to Install a Magento 2 on localhost

Jul 5, 2016 11:21:41 PM

So many people as beginners of Magento 2 often get problem with Magento 2 installation and Command Line. Today i will share my experience in this job.

I suppose the project named: magento-2.1.0 (relative path looks like xampp/htdocs/magento-2.1.0/)

You install this project follow magento's guide

I just want to instruct the way to use the Command Line.

After you completed Magento 2 Installation, you need to run some command:

- Open Xampp as below screenshot

Of course we have a few ways to run command line but this is my favorite way

Then type:

cd htdocs\magento-2.1.0\bin [Enter]

php magento setup:static-content:deploy [Enter]

php magento indexer:reindex [Enter]

Done!! Your Magento 2 installation completed

If you want to install the extensions for this project, you just need type command:

php magento setup:upgrade [Enter]

php magento static-content:deploy [Enter] ( this command applys to extension including js, css, html files in web directory)


Event and Observer in Magento 2

Jun 15, 2016 9:21:34 PM

 we have to declare event that we will catch in file di.xml and a function on Observer file.

Example: echo module name, controller name, action name of the current module.

Event used:  controller_action_predispatch

1. Declare Event in events.xml (frontend)

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd">
<event name="controller_action_predispatch">
<observer name="magenhub_event" instance="Magenhub\Chris\Model\Observer" method="printInfo" shared="false" />

This code will be write in module: Magenhub_Chris, model Observer.

2. Write file Observer.php

Write function printInfo to print module name, controller name, action name of the current url.

File: app/code/Magenhub/Chris/Model/Observer.php


namespace Magenhub\Chris\Model;

class Observer {

public function printInfo(\Magento\Framework\Event\Observer $observer) {
$request = $observer->getEvent()->getData('request');
echo $request->getModuleName('catalog').'<br/>';
echo $request->getControllerName('product').'<br/>';
echo $request->getActionName('view').'<br/>';


This code only print module name, controller name and action name to browser.

  • Result for home page:


  • Result for product view page:



It's a Helper

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Filesystem\DirectoryList;

class Resize extends AbstractHelper{

    protected $_filesystem;
    protected $_storeManager;
    protected $_directory;
    protected $_imageFactory;

    public function __construct(
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\Filesystem $filesystem,
        \Magento\Framework\Image\AdapterFactory $imageFactory

    ) {
        $this->_filesystem = $filesystem;
        $this->_storeManager = $storeManager;
        $this->_directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
        $this->_imageFactory = $imageFactory;


    public function imageResize(
        $absPath = $this->_filesystem

        $imageResized = $this->_filesystem
        $imageResize = $this->_imageFactory->create();

        $imageResize->backgroundColor([255, 255, 255]);

        $dest = $imageResized ;
        $resizedURL= $this->_storeManager->getStore()
        return $resizedURL;


    public function getNewDirectoryImage($src){
        $segments = array_reverse(explode('/',$src));
        $first_dir = substr($segments[0],0,1);
        $second_dir = substr($segments[0],1,1);
        return 'cache/'.$first_dir.'/'.$second_dir.'/'.$segments[0];

How to use Date Time in Magento 2

May 14, 2016 7:36:56 PM

For beginner who is getting problem with Datetime class that is not like Magento 1x

we just use class: Magento\Framework\Stdlib\DateTime\DateTime

For example: