Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-6407

ContributionProcessor.php fails silently when PayPal truncates TransactionSearches at 100.

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.1.3
    • Fix Version/s: 3.2
    • Component/s: CiviContribute
    • Labels:
      None

      Description

      PayPal's API will only return a maximum of 100 transactions in a TransactionSearch API call. ContributionProcessor.php gives no warning to the user that results were truncated and so falsely leads the user to believe that all contributions were processed for the given date range, rather that simply the first 100. ContributionProcessor.php should attempt to process all contributions, or at the very least warn the user that results were truncated.

      Sadly, not only will PayPal only send a max of 100 transactions, but they offer no functionality to page, or request the next set. They simply alert you that the results were truncated and leave it to you to figure out how to amend your StartDate and EndDate parameters to avoid retrieving more than 100 transactions. This is something that cannot be known in advance, so the solution implemented in the attached patch is to only request one day at a time for a given date range. It's unlikely that most installations will receive more than 100 contributions to PayPal in a single day, but should that happen (and it has happened on occasion with us), with the following patch at the very least ContributionProcessor.php will emit a warning so that this problem can be resolved manually.

      Also, there was a fairly large inefficiency in ContributionProcessor.php where it would fetch all the transactions for a date range from PayPal, then proceed to fetch details via GetTransactionDetails for each and every one of them, many times only to find that the contribution was already processed. Since the list of transactions returned by a TransactionSearch includes all necessary data to check for transactions that were already processed there is no need to fetch details from PayPal for those. The attached patch implements a functionality that will only ask for transaction details from PayPal if the trxn_id doesn't already exist in the database. This drastically speeds things up.

        Attachments

          Activity

            People

            • Assignee:
              rahulbile Rahul Bile
              Reporter:
              nkinkade Nathan Kinkade
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: