Skip to content

Failing trying to get transactions more than 3 years old #26

@ivanfor

Description

@ivanfor

Hi.
Script was failing with the following error:

root@ffpi:/var/www/html# php artisan sync
Start pulling data from PayPal

In PayPal.php line 62:
                                                
  Call to undefined method stdClass::getBody()  

This error was mentioned in another bug, but seemed not to be the same thing.
After debugging in commandline, I got the following message:

ivan@pepinillo:/tmp$ curl -X GET "https://api-m.paypal.com/v1/reporting/transactions?page=1&page_size=1&fields=all" -H "Content-Type: application/json" -H "Authorization: Bearer xxxxxxxuJb4sFuA" -G --data-urlencode "start_date=2022-07-01T00:00:00-0700" --data-urlencode "end_date=2022-07-31T23:59:59-0700" | jq                                                                                      
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   308  100   308    0     0    646      0 --:--:-- --:--:-- --:--:--   645
{
  "name": "INVALID_REQUEST",
  "message": "Request is not well-formed, syntactically incorrect, or violates schema.",
  "debug_id": "b014e532dc5c5",
  "details": [
    {
      "field": "start_date",
      "value": "2022-07-01T00:00:00-0700",
      "location": "query",
      "issue": "Start Date provided is before the allowed range of 3 years."
    }
  ],
  "links": []
}

Reviewing the code I realized syncing is going recursively back in time forever, so I've temporarily fixed it adding:

    if ($date->lt(Carbon::now()->subYears(3))) {
        return;
    }

... in syncPayPal() function, but it gets overwritten on every docker deploy.

I don't know if this 3 years limit is something for everybody or not. Anybody knows?
In any case, do you want mi to create a PR with the fix I used?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions