cancel
Showing results for 
Search instead for 
Did you mean: 

What timezone is used for paypal recurring transactions? How can I change it?

What timezone is used for paypal recurring transactions? How can I change it?

My store is running 1.9.2.3. I use paypal recurring profiles. My local timezone is in Australia.

 

When a client signs up for a new subscription, I get an error that looks like this:

 

Payment transaction failed.

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

 

I gather this is timezone related, because if they try again at a different time of day, it works. My local timezone is Sydney (UTC+11 at the moment). My question is this. How is magento representing now() to paypal? Is a timezone applied? I have a feeling that my timezone is causing this to fail. However, I tried changing some timezone settings, but it is still failing. My server time is UTC, with NTP sync'd time. I am based in Australia, and I have a feeling a timezone setting somewhere in Magento may be causing this to fail.

 

Some previous posts elsewhere on this are:

I tried the patches listed in the first post, but that did not help. Your assistance is appreciated.

10 REPLIES 10

Re: What timezone is used for paypal recurring transactions? How can I change it?

I reviewed paypal logs, and I think this may be a bug. If you look at the text below, the response from the paypal gateway has a timestamp that is 1 second after the profilestartdate value that Magento sends to the gateway. Both values are in UTC. I am taking a wild guess here - but is it possible that a combination of internet latency (from Australia) combined with the time it takes to process a request causes a 1 second delay, and paypal sees that as "in the past" and generates the error?

 

My log data is below for your reference.

 

2016-03-11T13:23:25+00:00 DEBUG (7): Array

(

    [url] => https://api-3t.paypal.com/nvp

    [CreateRecurringPaymentsProfile] => Array

        (

            [PROFILESTARTDATE] => 2016-03-11 13:23:24

        )

 

    [response] => Array

        (

            [TIMESTAMP] => 2016-03-11T13:23:25Z

            [ACK] => Failure

            [VERSION] => 72.0

            [BUILD] => 18778392

            [L_ERRORCODE0] => 11505

            [L_SHORTMESSAGE0] => Start Date should be greater than current date

            [L_LONGMESSAGE0] => Subscription start date should be greater than current date

            [L_SEVERITYCODE0] => Error

        )

 

    [__pid] => 20505

)

 

Re: What timezone is used for paypal recurring transactions? How can I change it?

We do have the exact same problem in our shop as well (also Australian hosted) and it's driving both us and our clients nuts.

 

            [L_SHORTMESSAGE0] => Start Date should be greater than current date

            [L_LONGMESSAGE0] => Subscription start date should be greater than current date

 

We would really appreciate some pointers, help or assistance with this matter, as we're loosing sales and faith in Magento over this.

Re: What timezone is used for paypal recurring transactions? How can I change it?

Hello Magento Community.

 

Help really required here. To quote one of my clients:

"If this is a Magento problem, maybe it's time to consider alternatives."

Magento does everything I need, except handle subscription payments. If this is just broken and there is no workaround, then someone tell me and I'll make a decision on an alternate solution.

Re: What timezone is used for paypal recurring transactions? How can I change it?

Hello gKuhnert,

 

I have same issue since not sure if it is due to the latest patch I am using Magento 1.9.2.2. Have you found a solution? Appreciate if you can share it drives me nuts as well as payments cannot proceed.

 

Best,

 

Joel

Re: What timezone is used for paypal recurring transactions? How can I change it?

have you tried to set  exact same time and date in your server, php, and magento and Paypal account?

what you have set here: Customer Can Define Start Date

------------
MagenX - Magento and Server optimization

Re: What timezone is used for paypal recurring transactions? How can I change it?

Team.

 

I have found the root cause of this after some significant research - and assistance from Paypal. First things first, this is a 100% confirmed Magento bug.

 

Lets talk about the API. 

 

https://developer.paypal.com/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_...

 

PROFILESTARTDATE

(Required) The date when billing for this profile begins.

Note: The profile may take up to 24 hours for activation.

Character length and limitations: 

Must be a valid date, in UTC/GMT format; for example, 2013-08-24T05:38:48Z. No wildcards are allowed.

 

This is the paypal API specification for the start date field. In my discussion with paypal, they indicated that the date MUST be in this format. The default if not specified MAY be in pacific time, but there is no guarantee there.

 

Interesting observation. I did a test today. In the log file payment_paypal_express. log, it says:

 

[PROFILESTARTDATE] => 2016-04-21 23:10:36

 

Paypal confirmed the format of the timestamp that Magento sends to the Paypal API is the root cause of the problem.

 

 

Re: What timezone is used for paypal recurring transactions? How can I change it?

 

 

Updates:

 

In /app/code/core/Mage/Paypal/Model/Api/Nvp.php, we see

 

    /**
     * Filter callbacks for preparing internal amounts to NVP request 
     *
     * @var array
     */
    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',
    );

Notice the profile start date is commented out. Anyone know why?

 

Lets look at 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());
        }       
        $this->setStartDatetime($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
        return $this;
    }

 

So. This function uses a date format for what will be displayed to Paypal, that will be formatted with "DATETIME_INTERNAL_FORMAT" ... 

 

In includes/src/Varien_Date.php, we see

    const DATETIME_INTERNAL_FORMAT = 'yyyy-MM-dd HH:mm:ss';

Hmm. Smoking gun. When we look at my debug messages, we see that the date provided to Paypal is formatted in accordance with the Magento internal format, not as specified by the Paypal API specification.

 

 

 

Re: What timezone is used for paypal recurring transactions? How can I change it?

would love to see the outcome of your investigation as I too am getting this error message (again, in AU)

Re: What timezone is used for paypal recurring transactions? How can I change it?

Hi Cvanoosbree.

 

The results of my investigation are here...

 

https://community.magento.com/t5/Technical-Issues/ADVISORY-CONFIRMED-bug-in-Magento-Paypal-API-Code/...

 

I also posted a bug report

 

https://www.magentocommerce.com/bug-tracking/issue/index/id/1384

 

No response to either. A little underwhelming...