Im attempting to get my contact form to redirect to the homepage after form submission. I setup my module and can confirm it is working. In the code below, I get the 'Pre-dispatched' and 'Index Action' log messages but do not get the 'Post Action' and as you can expect, it also does not redirect me to the homepage when it is complete. I do receive the contact e-mail properly. Can anyone tell me why the first two functions are working correctly and postAction() is not?
I copied all of the code from the original controller into my controller for troubleshooting purposes. Everything is default except the addition of log messages and the redirects at the bottom.
class MyCompany_Contacts_IndexController extends Mage_Contacts_IndexController
{
const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email';
const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity';
const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template';
const XML_PATH_ENABLED = 'contacts/contacts/enabled';
public function preDispatch()
{
parent::preDispatch();
Mage::log('Pre-dispatched');
if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
$this->norouteAction();
}
}
public function indexAction()
{
Mage::log('Index Action.');
$this->loadLayout();
$this->getLayout()->getBlock('contactForm')
->setFormAction( Mage::getUrl('*/*/post') );
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');
$this->renderLayout();
}
public function postAction()
{
parent::postAction();
Mage::log('Post Action.');
$post = $this->getRequest()->getPost();
if ( $post ) {
$translate = Mage::getSingleton('core/translate');
/* #var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
try {
$postObject = new Varien_Object();
$postObject->setData($post);
$error = false;
if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
$error = true;
}
if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
$error = true;
}
if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
$error = true;
}
if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}
if ($error) {
throw new Exception();
}
$mailTemplate = Mage::getModel('core/email_template');
/* #var $mailTemplate Mage_Core_Model_Email_Template */
$mailTemplate->setDesignConfig(array('area' => 'frontend'))
->setReplyTo($post['email'])
->sendTransactional(
Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
null,
array('data' => $postObject)
);
if (!$mailTemplate->getSentSuccess()) {
throw new Exception();
}
$translate->setTranslateInline(true);
// Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
$this->_redirect('');
return;
} catch (Exception $e) {
$translate->setTranslateInline(true);
// Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
$this->_redirect('');
return;
}
} else {
$this->_redirect('');
}
}
}
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MyCompany_Contacts>
<version>0.0.1</version>
</MyCompany_Contacts>
</modules>
<frontend>
<routers>
<contacts>
<args>
<modules>
<MyCompany_Contacts before="Mage_Contacts">MyCompany_Contacts</MyCompany_Contacts>
</modules>
</args>
</contacts>
</routers>
</frontend>
</config>
The problem lies in the parent::postAction(); part within your custom postAction. What you are doing now is posting a form to /post. It does end up in your postAction, but then is directly routed through the parent::postAction().
The parent method, thus Mage_Contacts_IndexController::postAction(), also contains the logic to send an email . Hence you are receiving one. The problem is that at the end of the parent method there is still the redirect $this->_redirect('*/*/');. This prevents the code from reaching your `Mage::log('Post Action.') and the rest of your custom code.
Solution: remove the parent::postAction() and your custom code in the postAction method will be executed and eventually your own redirect to the homepage will be ran.
I think I figured this out. I remmebered that the post data gets analyzed by Akismet before it gets sent so its entirely possible the default Mage_Contacts is already getting extended and is going trough that module first. Added the logging to postAction() in the Akismet controller and that verified it. Thanks for setting me on the right track.
Related
Thanks for this forum. I often read it and this is my first question.
The question concerns Magento (1.9.1.0). I wanted to add an additional module that allows customer to write a comment on the order. I've been able to find a module that suits my need on the web. It works perfectly, but there is a big problem: it joins in the final step of the checkout (in particular, after the payment phase). And so, if the customer pays by bank transfer, marking or similar payments, the problem doesn't arise: Magento passes to the next step (order comment) and then order completion.
The problem arises in case of Paypal payment, as Magento redirects customer to Paypal.com and, after making the payment, returns to the store by the end of the order (without going to the next step of the comment). The comment form consisted of 19 files that, once installed in Magento, don't modify any existing files.
I would like to include this form after shipping_method step (and not after payment step) and, therefore, I think I have to modify the file (of the module) that is called Abstract.php (app/code/community/Brainvire/Ordercomment/Controller/Onepage/Abstract.php).
I would be very grateful if you could help me edit that file.
<?php
require_once 'Mage/Checkout/controllers/OnepageController.php';
class Brainvire_Ordercomment_Controller_Onepage_Abstract extends
Mage_Checkout_OnepageController {
/*
* Saving the Payment at Checkout
*/
public function savePaymentAction()
{
$this->_expireAjax();
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('payment', array());
try {
$result = $this->getOnepage()->savePayment($data);
}
catch (Mage_Payment_Exception $e) {
if ($e->getFields()) {
$result['fields'] = $e->getFields();
}
$result['error'] = $e->getMessage();
}
catch (Exception $e) {
$result['error'] = $e->getMessage();
}
$redirectUrl = $this->getOnePage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
if (empty($result['error']) && !$redirectUrl) {
$this->loadLayout('checkout_onepage_ordercomment');
$result['goto_section'] = 'ordercomment';
}
if ($redirectUrl) {
$result['redirect'] = $redirectUrl;
}
$this->getResponse()->setBody(Zend_Json::encode($result));
}
}
/*
* Saving the order comment
*/
public function saveOrdercommentAction()
{
$this->_expireAjax();
if ($this->getRequest()->isPost()) {
$_brainvire_Ordercomment = $this->getRequest()->getPost('ordercomment');
Mage::getSingleton('core/session')->setBrainvireOrdercomment($_brainvire_Ordercomment);
$result = array();
$redirectUrl = $this->getOnePage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
if (!$redirectUrl) {
$this->loadLayout('checkout_onepage_review');
$result['goto_section'] = 'review';
$result['update_section'] = array(
'name' => 'review',
'html' => $this->_getReviewHtml()
);
}
if ($redirectUrl) {
$result['redirect'] = $redirectUrl;
}
$this->getResponse()->setBody(Zend_Json::encode($result));
}
}
}
How do I edit this php code to insert Ordercomment after shipping_method step and before payment step?
Thanks
GS
I was able to move the order-comment section by editing two files:
First: Brainvire\Ordercomment\Block\Onepage.php
class Brainvire_Ordercomment_Block_Onepage extends Mage_Checkout_Block_Onepage
{
/**
* getting the steps of Checkout page
*/
public function getSteps()
{
...
$stepCodes = array('billing', 'shipping', 'shipping_method', 'ordercomment', 'payment', 'review'); // moved 'ordercomment' before 'payment'
...
}
}
And then the file you mentioned: Brainvire\Ordercomment\Controller\Onepage\Abstract.php
Remove the savePaymentAction() method and replace with this:
class Brainvire_Ordercomment_Controller_Onepage_Abstract extends Mage_Checkout_OnepageController {
/**
* Shipping method save action
*/
public function saveShippingMethodAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('shipping_method', '');
$result = $this->getOnepage()->saveShippingMethod($data);
/*
$result will have erro data if shipping method is empty
*/
if(!$result) {
Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method',
array('request'=>$this->getRequest(),
'quote'=>$this->getOnepage()->getQuote()));
$this->getOnepage()->getQuote()->collectTotals();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
if (empty($result['error']) && !$redirectUrl) {
$this->loadLayout('checkout_onepage_ordercomment');
$result['goto_section'] = 'ordercomment';
}
}
$this->getOnepage()->getQuote()->collectTotals()->save();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
/*
* Saving the order comment
*/
public function saveOrdercommentAction()
{
$this->_expireAjax();
if ($this->getRequest()->isPost()) {
$_brainvire_Ordercomment = $this->getRequest()->getPost('ordercomment');
Mage::getSingleton('core/session')->setBrainvireOrdercomment($_brainvire_Ordercomment);
$result = array();
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
$this->getResponse()->setBody(Zend_Json::encode($result));
}
}
}
Once you get this working, you should move these customizations into an override module, or at least copy the modified files to app/code/local, so the original code stays intact.
I have a custom module which is called on the customer_save_observer_executed event and specifically when a customer updates their details in their account page (name, password, email etc) I have added a custom attribute called display_name.
When a customer submits this form i need to check if the display_name currently exists for any other customer. If it doesn't then setDisplayName(...) else do nothing/display error message.
I was hoping to do this with this snippet:
$customer_check = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('display_name')
->addAttributeToFilter('display_name',$new_name)->load();
if ( is_object($customer_check) && count($customer_check) >= 2) {
// dont allow - duplicate customer displayname
}
else {
// allow update....
}
My current code in Model -> Observer.php
class xxxxxxx_Model_Observer
{
public function xxxxxxxx(Varien_Event_Observer $observer)
{
// to stop event being fired twice
if(Mage::registry('customer_save_observer_executed')){
return $this;
}
$postData = Mage::app()->getRequest()->getPost();
$customer = $observer->getCustomer();
// if updating NOT a new customer
if($customer instanceof Mage_Customer_Model_Customer && !$customer->isObjectNew()) {
// check display name is posted
if(!empty($postData['display_name'])){
$current_name = $customer->getDisplayName();
$new_name = $postData['display_name'];
// duplicate check
$customer_check = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('display_name')
->addAttributeToFilter('display_name',$new_name)->load();
if ( is_object($customer_check) && count($customer_check) >= 2) {
// dont allow - duplicate customer displayname
}
else {
if( $postData['display_name'] !== $current_name ) {
$customer->setDisplayName($postData['display_name']);
}
}
}
}
Mage::register('customer_save_observer_executed',true);
}
}
but this just updates the display_name even if i deliberately set it to a duplicate of another customers
UPDATE
Looking into this further it looks like the module function itself is not being run or nothing inside it is taking affect, as whatever i put in it doesn't work. It is infact the default behaviour that is setting the displayname not my module. My module is activated and my config file uses the customer_save_commit_after event as shown below:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<xxx_xxxxx>
<version>0.0.1</version>
</xxx_xxxxx>
</modules>
<global>
<models>
<xxx_xxxxx>
<class>xxx_xxxxx_Model</class>
</xxx_xxxxx>
</models>
<events>
<customer_save_commit_after>
<observers>
<xxx_xxxxx>
<class>xxx_xxxxx/observer</class>
<method>xxxxxx</method>
<type>singleton</type>
</xxx_xxxxx>
</observers>
</customer_save_commit_after>
</events>
</global>
</config>
This probably is the case because all data from the form submitted is set on the customer model in Magento's Customer module (code taken from Mage_Customer_AccountController)
/**
* Forgot customer account information page
*/
public function editAction()
{
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');
$block = $this->getLayout()->getBlock('customer_edit');
if ($block) {
$block->setRefererUrl($this->_getRefererUrl());
}
$data = $this->_getSession()->getCustomerFormData(true);
$customer = $this->_getSession()->getCustomer();
if (!empty($data)) {
$customer->addData($data);
}
if ($this->getRequest()->getParam('changepass') == 1) {
$customer->setChangePassword(1);
}
$this->getLayout()->getBlock('head')->setTitle($this->__('Account Information'));
$this->getLayout()->getBlock('messages')->setEscapeMessageFlag(true);
$this->renderLayout();
}
Here addData() is called on the customer model. To prevent this rename your form's input to something temporary, like <input name="display_name_tmp"/>, then in your controller do something like
public function xxxxxxxx(Varien_Event_Observer $observer)
{
// to stop event being fired twice
if(Mage::registry('customer_save_observer_executed')){
return $this;
}
$postData = Mage::app()->getRequest()->getPost();
$customer = $observer->getCustomer();
// if updating NOT a new customer
if($customer instanceof Mage_Customer_Model_Customer &&
!$customer->isObjectNew()) {
// check display name is posted
if(!empty($postData['display_name_tmp'])){
$current_name = $customer->getDisplayName();
$new_name = $postData['display_name_tmp'];
// duplicate check
$customer_check = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('display_name')
->addAttributeToFilter('display_name',$new_name)->load();
if ( is_object($customer_check) && count($customer_check) >= 2) {
// dont allow - duplicate customer displayname
}
else {
if( $postData['display_name'] !== $current_name ) {
$customer->setDisplayName($postData['display_name_tmp']);
}
}
}
}
Mage::register('customer_save_observer_executed',true);
}
I am trying to update the popularity count of Magento's Tag module by interacting with this core function in Mage_Tag_Model_API
public function update($tagId, $data, $store)
{
$data = $this->_prepareDataForUpdate($data);
$storeId = $this->_getStoreId($store);
/** #var $tag Mage_Tag_Model_Tag */
$tag = Mage::getModel('tag/tag')->setStoreId($storeId)->setAddBasePopularity()->load($tagId);
if (!$tag->getId()) {
$this->_fault('tag_not_exists');
}
// store should be set for 'base_popularity' to be saved in Mage_Tag_Model_Resource_Tag::_afterSave()
$tag->setStore($storeId);
if (isset($data['base_popularity'])) {
$tag->setBasePopularity($data['base_popularity']);
}
if (isset($data['name'])) {
$tag->setName(trim($data['name']));
}
if (isset($data['status'])) {
// validate tag status
if (!in_array($data['status'], array(
$tag->getApprovedStatus(), $tag->getPendingStatus(), $tag->getDisabledStatus()))) {
$this->_fault('invalid_data');
}
$tag->setStatus($data['status']);
}
try {
$tag->save();
} catch (Mage_Core_Exception $e) {
$this->_fault('save_error', $e->getMessage());
}
return true;
}
In my controller I have this :
public function clickAction()
{
$tagString = $this->getRequest()->getParam('tag');
$tagByName = Mage::getModel('tag/tag')->loadByName($tagString);
$tagId = $tagByName->getTagId();
$basePopularity = ['base_popularity' => '13']; // hard coding while testing
Mage::getModel('tag/api')->update($tagId, $basePopularity, 1);
}
If I put a log statement in this part of the update function :
try {
// log stuff
$tag->save();
}
I can see it makes it to that try but there is no change in the data. What did I screw up? Any other ideas on how I can update the popularity of a tag through a controller? Using this same method and adding 'name' => 'blah' to that $data array parameter works fine..
I also found in Mage_Tag_Model_Indexer_Summary.php this method defined in the PHPdoc * #method Mage_Tag_Model_Indexer_Summary setPopularity(int $value) Maybe that is what I need... can someone provide an example showing how I could use that magic setter?
Try adding Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); at the start of your clickAction function. base_popularity can only be updated from admin store.
I'm working with magento EE that has full page caching feature. There is a block that is updated dynamically, but I can't seem to disable its caching.
What I want to achieve ideally: disable caching only for particular block so it would be rendered again each time the page loads.
Things I tried:
Include unsetData to layout file
<action method="unsetData"><key>cache_lifetime</key></action>
<action method="unsetData"><key>cache_tags</key></action>
Set function _saveCache to return false
protected function _saveCache($data, $id, $tags = array(), $lifetime = null) {
return false;
}
Set different values for cache_lifetime
public function __construct()
{
$this->addData(array(
‘cache_lifetime’ => 0,
‘cache_tags’ => array(Mage_Catalog_Model_Product::CACHE_TAG),
));
}
Perhaps I'm missing something in full page caching mechanics?
Well, I found a couple of good posts and implement my caching with etc/cache.xml, that wraps my block with container object.
My cache.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<placeholders>
<namespace_block_unique_node>
<block>module/block_class</block>
<name>name_of_block_in_my_layout</name>
<template>path/to/my/template</template>
<placeholder>UNIQUE_PLACEHOLDER_HERE</placeholder>
<container>Namespace_Module_Model_Caching_Container_BlockName</container>
<cache_lifetime>86400</cache_lifetime>
</namespace_block_unique_node>
</placeholders>
</config>
I used here as block the block that should not be cached, as name name of block in my layout, and as container I've choose my container.
Code for container:
<?php
class Namespace_Module_Model_Caching_Container_BlockName extends Enterprise_PageCache_Model_Container_Abstract
{
protected function _getCacheId()
{
return 'NAMESPACE_MODULE_BLOCKNAME' . $this->_getIdentifier();
}
protected function _getIdentifier()
{
return microtime();
}
protected function _renderBlock()
{
$blockClass = $this->_placeholder->getAttribute('block');
$template = $this->_placeholder->getAttribute('template');
$block = new $blockClass;
$block->setTemplate($template);
$layout = Mage::app()->getLayout();
$block->setLayout($layout);
return $block->toHtml();
}
protected function _saveCache($data, $id, $tags = array(), $lifetime = null) { return false;}
}
Here I putmicrotime() function to identify block, but inside my module I used cookie variables related to my module. I believe that saves redundant reloading of a block when nothing was really changed.
The thing that I didn't found in other tutorials is that I had to create layout variable and assign it to my block, otherwise I was getting only my block instead of whole page.
Here is the solution for disabling FPC for a specific controller (could be extended to specific action as well).
First create an Observer to listen on the controller_action_predispatch event:
public function processPreDispatch(Varien_Event_Observer $observer)
{
$action = $observer->getEvent()->getControllerAction();
// Check to see if $action is a Product controller
if ($action instanceof Mage_Catalog_ProductController)
{
$request = $action->getRequest();
$cache = Mage::app()->getCacheInstance();
// Tell Magento to 'ban' the use of FPC for this request
$cache->banUse('full_page');
}
}
Then add the following to your config.xml file for the module. This goes in the section:
<events>
<controller_action_predispatch>
<observers>
<YOUR_UNIQUE_IDENTIFIER>
<class>YOURMODULE/observer</class>
<method>processPreDispatch</method>
</YOUR_UNIQUE_IDENTIFIER>
</observers>
</controller_action_predispatch>
</events>
Now Magento will serve up your page every time and bypass FPC for the request.
And You can also refer: http://mikebywaters.wordpress.com/2011/12/14/disable-magento-full-page-cache-on-a-per-controller-basis/
cache_lifetime must be set to null to disable cache for this block
public function __construct()
{
$this->addData(array(
‘cache_lifetime’ => null,
));
}
Is there any functionality in magento payment extention to stop the creation of an order before the success status from payment gateway is returned?
The Extension is designed as a payment redirect (with getOrderPlaceRedirectUrl) but really in the correct controller action, I do post from the action with params, to the gateway and return success if all OK, and return failure if not.
But the order is already created so I must cancel this order, but it should not create this order in the first place.
Maybe if I can design it as a gateway, I can use some payment method to do this?
I thought about the validate or prepareSave methods, but both of them are called twice - on accept payment method and on place order.
Also I thought about events - maybe I can use some event to do this post action and on failture just throw exception?
But I really think that in the payment methods, there has to be some standard functionality that I can use.
This is quite a common issue during Payment Module development.
Magento offers two hooks for payment method classes to provide redirect URL's, one before the order is created, one after.
If a payment method model implements getOrderPlaceRedirectUrl() the customer will be redirected after the confirmation step of the one page checkout, the order entity will be created.
If a payment method model implements the getCheckoutRedirectUrl() method, the customer will be redirected after the payment step of the one page checkout, and no order entity is created.
This is not ideal, but thats what Magento offers out of the box.
How about extending the _validate() method on Mage_Sales_Model_Service_Quote, and throw an error there so that it never gets to the "$transaction->save();" bit.
public function submitOrder()
{
$this->_deleteNominalItems();
// do some check here
$this->_validate();
// End checks
$quote = $this->_quote;
$isVirtual = $quote->isVirtual();
........
try {
$transaction->save();
$this->_inactivateQuote();
Mage::dispatchEvent('sales_model_service_quote_submit_success', array('order'=>$order, 'quote'=>$quote));
} catch (Exception $e) {
...........
}
...........
return $order;
}
Validate function looks like this:
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
if ($addressValidation !== true) {
Mage::throwException(
$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
);
}
$method= $address->getShippingMethod();
$rate = $address->getShippingRateByCode($method);
if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
Mage::throwException($helper->__('Please specify a shipping method.'));
}
}
$addressValidation = $this->getQuote()->getBillingAddress()->validate();
if ($addressValidation !== true) {
Mage::throwException(
$helper->__('Please check billing address information. %s', implode(' ', $addressValidation))
);
}
if (!($this->getQuote()->getPayment()->getMethod())) {
Mage::throwException($helper->__('Please select a valid payment method.'));
}
return $this;
}
The extended function can look like this:
public function __construct(Mage_Sales_Model_Quote $quote)
{
$this->_quote = $quote;
parent::__construct($quote);
}
protected function _validate()
{
// Code to test comes here
Mage::throwException(Mage::helper('payment')->__('unsuccessfull.....'));
// Code ends, now call parent
return parent::_validate();
}
As I said - giving sample that I used for this solution at final.
I prefered to observe event to do post request. Really if you'll use method presented here
you will take the same effect, but I prefer to use event observer. So:
First add some data to config.xml to create event observer in frontend section
<events>
<sales_model_service_quote_submit_before>
<observers>
<lacpaycs>
<type>singleton</type>
<class>OS_LacPayCS_Model_Observer</class>
<method>lacpaycs_payment_send</method>
</lacpaycs>
</observers>
</sales_model_service_quote_submit_before>
</events>
then we must create Observer class in OS/LacPayCS/Mode/Observer.php:
class OS_LacPayCS_Model_Observer {
protected $_code = 'lacpaycs';
// Here some our additional functions
/**
* #param Varien_Object $observer
*/
public function lacpaycs_payment_send(Varien_Object $observer)
{
/**
* #var Mage_Sales_Model_Order $order
* #var Mage_Sales_Model_Quote $quote
*/
$order = $observer->getOrder();
$quote = $observer->getQuote();
$payment = $order->getPayment();
if ($payment->getMethodInstance()->getCode() != $this->_code) {
return;
}
$helper = Mage::helper('lacpaycs');
try {
// Here we prepare data and sending request to gateway, and getting response
if (!$this->_validateResponse($response)) {
Mage::throwException('Error '.$this->errorMsg);
}
} catch (Exception $e) {
Mage::throwException($e->getMessage());
}
}
}
So in two words what we doing here $_code is the same that in our payment model and with it we checking in observer if we catched event when customer using our payment method
All another code is simple, so I think it's no need to comment it