Your shopping cart is empty. Browse our Store

Magento

Open Source eCommerce Evolved

Magento Forum

   
New Payment Module Problem
 
ryu007
Sr. Member
 
Avatar
Total Posts:  93
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

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ryu007
Sr. Member
 
Avatar
Total Posts:  93
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 ?

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ryu007
Sr. Member
 
Avatar
Total Posts:  93
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 ?

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1524
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

 Signature 

- I would love to change the world, but they won’t give me the source code -

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

Hi Moshe,

Moshe - 22 April 2008 02: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.

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

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

Nobody knows how to do this ?

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

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ryu007
Sr. Member
 
Avatar
Total Posts:  93
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;
    
}

 Signature 

Artbambou : Mobilier, meuble, vannerie et décoration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
netwings
Jr. Member
 
Total Posts:  3
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
Jr. Member
 
Total Posts:  25
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
Magento Community
Magento Community
    Back to top
 
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien