Issues with Paypal plugin

Discussion in 'aMember Pro v.4' started by ges33, Feb 14, 2012.

  1. ges33

    ges33 Member

    Joined:
    Jan 20, 2012
    Messages:
    41
    Paypal plugin is still not functioning right. It runs into trouble when late night payments are made by user. Payments made during the day are fine. When I test with payments made between 11pm and 12mid, there are problems with how the recurring profile is set up in Paypal. User is caused to lose access even though user has active subscription in place.

    Here's a screenshot of a user just shortly after midnight, where his access is suddenly switched to expired even though an active recurring subscription is in place.

    user is expired.jpg

    A payment will eventually come through on 2/14 and user access will be restored, but user is without access for multiple hours. I am also testing this with varying length subscriptions: 2 days, 1 week, 1 month. The same problem is found in all the recurring profiles that are set up in Paypal with these varying subscription lengths. There is a gap that causes user access to expire in the middle of an active subscription.

    Here are the transaction logs for the above user that show discrepancy:

    dates are off.jpg
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    A question - what is the timezone of the server configured in PHP?

    Could you please do the following, upload the following script to your server as "time-test.php", then open in browser and post output here. Also notice GMT time from http://www.timeanddate.com/library/abbreviations/timezones/eu/gmt.html
    PHP:
    <?php
    echo date('Y-m-d H:i:s') . ' == GMT ' gmdate('Y-m-d H:i:s') . "<br />\n";
    echo 
    ini_get('date.timezone');
    Or send me FTP info (into the helpdesk with link to this topic) and I will do that for you.
  3. ges33

    ges33 Member

    Joined:
    Jan 20, 2012
    Messages:
    41
    The timezone of my server is: 'America/Chicago' which is Central Standard Time (CST), UTC/GMT -6 HOURS

    Here's what the script returns:
    2012-02-14 07:27:29 == GMT 2012-02-14 13:27:29

    There needs to be a way for aMember to recognize when GMT is into the next day and then set the 'rebill_date' to reflect the fact that the recurring profile won't be processing a payment for an extra day. In the above example, aMember should have set the 'rebill_date' to 2/14. Then payment and expected payment would be in sync and happening on the same day. Also, in a case like this, aMember should add a day to 'first_period'. In the above example, 'first_period' should be set to '2d' and 'second_period' should be set to '1d'. That would give the user a little more than a full day subscription on the first billing cycle, but it would ensure that the user didn't expire in the middle of their subscription.

    NOTE: I neglected to say this is for the PAYPAL PRO PLUGIN (not Paypal Standard).

    I'm hoping we can get this Paypal Pro plugin working soon so I can start using aMember.

    Thanks, Alex!
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    I believe the problem is in payment processing delay on paypal side.
    in your example you made payment 20 minutes before midnight. So aMember set profile start date to the same time as well. Obviously paypal will not charge customer immediately, and for example if there is two hours delay, payment will be rebilled on next day. And in result user will not have access for an two hours.
    To fix this issue edit /amember/library/Am/Paysystem/paypalApiRequest.php find this function:
    function createRecurringPaymentProfile(Invoice $invoice, CcRecord $cc = null, $token = null, $payerId = null)
    In that function change:
    PHP:
            $this->addPostParameter('PROFILESTARTDATE'gmdate('Y-m-d\TH:i:s.00\Z'
                
    strtotime($invoice->calculateRebillDate(1) . date'H:i:s'$invoice->getDi()->time))
            ));
    to

    PHP:
            $this->addPostParameter('PROFILESTARTDATE'gmdate('Y-m-d\TH:i:s.00\Z'
                
    strtotime($invoice->calculateRebillDate(1) . ' 00:00:01')
            ));
    So payment will always be rebilled from the start of rebilling date. So this will allow up to 24 hours delay in payment processing. Please test this and let me know does this helps or not?
  5. ges33

    ges33 Member

    Joined:
    Jan 20, 2012
    Messages:
    41
    That works, Alex--thanks!! Seems like the Paypal Pro plugin is doing what I need now.

    Thanks for getting it working!
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Ok. I will add this to release then. Thanks for the update!
  7. primesitemm

    primesitemm New Member

    Joined:
    Oct 12, 2009
    Messages:
    19
    Alex, we are having the same issue as ges33. We are using Paypal_r plugin.

    Upon paying via Paypal, our customers are given a 1 day free trial, after which they are charged a recurring monthly fee.

    However, after the 1 day free trial period ends (24 hours after signup) they are not charged the regular recurring monthly fee. Instead, it takes about 36 hours after signup for them to be charged the normal recurring monthly charge.

    When we upload that script on our server, the output we get is:
    Code:
    php > echo date('Y-m-d H:i(worry)') . ' == GMT ' . gmdate('Y-m-d H:i(worry)') . "<br />\n";
    2012-03-20 20:52:41 == GMT 2012-03-20 20:52:41<br />
    php > echo ini_get('date.timezone');
    php >
    Our server timezone is UTC and it seems paypal internally uses PDT. We suspect the issue is the amember paypal plugin is somehow setting the wrong timezone in the code that is sent to paypal.

    We have been in contact with Paypal technical support and they have asked for:
    "the actual button code created by the paypal plug in. Paypal cannot view the parameters being generated, so cannot troubleshoot it without that. Is there support for the site or the plugin that you can contact for assistance with generating that?"

    Can you help us out with this? Thanks
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    The problem is in 1 day Trial. I remember I've read about this on paypal site, although I can't find that article now.
    Paypal can take additional time in order to create subscription, so there can be issues with 1 day trial period.
    So just use longer trial periods.
  9. primesitemm

    primesitemm New Member

    Joined:
    Oct 12, 2009
    Messages:
    19
    Thanks for the reply. Is there anyway to get the
    "the actual button code created by the paypal plug-in (during signup)" so I can send to Paypal technical support?​
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    try to signup as regular user, when you are on paypal side, copy url from Browser location bar and send this url to them.
  11. vitavee

    vitavee New Member

    Joined:
    May 19, 2015
    Messages:
    3
    Hello,

    I have exactly the same problem with paypal_r plugin

    I have setup a 30-day $1 trial and then it's a recurring subscription.

    Some users' subscriptions are getting expired even though their subscription is still active as you can see in this screenshot:

    [​IMG]

    Is there anything I can change on my side to fix this?

    Thanks

Share This Page