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

Recurring Profiles - PayPal date/time error
 
Michael Birnbaum
Jr. Member
 
Total Posts:  5
Joined:  2010-01-16
 

Hi

I’m having some issues with the Recurring Profiles feature in 1.4.2, which has to do with date and time and its making me lose business because people can’t sign up for membership at certain times of the day.

Shop Configuration:
Locale - English/Australia
Timezone - E.Australia Standard (Australia/Brisbane)

Server location: Salt Lake City, USA

Reproducible scenario:
Current local time (in Brisbane, Australia) between 11PM and 12AM (reportedly some other times as well but I found these to be the reliable ones to test)

User buys a subscription item:

Start Date
9/03/11 11:35 PM
Billing Period
3 Month cycle.
Repeats until suspended or canceled.

User Goes to checkout, confirms address, chooses payment option - the only option: PayPal, redirect to paypal.
At PayPal, user logs in, confirms purchase, redirect to our shop.
At ‘Review Order’ page, customer clicks ‘Place Order’ button.
Page refreshes and shows this error:

PayPal gateway has rejected request. Subscription start date should be greater than current date (#11505: Start Date should be greater than current date).

Stack trace:
exception ‘Mage_Core_Exception’ with message ‘PayPal NVP gateway errors: Subscription start date should be greater than current date (#11505: Start Date should be greater than current date). Correlation ID: 8ef59009ad615. Version: 60.0.’ in /var/www/magento/app/Mage.php:536
Stack trace:
#0 /var/www/magento/app/code/core/Mage/Paypal/Model/Api/Nvp.php(952): Mage::exception(’Mage_Core’, ‘PayPal NVP gate...’)
#1 /var/www/magento/app/code/core/Mage/Paypal/Model/Api/Nvp.php(914): Mage_Paypal_Model_Api_Nvp->_handleCallErrors(Array)
#2 /var/www/magento/app/code/core/Mage/Paypal/Model/Api/Nvp.php(778): Mage_Paypal_Model_Api_Nvp->call(’CreateRecurring...’, Array)
#3 /var/www/magento/app/code/core/Mage/Paypal/Model/Pro.php(367): Mage_Paypal_Model_Api_Nvp->callCreateRecurringPaymentsProfile()
#4 /var/www/magento/app/code/core/Mage/Paypal/Model/Express.php(283): Mage_Paypal_Model_Pro->submitRecurringProfile(Object(Mage_Sales_Model_Recurring_Profile), Object(Mage_Sales_Model_Quote_Payment))
#5 /var/www/magento/app/code/core/Mage/Sales/Model/Recurring/Profile.php(83): Mage_Paypal_Model_Express->submitRecurringProfile(Object(Mage_Sales_Model_Recurring_Profile), Object(Mage_Sales_Model_Quote_Payment))
#6 /var/www/magento/app/code/core/Mage/Sales/Model/Service/Quote.php(310): Mage_Sales_Model_Recurring_Profile->submit()
#7 /var/www/magento/app/code/core/Mage/Sales/Model/Service/Quote.php(201): Mage_Sales_Model_Service_Quote->_submitRecurringPaymentProfiles()
#8 /var/www/magento/app/code/core/Mage/Sales/Model/Service/Quote.php(216): Mage_Sales_Model_Service_Quote->submitNominalItems()
#9 /var/www/magento/app/code/core/Mage/Paypal/Model/Express/Checkout.php(491): Mage_Sales_Model_Service_Quote->submitAll()
#10 /var/www/magento/app/code/core/Mage/Paypal/Controller/Express/Abstract.php(249): Mage_Paypal_Model_Express_Checkout->place(’EC-1B846250MC12...’)
#11 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Paypal_Controller_Express_Abstract->placeOrderAction()
#12 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch(’placeOrder’)
#13 /var/www/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#14 /var/www/magento/app/code/core/Mage/Core/Model/App.php(304): Mage_Core_Controller_Varien_Front->dispatch()
#15 /var/www/magento/app/Mage.php(596): Mage_Core_Model_App->run(Array)
#16 /var/www/magento/index.php(78): Mage::run(’’, ‘store’)
#17 {main}

Has anyone else encountered this problem?
I’m guessing the date might be set in this object: Mage_Sales_Model_Recurring_Profile
That’s where I’m currently investigating.

This whole recurring profile implementation is rather dodgy by the looks of the relevant code.
Is there a working alternative?
I’ve had a look at the seemingly only other subscription module by AheadWorks and while it promises a lot, I’m not confident in the company to deliver since I’ve had issues with a different extension of theirs and support was rather lacking.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michael Birnbaum
Jr. Member
 
Total Posts:  5
Joined:  2010-01-16
 

This bug has reportedly been occurring between 11pm and 9am.
That’s almost half a day during which nobody can sign up for membership!

Has anybody got any suggestions?

I’ve set the server’s timezone/locale to match magento’s, set them to ETC, GMT, various US timezones without any change in behavior.
I’ve restarted Apache after each server timezone change of course.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michael Birnbaum
Jr. Member
 
Total Posts:  5
Joined:  2010-01-16
 

While the actual cause of the problem remains unknown to me, a fix that works is as follows:

Magento 1.4.2

app/code/core/Mage/Payment/Model/Recurring/Profile.php

/**
     * Determine nearest possible profile start date
     *
     * @param Zend_Date $minAllowed
     * @return Mage_Payment_Model_Recurring_Profile
     */
    public function setNearestStartDatetime(Zend_Date $minAllowed null)
    
{
        
// TODO: implement proper logic with invoking payment method instance
        
$date $minAllowed;
        if (!
$date || $date->getTimestamp() < time()) {
            $date 
= new Zend_Date(time());
        
}
// ++
        
$date->add(12Zend_Date::HOUR);
// ++
        
$this->setStartDatetime($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
        return 
$this;
    
}

I found adding 12 hours to be sufficient to tick the start date over to the next day, but to be sure you could just do $date->addDay(1); instead which could result in the start date being 2 days ahead.

Obviously you shouldn’t actually edit the core file, instead create your own module that overrides this core function.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michael Birnbaum
Jr. Member
 
Total Posts:  5
Joined:  2010-01-16
 

Not sure if anything changed between 1.4.2 and 1.6.1 but this fix didn’t work anymore.

New fix:
Mage/Payment/Models/Api/Nvp.php

// Line 193:
    protected $_exportToRequestFilters = array(
        
'AMT'         => '_filterAmount',
        
'ITEMAMT'     => '_filterAmount',
        
'TRIALAMT'    => '_filterAmount',
        
'SHIPPINGAMT' => '_filterAmount',
        
'TAXAMT'      => '_filterAmount',
        
'INITAMT'     => '_filterAmount',
        
'CREDITCARDTYPE' => '_filterCcType',
//        'PROFILESTARTDATE' => '_filterToPaypalDate',
        
'AUTOBILLAMT' => '_filterBillFailedLater',
        
'BILLINGPERIOD' => '_filterPeriodUnit',
        
'TRIALBILLINGPERIOD' => '_filterPeriodUnit',
        
'FAILEDINITAMTACTION' => '_filterInitialAmountMayFail',
        
'BILLINGAGREEMENTSTATUS' => '_filterBillingAgreementStatus',
        
'NOSHIPPING' => '_filterInt',
    );
// Uncomment the commented out filter

// Then insert this filter into the class
protected function _filterToPaypalDate($value)
{
    $date 
= new Zend_Date($value);
    
$date->add(1Zend_Date::DAY);
    return 
date('Y-m-d\T00:00:00\Z',  strtotime($date->toString()));
}

As usual, don’t modify the core files, create a custom module for it.

+1 sleepless night because apparently this bug only reared its head during my nighttime.

 
Magento Community Magento Community
Magento Community
Magento Community
 
seolutions
Jr. Member
 
Total Posts:  7
Joined:  2012-12-13
 

Hey I tried the NVP method, but now the IPN doesn’t send an Invoice or Order to the Magento Dashboard.

I checked the IPN report and it’s definitely a time issue.

Anyone got this resolved in magento 1.7.0.2 ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
seolutions
Jr. Member
 
Total Posts:  7
Joined:  2012-12-13
 

No one found a working fix for this? We are at our wits end.

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