Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

New Payment Module Problem
 
Mageho
Sr. Member
 
Avatar
Total Posts:  291
Joined:  2008-03-24
France, Paris
 

Good morning,

Actually, I write a new payment module for Fianet, called ReceiveAndPay.
A new French payment solution.

Everything going right but I block on small things :
- I lost the checkout session during return to the store although customer are still connected to his account.
Customer are redirected to cart page, but I want to redirected him to the checkout success page.

- How do I desactive the module from payment process if, per example, the service are unavailable ?
I look for var or function, not all code.

This is my StandardController for the return :

<?php
    
/**
     * When a customer chooses ReceiveAndPay on Checkout/Payment page
     *
     */
    
public function redirectAction()
    
{
        $session 
Mage::getSingleton('checkout/session');
        
$session->setReceiveandpayStandardQuoteId($session->getQuoteId());
        
$this->getResponse()->setBody($this->getLayout()->createBlock('receiveandpay/standard_redirect')->toHtml());
        
$session->unsQuoteId();
    
}
    
    
public function customerAction()
    
{
        $session 
Mage::getSingleton('checkout/session');
        
$session->setQuoteId($session->getReceiveandpayStandardQuoteId(true));
        
/**
         * set the quote as inactive after back from ReceiveAndPay
         */
        
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();

        
/**
         * send confirmation email to customer
         */
        
$order Mage::getModel('sales/order');

        
$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());

        if (
$order->getId()) 
        
{
            $order
->sendNewOrderEmail();
        
}

        Mage
::getSingleton('checkout/session')->unsQuoteId();

        
$this->_redirect('checkout/onepage/success');
    
}

    
/**
     * Response from ReceiveAndPay
     *
     *  @return      void
     */
    
public function systemAction()
    
{
        
/*
          Pas de reponse POST de la part de ReceiveAndPay
          Vérification importante si quelqu'un tape
          l'adresse directement dans la barre d'adresse
        */
        
if (!$this->getRequest()->isPost()) 
        
{
            $this
->_redirect('');
            return;
        
}

        
// Enregistre le retour du serveur ReceiveAndPay
        
if ( $this->getDebug() ) 
        
{
            $debug 
Mage::getModel('receiveandpay/api_debug')
                ->
setApiEndpoint($this->getStandard()->getReceiveAndPayUrl())
                ->
setRequestBody(print_r($this->getRequest()->getPost(), 1))
                ->
save();
        
}
    }

It’s almost done, so some helps are VERY appreciated !

Cheers,
Ilan

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mageho
Sr. Member
 
Avatar
Total Posts:  291
Joined:  2008-03-24
France, Paris
 

I just think about testing how paypal module implements return callback and return action for the customer.

And I am little astonished !

It’s exactly the same controller so I don’t see where I wrong ?
I tried paypal module just to check out and when you are on paypal side and you click on “return to the shop ****”
it redirect me to the empty shopping cart page ...

It display the cart without items…
I think it’s bug ? Somebody have noticed that ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mageho
Sr. Member
 
Avatar
Total Posts:  291
Joined:  2008-03-24
France, Paris
 

OK, I find it myself !

We don’t need this lines :

Mage::getSingleton(’checkout/session’)->getQuote()->setIsActive(false)->save();

and

Mage::getSingleton(’checkout/session’)->unsQuoteId();

Those line delete the current checkout session.
I don’t see why it implements in paypal module but for my new module, it works smoothly !

Now, I just have to find it to desactive a module.
It’s not the isAvailable method ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@ryu007: do you have ‘active’ configuration flag for your module?

P.S. you can use ‘pre’ tags instead of ‘quote’ for code snippets

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mageho
Sr. Member
 
Avatar
Total Posts:  291
Joined:  2008-03-24
France, Paris
 

Hi Moshe,

Moshe - 22 April 2008 01:55 PM

@ryu007: do you have ‘active’ configuration flag for your module?

Yes, of course !

I have just finished the module right now,
but I have to know how do I desactive the module by code if ReceiveAndPay server is unavailable !

For further information, this is my new controller :

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   Mage
 * @package    Mage_ReceiveAndPay
 * @copyright  Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)

 * ReceiveAndPay Form Method Front Controller
 *
 * @category   Mage
 * @package    Mage_ReceiveAndPay
 * @name       Mage_ReceiveAndPay_StandardController
**/
 
class Mage_ReceiveAndPay_StandardController extends Mage_Core_Controller_Front_Action
{    
    
/**
     * Get singleton with ReceiveAndPay strandard
     *
     * @return object Mage_ReceiveAndPay_Model_Standard
     */
    
public function getStandard()
    
{
        
return Mage::getSingleton('receiveandpay/standard');
    
}
    
    
/**
     * Get Api Key Model
     *
     * @return object Mage_ReceiveAndPay_Model_Config
     */
    
public function getApiKey()
    
{
        
return $this->getStandard()->getApiKey();
    
}

    
/**
     * Get Config model
     *
     * @return object Mage_ReceiveAndPay_Model_Config
     */
    
public function getConfig()
    
{
        
return $this->getStandard()->getConfig();
    
}

    
/**
     *  Return debug flag
     *
     *  @return  boolean
     */
    
public function getDebug()
    
{
        
return $this->getStandard()->getDebug();
    
}

    
/**
     * When a customer chooses ReceiveAndPay on Checkout/Payment page
     *
     */
    
public function redirectAction()
    
{
        $session 
Mage::getSingleton('checkout/session');
        
$session->setReceiveandpayStandardQuoteId($session->getQuoteId());
        
$this->getResponse()->setBody($this->getLayout()->createBlock('receiveandpay/standard_redirect')->toHtml());
        
$session->unsQuoteId();
    
}

    
/**
     *  Customer Response from ReceiveAndPay
     *
     *  @return      void
     */
    
public function customerAction()
    
{    
        $session 
Mage::getSingleton('checkout/session');
        
$session->setQuoteId($session->getReceiveandpayStandardQuoteId(true));        
        
        
$checkHash $this->getApiKey()->hash(
          
$this->getConfig()->getMerchantKey() . 
          
$this->getRequest()->getPost('RefID') . 
          
$this->getRequest()->getPost('TransactionID')
        );
        
        if (
$checkHash != $this->getRequest()->getPost('HashControl'))
        
{
            Mage
::throwException('Hash value doesn\'t according to Merchant');
            $this->_redirect('
checkout/onepage');
        }

        // Verification si la commande n'
a pas Ã©té avortée ou refusée pour fraude
        
if ($this->getRequest()->getPost('Tag') != && 
            
$this->getRequest()->getPost('Tag') != 2)
        
{
          
/**
           * send confirmation email to customer
           */
           
$order Mage::getModel('sales/order');
           
$order->loadByIncrementId($this->getRequest()->getPost('RefID'));

           if (
$order->getId()) 
           
{
               $order
->sendNewOrderEmail();
           
}
           
           $this
->_redirect('checkout/onepage/success');
        
else {
           $this
->_redirect('checkout/onepage');
        
}
    }

    
/**
     *  PUSH Response from ReceiveAndPay
     *
     *  @return      void
     */
    
public function systemAction()
    
{
        
// Pas de reponse POST de la part de ReceiveAndPay
        
if (!$this->getRequest()->isPost()) 
        
{
            Mage
::throwException('Callback data are not present');
            
$this->_redirect('');
            return;
        
}
        
        $checkHash 
$this->getApiKey()->hash(
            
$this->getConfig()->getMerchantKey() . 
            
$this->getRequest()->getPost('RefID') . 
            
$this->getRequest()->getPost('TransactionID')
        );
        
        if (
$checkHash != $this->getRequest()->getPost('HashControl'))
        
{
            Mage
::throwException('Hash value doesn\'t according to Merchant');
            $this->_redirect('');
            return;
        }

        // Enregistre le retour du serveur ReceiveAndPay si Mode Debug
        if ( $this->getDebug() ) 
        {
            $debug = Mage::getModel('
receiveandpay/api_debug')
                ->setApiEndpoint($this->getStandard()->getReceiveAndPayUrl())
                ->setRequestBody(print_r($this->getRequest()->getPost(), 1))
                ->save();
        }
    }
}

Thank you to take your time for answering me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mageho
Sr. Member
 
Avatar
Total Posts:  291
Joined:  2008-03-24
France, Paris
 

Nobody knows how to do this ?

Even for shipping module, it’s very useful ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mageho
Sr. Member
 
Avatar
Total Posts:  291
Joined:  2008-03-24
France, Paris
 

Finally, I found it !

/**
     * Return true if the method can be used at this time
     *
     * @return bool
     */
    public function isAvailable()
    
{
        
return false;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
netwings
Jr. Member
 
Total Posts:  4
Joined:  2008-04-09
 

Hi Guys,

I am sorry for a question that is not 100% related to this topic but i’ve been looking for help everywhere and no one seems to know what to do about this problem. I am even starting to think of giving up on magento all together and just stick with os commerce.

My problem is:

If a user comes to buy something for the first time they are asked if they want to register or check out as a guest.

Lets say the user types in their registration details and move in step by step to the final page before it is redirected to the paypal payments standard uk page, the problem starts when the redirected paypal website loads up and the price information has not been transferred, so pay pal will ask the user to put in the price information themselves.

The same problem does not happen if the user is already registered or tries to check out as a guest, the price will be sent over to paypal without any problems.

weird....

Any help will be apreciated.

Many Thanks for taking the time.

 
Magento Community Magento Community
Magento Community
Magento Community
 
leeaston
Sr. Member
 
Total Posts:  77
Joined:  2007-11-26
France
 

Hi ryu007,

will your module be in http://www.magentocommerce.com/magento-connect/community ?

Best wishes
Lee

 
Magento Community Magento Community
Magento Community
Magento Community
 
Troy Brown
Jr. Member
 
Total Posts:  14
Joined:  2008-05-29
 
ryu007 - 30 April 2008 01:48 PM

Finally, I found it !

/**
     * Return true if the method can be used at this time
     *
     * @return bool
     */
    public function isAvailable()
    
{
        
return false;
    
}

I may be misunderstanding, but if you want to deactivate the module, you wouldnt want to mess with the base code as that will kill all the other modules as well.

You should have in your system.xml file something like this:

<active translate="label">
    <
label>Enabled</label>
    <
frontend_type>select</frontend_type>
    <
source_model>adminhtml/system_config_source_yesno</source_model>
    <
sort_order>1</sort_order>
    <
show_in_default>1</show_in_default>
    <
show_in_website>1</show_in_website>
    <
show_in_store>0</show_in_store>
</
active>

Then, in your config.xml you need something like this:

<default>
        <
payment>
            <
paymethod>
                <
active>1</active>
                <
cctypes>AE,VI,MC,DI</cctypes>
                <
debug>1</debug>
                <
model>paymethod/paymethod</model>
                <
payment_action>authorize</payment_action>
                <
order_status>1</order_status>
                <
test>1</test>
                <
title>Payment (Credit Card)</title>
                <
allowspecific>0</allowspecific>
            </
paymethod>
       </
payment>
</default>

Simply setting the default <active> to 0 instead of 1 will deactive the module. You can also go into the admin configuration area and select Enabled: No and that will do it as well.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top