robvankeilegom / firefly-III-paypal-importer

PayPal Data Importer for Firefly III
48 stars 3 forks source link

Method App\Console\Commands\Sync::syncPayPal does not exist #1

Closed m4t7 closed 2 years ago

m4t7 commented 2 years ago

Good day,

this project seems interessting. I followed your install instructions.

Unfortunatly I get the following issue after running artisan sync

php artisan sync

In Macroable.php line 113:

  Method App\Console\Commands\Sync::syncPayPal does not exist.  

Same error is shown in the log.

storage/logs/lumen-2022-03-05.log ``` #0 /home/user/github/firefly-III-paypal-importer/app/Console/Commands/Sync.php(31): Illuminate\\Console\\Command->__call() #1 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/container/BoundMethod.php(36): App\\Console\\Commands\\Sync->handle() #2 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #3 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #4 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #5 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/container/Container.php(653): Illuminate\\Container\\BoundMethod::call() #6 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/console/Command.php(136): Illuminate\\Container\\Container->call() #7 /home/user/github/firefly-III-paypal-importer/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute() #8 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run() #9 /home/user/github/firefly-III-paypal-importer/vendor/symfony/console/Application.php(1015): Illuminate\\Console\\Command->run() #10 /home/user/github/firefly-III-paypal-importer/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand() #11 /home/user/github/firefly-III-paypal-importer/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun() #12 /home/user/github/firefly-III-paypal-importer/vendor/illuminate/console/Application.php(94): Symfony\\Component\\Console\\Application->run() #13 /home/user/github/firefly-III-paypal-importer/vendor/laravel/lumen-framework/src/Console/Kernel.php(116): Illuminate\\Console\\Application->run() #14 /home/user/github/firefly-III-paypal-importer/artisan(35): Laravel\\Lumen\\Console\\Kernel->handle() #15 {main} "} [2022-03-05 12:28:16] local.ERROR: Method App\Console\Commands\Sync::syncPayPal does not exist. {"exception":"[object] (BadMethodCallException(code: 0): Method App\\Console\\Commands\\Sync::syncPayPal does not exist. at /home/user/github/firefly-III-paypal-importer/vendor/illuminate/macroable/Traits/Macroable.php:113) [stacktrace] ```

Macroable.php function that contains line 113:

110     public function __call($method, $parameters)
111     {
112         if (! static::hasMacro($method)) {
113             throw new BadMethodCallException(sprintf(
114                 'Method %s::%s does not exist.', static::class, $method
115             ));
116         }

I assume Sync::syncPayPal is unspecified or not on the expected location.

If I can debug or otherwise be helpful let me know.

robvankeilegom commented 2 years ago

@m4t7 Thanks for the issue. There was indeed a typo & i fixed it for you. If you run git pull to get the latest version you'll be alright. Let me know how it goes.

m4t7 commented 2 years ago

@robvankeilegom thanks for your quick reply. The inital issue is solved, now I run into new issues. :/

[user@manjaro firefly-III-paypal-importer]$ php artisan sync
Start pulling data from PayPal

In Connection.php line 712:

  could not find driver (SQL: select * from "payers" where ("pp_id" = 46VJKHTKQ5QPA) limit 1)  

In Connector.php line 70:

  could not find driver  
storage/logs/lumen-2022-03-07.log ``` [2022-03-07 07:39:57] local.ERROR: could not find driver (SQL: select * from "payers" where ("pp_id" = 46VJKHTKQ5QPA) limit 1) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 0): could not find driver (SQL: select * from \"payers\" where (\"pp_id\" = 46VJKHTKQ5QPA) limit 1) at /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Connection.php:712) [stacktrace] #0 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Connection.php(672): Illuminate\\Database\\Connection->runQueryCallback() #1 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Connection.php(376): Illuminate\\Database\\Connection->run() #2 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Query/Builder.php(2414): Illuminate\\Database\\Connection->select() #3 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Query/Builder.php(2402): Illuminate\\Database\\Query\\Builder->runSelect() #4 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Query/Builder.php(2936): Illuminate\\Database\\Query\\Builder->Illuminate\\Database\\Query\\{closure}() #5 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Query/Builder.php(2403): Illuminate\\Database\\Query\\Builder->onceWithColumns() #6 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Eloquent/Builder.php(625): Illuminate\\Database\\Query\\Builder->get() #7 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Eloquent/Builder.php(609): Illuminate\\Database\\Eloquent\\Builder->getModels() #8 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Concerns/BuildsQueries.php(294): Illuminate\\Database\\Eloquent\\Builder->get() #9 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Eloquent/Builder.php(474): Illuminate\\Database\\Eloquent\\Builder->first() #10 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Eloquent/Builder.php(508): Illuminate\\Database\\Eloquent\\Builder->firstOrNew() #11 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/support/Traits/ForwardsCalls.php(23): Illuminate\\Database\\Eloquent\\Builder->updateOrCreate() #12 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Eloquent/Model.php(2132): Illuminate\\Database\\Eloquent\\Model->forwardCallTo() #13 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Eloquent/Model.php(2144): Illuminate\\Database\\Eloquent\\Model->__call() #14 /home/matt/github/firefly-III-paypal-importer/app/Sync.php(55): Illuminate\\Database\\Eloquent\\Model::__callStatic() #15 /home/matt/github/firefly-III-paypal-importer/app/Console/Commands/Sync.php(34): App\\Sync->syncPayPal() #16 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/container/BoundMethod.php(36): App\\Console\\Commands\\Sync->handle() #17 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #18 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #19 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #20 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/container/Container.php(653): Illuminate\\Container\\BoundMethod::call() #21 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/console/Command.php(136): Illuminate\\Container\\Container->call() #22 /home/matt/github/firefly-III-paypal-importer/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute() #23 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run() #24 /home/matt/github/firefly-III-paypal-importer/vendor/symfony/console/Application.php(1015): Illuminate\\Console\\Command->run() #25 /home/matt/github/firefly-III-paypal-importer/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand() #26 /home/matt/github/firefly-III-paypal-importer/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun() #27 /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/console/Application.php(94): Symfony\\Component\\Console\\Application->run() #28 /home/matt/github/firefly-III-paypal-importer/vendor/laravel/lumen-framework/src/Console/Kernel.php(116): Illuminate\\Console\\Application->run() #29 /home/matt/github/firefly-III-paypal-importer/artisan(35): Laravel\\Lumen\\Console\\Kernel->handle() #30 {main} [previous exception] [object] (PDOException(code: 0): could not find driver at /home/matt/github/firefly-III-paypal-importer/vendor/illuminate/database/Connectors/Connector.php:70) [stacktrace] ```

Here is my .env File, I assume the DB connection is not working as expected

.env ``` APP_NAME=Lumen APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost APP_TIMEZONE=UTC LOG_CHANNEL=stack LOG_SLACK_WEBHOOK_URL= DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=/home/matt/github/firefly-III-paypal-importer/database/database.sqlite DB_USERNAME= DB_PASSWORD= CACHE_DRIVER=file QUEUE_CONNECTION=sync PAYPAL_CLIENT_ID="....." PAYPAL_CLIENT_SECRET="....." FIREFLY_TOKEN="...." FIREFLY_URI=https://cash....rpn FIREFLY_PAYPAL_ACCOUNT_ID=97 ```
robvankeilegom commented 2 years ago

@m4t7 This means your local environment isn't configured to support sqlite. If you're on a Debian based system like Ubuntu you'll have to install php-sqlite with sudo apt install php-sqlite. After that you'll have to restart your web server.

I'm planning to put the application in a docker container like the official firefly-importer once i have some free time. So you'll be able to start it with a single command.

m4t7 commented 2 years ago

@robvankeilegom ok thanks for that explanation.

I'm using Arch Linux (Manjaro) as my daily driver and normal work environment. I installed php-sqlite from official manjaro repository. Unfortunatly I get the same error. I don't know what I forget. Do I need a websever on top? I thought with composer everything was installed.

Here are all my sqlite specifc packages - sqlite - lib32-sqlite - php-sqlite

I have specified the full path for the database in the environment file and should have every dependency.

robvankeilegom commented 2 years ago

@m4t7 Is was wrong about the web server. You're running php from the CLI, so you won't have to restart a web server. I added the necessary files to run the app in Docker.

The README.md file was updated as well. Make sure the DB_DATABASE field in your .env file has exactly the same value as in .env.example before building the container.

m4t7 commented 2 years ago

@robvankeilegom

Thanks for your effort, but it still fails.

I adjusted your Dockerfile and docker-compse.yml a little bit to get my own CA_CERT installed while the container is created and map the database path within the docker-compose.

File Change - added Volume

    volumes:
      - ./database:/var/www/html

This code maps the database path from the actual folder e.g. "firefly-III-paypal-importer/database". The .env File still contains /var/www/html/database.sqlite

Complete docker-compose File

$ cat docker-compose.yml 
version: '3'
services:
  firefly-iii-paypal-importer:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: firefly-iii-paypal-importer
    restart: unless-stopped
    tty: true
    working_dir: /var/www/html
    volumes:
      - ./database:/var/www/html

File Change - added RUN actions

I added at the end of the Dockerfile two RUN actions

RUN cp /var/www/html/database/CA_CERT.crt /usr/local/share/ca-certificates/
RUN /usr/sbin/update-ca-certificates

Build and Run

$ docker-compose up -d ``` $ docker-compose up -d Sending build context to Docker daemon 6.952MB Step 1/12 : FROM php:8.1.3-apache ---> f414fe2d15cb Step 2/12 : RUN apt-get update && apt-get install -y git curl zip unzip ---> Running in 7e13452e4d1d Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB] Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB] Get:3 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [122 kB] Get:4 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB] Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB] Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2596 B] Fetched 8507 kB in 2s (3748 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... curl is already the newest version (7.74.0-1.3+deb11u1). The following additional packages will be installed: git-man less libbsd0 libcbor0 libcurl3-gnutls libedit2 liberror-perl libfido2-1 libmd0 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client xauth Suggested packages: gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn keychain libpam-ssh monkeysphere ssh-askpass The following NEW packages will be installed: git git-man less libbsd0 libcbor0 libcurl3-gnutls libedit2 liberror-perl libfido2-1 libmd0 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client unzip xauth zip 0 upgraded, 21 newly installed, 0 to remove and 1 not upgraded. Need to get 10.9 MB of archives. After this operation, 49.2 MB of additional disk space will be used. Get:1 http://deb.debian.org/debian bullseye/main amd64 less amd64 551-2 [133 kB] Get:2 http://deb.debian.org/debian bullseye/main amd64 libmd0 amd64 1.0.3-3 [28.0 kB] Get:3 http://deb.debian.org/debian bullseye/main amd64 libbsd0 amd64 0.11.3-1 [108 kB] Get:4 http://deb.debian.org/debian bullseye/main amd64 libedit2 amd64 3.1-20191231-2+b1 [96.7 kB] Get:5 http://deb.debian.org/debian bullseye/main amd64 libcbor0 amd64 0.5.0+dfsg-2 [24.0 kB] Get:6 http://deb.debian.org/debian bullseye/main amd64 libfido2-1 amd64 1.6.0-2 [53.3 kB] Get:7 http://deb.debian.org/debian bullseye/main amd64 openssh-client amd64 1:8.4p1-5 [929 kB] Get:8 http://deb.debian.org/debian bullseye/main amd64 libcurl3-gnutls amd64 7.74.0-1.3+deb11u1 [338 kB] Get:9 http://deb.debian.org/debian bullseye/main amd64 liberror-perl all 0.17029-1 [31.0 kB] Get:10 http://deb.debian.org/debian bullseye/main amd64 git-man all 1:2.30.2-1 [1827 kB] Get:11 http://deb.debian.org/debian bullseye/main amd64 git amd64 1:2.30.2-1 [5527 kB] Get:12 http://deb.debian.org/debian bullseye/main amd64 libxau6 amd64 1:1.0.9-1 [19.7 kB] Get:13 http://deb.debian.org/debian bullseye/main amd64 libxdmcp6 amd64 1:1.1.2-3 [26.3 kB] Get:14 http://deb.debian.org/debian bullseye/main amd64 libxcb1 amd64 1.14-3 [140 kB] Get:15 http://deb.debian.org/debian bullseye/main amd64 libx11-data all 2:1.7.2-1 [311 kB] Get:16 http://deb.debian.org/debian bullseye/main amd64 libx11-6 amd64 2:1.7.2-1 [772 kB] Get:17 http://deb.debian.org/debian bullseye/main amd64 libxext6 amd64 2:1.3.3-1.1 [52.7 kB] Get:18 http://deb.debian.org/debian bullseye/main amd64 libxmuu1 amd64 2:1.1.2-2+b3 [23.9 kB] Get:19 http://deb.debian.org/debian bullseye/main amd64 unzip amd64 6.0-26 [171 kB] Get:20 http://deb.debian.org/debian bullseye/main amd64 xauth amd64 1:1.1-1 [40.5 kB] Get:21 http://deb.debian.org/debian bullseye/main amd64 zip amd64 3.0-12 [232 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 10.9 MB in 1s (13.6 MB/s) Selecting previously unselected package less. (Reading database ... 14070 files and directories currently installed.) Preparing to unpack .../00-less_551-2_amd64.deb ... Unpacking less (551-2) ... Selecting previously unselected package libmd0:amd64. Preparing to unpack .../01-libmd0_1.0.3-3_amd64.deb ... Unpacking libmd0:amd64 (1.0.3-3) ... Selecting previously unselected package libbsd0:amd64. Preparing to unpack .../02-libbsd0_0.11.3-1_amd64.deb ... Unpacking libbsd0:amd64 (0.11.3-1) ... Selecting previously unselected package libedit2:amd64. Preparing to unpack .../03-libedit2_3.1-20191231-2+b1_amd64.deb ... Unpacking libedit2:amd64 (3.1-20191231-2+b1) ... Selecting previously unselected package libcbor0:amd64. Preparing to unpack .../04-libcbor0_0.5.0+dfsg-2_amd64.deb ... Unpacking libcbor0:amd64 (0.5.0+dfsg-2) ... Selecting previously unselected package libfido2-1:amd64. Preparing to unpack .../05-libfido2-1_1.6.0-2_amd64.deb ... Unpacking libfido2-1:amd64 (1.6.0-2) ... Selecting previously unselected package openssh-client. Preparing to unpack .../06-openssh-client_1%3a8.4p1-5_amd64.deb ... Unpacking openssh-client (1:8.4p1-5) ... Selecting previously unselected package libcurl3-gnutls:amd64. Preparing to unpack .../07-libcurl3-gnutls_7.74.0-1.3+deb11u1_amd64.deb ... Unpacking libcurl3-gnutls:amd64 (7.74.0-1.3+deb11u1) ... Selecting previously unselected package liberror-perl. Preparing to unpack .../08-liberror-perl_0.17029-1_all.deb ... Unpacking liberror-perl (0.17029-1) ... Selecting previously unselected package git-man. Preparing to unpack .../09-git-man_1%3a2.30.2-1_all.deb ... Unpacking git-man (1:2.30.2-1) ... Selecting previously unselected package git. Preparing to unpack .../10-git_1%3a2.30.2-1_amd64.deb ... Unpacking git (1:2.30.2-1) ... Selecting previously unselected package libxau6:amd64. Preparing to unpack .../11-libxau6_1%3a1.0.9-1_amd64.deb ... Unpacking libxau6:amd64 (1:1.0.9-1) ... Selecting previously unselected package libxdmcp6:amd64. Preparing to unpack .../12-libxdmcp6_1%3a1.1.2-3_amd64.deb ... Unpacking libxdmcp6:amd64 (1:1.1.2-3) ... Selecting previously unselected package libxcb1:amd64. Preparing to unpack .../13-libxcb1_1.14-3_amd64.deb ... Unpacking libxcb1:amd64 (1.14-3) ... Selecting previously unselected package libx11-data. Preparing to unpack .../14-libx11-data_2%3a1.7.2-1_all.deb ... Unpacking libx11-data (2:1.7.2-1) ... Selecting previously unselected package libx11-6:amd64. Preparing to unpack .../15-libx11-6_2%3a1.7.2-1_amd64.deb ... Unpacking libx11-6:amd64 (2:1.7.2-1) ... Selecting previously unselected package libxext6:amd64. Preparing to unpack .../16-libxext6_2%3a1.3.3-1.1_amd64.deb ... Unpacking libxext6:amd64 (2:1.3.3-1.1) ... Selecting previously unselected package libxmuu1:amd64. Preparing to unpack .../17-libxmuu1_2%3a1.1.2-2+b3_amd64.deb ... Unpacking libxmuu1:amd64 (2:1.1.2-2+b3) ... Selecting previously unselected package unzip. Preparing to unpack .../18-unzip_6.0-26_amd64.deb ... Unpacking unzip (6.0-26) ... Selecting previously unselected package xauth. Preparing to unpack .../19-xauth_1%3a1.1-1_amd64.deb ... Unpacking xauth (1:1.1-1) ... Selecting previously unselected package zip. Preparing to unpack .../20-zip_3.0-12_amd64.deb ... Unpacking zip (3.0-12) ... Setting up libxau6:amd64 (1:1.0.9-1) ... Setting up unzip (6.0-26) ... Setting up libcbor0:amd64 (0.5.0+dfsg-2) ... Setting up less (551-2) ... Setting up libcurl3-gnutls:amd64 (7.74.0-1.3+deb11u1) ... Setting up liberror-perl (0.17029-1) ... Setting up zip (3.0-12) ... Setting up libx11-data (2:1.7.2-1) ... Setting up libmd0:amd64 (1.0.3-3) ... Setting up git-man (1:2.30.2-1) ... Setting up libfido2-1:amd64 (1.6.0-2) ... Setting up libbsd0:amd64 (0.11.3-1) ... Setting up libxdmcp6:amd64 (1:1.1.2-3) ... Setting up libxcb1:amd64 (1.14-3) ... Setting up libedit2:amd64 (3.1-20191231-2+b1) ... Setting up git (1:2.30.2-1) ... Setting up libx11-6:amd64 (2:1.7.2-1) ... Setting up libxmuu1:amd64 (2:1.1.2-2+b3) ... Setting up openssh-client (1:8.4p1-5) ... Setting up libxext6:amd64 (2:1.3.3-1.1) ... Setting up xauth (1:1.1-1) ... Processing triggers for libc-bin (2.31-13+deb11u2) ... Processing triggers for mailcap (3.69) ... Removing intermediate container 7e13452e4d1d ---> 7ed04f4c506f Step 3/12 : RUN sed -i -e "s/html/html\/public/g" /etc/apache2/sites-enabled/000-default.conf ---> Running in 263ae722e080 Removing intermediate container 263ae722e080 ---> 933ecc4a816a Step 4/12 : RUN a2enmod rewrite ---> Running in cc4e715125f0 Enabling module rewrite. To activate the new configuration, you need to run: service apache2 restart Removing intermediate container cc4e715125f0 ---> 896d2484f790 Step 5/12 : COPY --from=composer:latest /usr/bin/composer /usr/bin/composer ---> 0066808f5e50 Step 6/12 : WORKDIR /var/www/html ---> Running in ed9fcfbeb20c Removing intermediate container ed9fcfbeb20c ---> ce4405467d74 Step 7/12 : COPY . . ---> 040f8d1b93c5 Step 8/12 : RUN composer install --no-interaction --optimize-autoloader --no-dev ---> Running in bba5f364a471 Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 0 installs, 0 updates, 35 removals - Removing theseer/tokenizer (1.2.1) - Removing sebastian/version (3.0.2) - Removing sebastian/type (2.3.4) - Removing sebastian/resource-operations (3.0.3) - Removing sebastian/recursion-context (4.0.4) - Removing sebastian/object-reflector (2.0.4) - Removing sebastian/object-enumerator (4.0.4) - Removing sebastian/lines-of-code (1.0.3) - Removing sebastian/global-state (5.0.5) - Removing sebastian/exporter (4.0.4) - Removing sebastian/environment (5.1.3) - Removing sebastian/diff (4.0.4) - Removing sebastian/complexity (2.0.2) - Removing sebastian/comparator (4.0.6) - Removing sebastian/code-unit-reverse-lookup (2.0.3) - Removing sebastian/code-unit (1.0.8) - Removing sebastian/cli-parser (1.0.1) - Removing phpunit/phpunit (9.5.16) - Removing phpunit/php-timer (5.0.3) - Removing phpunit/php-text-template (2.0.4) - Removing phpunit/php-invoker (3.1.1) - Removing phpunit/php-file-iterator (3.0.6) - Removing phpunit/php-code-coverage (9.2.13) - Removing phpspec/prophecy (v1.15.0) - Removing phpdocumentor/type-resolver (1.6.0) - Removing phpdocumentor/reflection-docblock (5.3.0) - Removing phpdocumentor/reflection-common (2.2.0) - Removing phar-io/version (3.2.1) - Removing phar-io/manifest (2.0.3) - Removing nikic/php-parser (v4.13.2) - Removing myclabs/deep-copy (1.10.2) - Removing mockery/mockery (1.5.0) - Removing hamcrest/hamcrest-php (v2.0.1) - Removing fakerphp/faker (v1.19.0) - Removing doctrine/instantiator (1.4.0) 0/25 [>---------------------------] 0% 10/25 [===========>----------------] 40% 25/25 [============================] 100% Generating optimized autoload files 40 packages you are using are looking for funding. Use the `composer fund` command to find out more! Removing intermediate container bba5f364a471 ---> b2509bfa435b Step 9/12 : RUN php artisan key:generate ---> Running in d1b758dbc993 Application key [SP6y0fPLPALOIufhNjKzgwgQteaOA7lb] set successfully. Removing intermediate container d1b758dbc993 ---> fdaeb265293a Step 10/12 : RUN php artisan migrate --force ---> Running in aeb2378df784 Migration table created successfully. Migrating: 2022_02_24_205513_create_payers_table Migrated: 2022_02_24_205513_create_payers_table (15.19ms) Migrating: 2022_02_24_205754_create_transactions_table Migrated: 2022_02_24_205754_create_transactions_table (16.08ms) Removing intermediate container aeb2378df784 ---> 1afbb59ec556 Step 11/12 : RUN cp /var/www/html/database/CA_CERT.crt /usr/local/share/ca-certificates/ ---> Running in 2fa88a8c98be Removing intermediate container 2fa88a8c98be ---> c26dfea95407 Step 12/12 : RUN /usr/sbin/update-ca-certificates ---> Running in ad731e49f494 Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Removing intermediate container ad731e49f494 ---> d1fa31a9a410 Successfully built d1fa31a9a410 Successfully tagged firefly-iii-paypal-importer_firefly-iii-paypal-importer:latest [+] Running 2/2 ⠿ Network firefly-iii-paypal-importer_default Created 0.1s ⠿ Container firefly-iii-paypal-importer Started 0.6s ```

Issue

$ docker exec firefly-iii-paypal-importer php artisan sync
Could not open input file: artisan
$ docker exec -it firefly-iii-paypal-importer bash
root@013c204d1248:/var/www/html# php artisan sync
Could not open input file: artisan
root@013c204d1248:/var/www/html# ls
CA_CERT.crt  database.sqlite  factories migrations  seeders
m4t7 commented 2 years ago

Oh man my fault, I added the false volume.

Corrected Volume

    volumes:
      - ./database:/var/www/html/database

Environment File has the value from example.

$ cat .env | grep DB_DA
DB_DATABASE=/var/www/html/database/database.sqlite

New Issue

$ docker exec firefly-iii-paypal-importer php artisan sync
Start pulling data from PayPal

In Connection.php line 712:

  SQLSTATE[HY000]: General error: 1 no such table: payers (SQL: select * from  
   "payers" where ("pp_id" = 46VJKHTKQ5QPA) limit 1)                           

In Connection.php line 368:

  SQLSTATE[HY000]: General error: 1 no such table: payers       

Inside Docker Container

$ docker exec -it firefly-iii-paypal-importer bash
root@4481b8df472c:/var/www/html# ls
Dockerfile  app      bootstrap      composer.lock  database        phpunit.xml  resources  storage  vendor
README.md   artisan  composer.json  config     docker-compose.yml  public       routes     tests
root@4481b8df472c:/var/www/html# cd database/
root@4481b8df472c:/var/www/html/database# ls
CA-CERT.crt  database.sqlite  factories migrations  seeders

No payers file is generated. Do you see why?

robvankeilegom commented 2 years ago

@m4t7 You're getting there. You'll have to run php artisan migrate --force to generate the table you need.

m4t7 commented 2 years ago

@robvankeilegom still failing , this time a new issue in Sync.php

$ docker exec -it firefly-iii-paypal-importer bash
root@4481b8df472c:/var/www/html# php artisan migrate --force
Migration table created successfully.
Migrating: 2022_02_24_205513_create_payers_table
Migrated:  2022_02_24_205513_create_payers_table (15.48ms)
Migrating: 2022_02_24_205754_create_transactions_table
Migrated:  2022_02_24_205754_create_transactions_table (18.22ms)
root@4481b8df472c:/var/www/html# php artisan sync
Start pulling data from PayPal

In Sync.php line 65:

  Undefined property: stdClass::$item_details  
m4t7 commented 2 years ago

Good day @robvankeilegom hope all is well. Regarding the issue that I'm facing, I do not understand why this happens.

Source Code in app/Sync.php:

65            $cartItems = ($record->cart_info->item_details);
66
67            $transaction = Transaction::updateOrCreate([
68                'pp_id' => $record->transaction_info->transaction_id,
69            ], [
70                'reference_id'    => $reference,
71                'event_code'      => $record->transaction_info->transaction_event_code,
72                'initiation_date' => $record->transaction_info->transaction_initiation_date,
73                'currency'        => $record->transaction_info->transaction_amount->currency_code,
74                'value'           => $record->transaction_info->transaction_amount->value,
75                'description'     => implode(', ', array_column($cartItems, 'item_name')),
76            ]);

In the developer documentation item_details array is specified and should contain item_name that is used to populate the description. Is this correct? https://developer.paypal.com/api/transaction-search/v1/#definition-item_detail

Here is my sqlite database no_descripton

Do you see any issue?

robvankeilegom commented 2 years ago

I'm sorry for taking so long to respond. I looked into the documentation last week and concluded the same as you. I'm not sure why the call isn't returning an item_detail field. It's only used for the transaction description so we could prolly omit it.

If you're willing to debug this further you could make an api call with a tool like Postman and check out the transaction. The call requires a start_date parameter where you can pass the oldest that thats visible in your sqlite database. This application retrieves transaction from newest to oldest, so the problem should be the transaction right after the last transaction in your database.

I'll change the code to omit the description if the item_detail isn't available later this week.

m4t7 commented 2 years ago

No worries.

I looked into my paypal account and I see that the app uses the payer name (e.g. alternative full name) as the transaction description if no transaction_note is found. (I assume the transaction_note is populated into the item_name)

In my example below the transaction contains an item_name":"2000640935" but that info is not useful at all and oblivious not imported into the transaction database table. (also not used in the app)

It would be great if you could check if the database contains a description value, and if not then use the alternate_full_name field and maybe extend it with the invoice_id , that mostly contain more useful information.

"payer_name":{"alternate_full_name":"Food GmbH"},

and

"invoice_id":"W21FEIKHY24RWPF5"

= Description

Food GmbH - Invoice ID: W21FEIKHY24RWPF5

JSON Response Paypal Transaction

Here are obfuscated transactions **Transaction without transaction_note and with item_name that has no description value in the database** ```json { "transaction_details": [ { "transaction_info": { "paypal_account_id": "2A12XXQAMF71F", "transaction_id": "2B258349616013924", "transaction_event_code": "T0006", "transaction_initiation_date": "2022-02-20T20:42:13+0000", "transaction_updated_date": "2022-02-20T20:42:13+0000", "transaction_amount": { "currency_code": "EUR", "value": "-113.64" }, "transaction_status": "S", "invoice_id": "W21FEIKHY24RWPF5", "custom_field": "FoodGmbHDE:pub.v2.1952631254249aw.nR0Qe4peb_Wd-hkZkbOlo-wAm90QpI3H_VLU5MqM6S_8:614714:W21FEIKHY24RWPF5:paypal", "protection_eligibility": "02", "instrument_type": "PAYPAL" }, "payer_info": { "account_id": "53465QAMF71F", "email_address": "service@foodgmbh.be", "address_status": "Y", "payer_status": "Y", "payer_name": { "alternate_full_name": "Food GmbH" }, "country_code": "BE" }, "shipping_info": { "name": "m4t7", "address": { "line1": "12 Foodstreet", "city": "Food Street", "country_code": "BE", "postal_code": "12345" } }, "cart_info": { "item_details": [ { "item_name": "2000640935", "item_quantity": "1", "item_unit_price": { "currency_code": "EUR", "value": "45.64" }, "item_amount": { "currency_code": "EUR", "value": "45.64" }, "total_item_amount": { "currency_code": "EUR", "value": "45.64" }, "invoice_number": "W21FEIKHY24RWPF5" } ] }, "store_info": {}, "auction_info": {}, "incentive_info": {} } ], "account_number": "K2AX8R5JWDHHC", "start_date": "2022-02-15T18:39:44+0000", "end_date": "2022-02-22T18:40:44+0000", "last_refreshed_datetime": "2022-03-20T07:29:59+0000", "page": 1, "total_items": 1, "total_pages": 1, "links": [ { "href": "https://api.paypal.com/v1/reporting/transactions?end_date=2022-02-22T18%3A40%3A44-0000&transaction_id=2B258349616013924&fields=all&start_date=2022-02-15T18%3A39%3A44-0000&page_size=100&page=1", "rel": "self", "method": "GET" } ] } ``` **Transaction with item_name/transaction_note that has a description value in the database** ```json { "transaction_details": [ { "transaction_info": { "paypal_account_id": "2A12XXQAMF71F", "transaction_id": "AXS135312U735002", "paypal_reference_id": "6T984122A6370360B", "paypal_reference_id_type": "TXN", "transaction_event_code": "T0006", "transaction_initiation_date": "2022-03-05T10:00:16+0000", "transaction_updated_date": "2022-03-05T10:00:16+0000", "transaction_amount": { "currency_code": "EUR", "value": "-148.22" }, "transaction_status": "S", "transaction_note": "5104.0081.5124 MP Water GmbH ", "invoice_id": "5104.0081.5124", "custom_field": "5103.4668.8042", "protection_eligibility": "02", "instrument_type": "PAYPAL" }, "payer_info": { "account_id": "12SWKFDWC3QFS", "email_address": "durst.paypal@water.be", "address_status": "Y", "payer_status": "Y", "payer_name": { "alternate_full_name": "Water GmbH" }, "country_code": "BE" }, "shipping_info": { "name": "m4t7", "address": { "line1": "Water Street 1", "city": "Watertown", "country_code": "BE", "postal_code": "12345" } }, "cart_info": { "item_details": [ { "item_name": "5103.4668.8042 MP Water GmbH", "item_description": "1234.4668.8042 MP Water GmbH", "item_quantity": "1", "item_unit_price": { "currency_code": "EUR", "value": "194.22" }, "item_amount": { "currency_code": "EUR", "value": "15.22" }, "total_item_amount": { "currency_code": "EUR", "value": "15.22" }, "invoice_number": "1504.0081.1224" } ] }, "store_info": {}, "auction_info": {}, "incentive_info": {} } ], "account_number": "A3FU9R3FXALHC", "start_date": "2022-03-01T18:39:44+0000", "end_date": "2022-03-06T18:40:44+0000", "last_refreshed_datetime": "2022-03-20T07:29:59+0000", "page": 1, "total_items": 1, "total_pages": 1, "links": [ { "href": "https://api.paypal.com/v1/reporting/transactions?end_date=2022-03-06T18%3A40%3A44-0000&transaction_id=AXS135312U735002&fields=all&start_date=2022-03-01T18%3A39%3A44-0000&page_size=100&page=1", "rel": "self", "method": "GET" } ] } ```
robvankeilegom commented 2 years ago

@m4t7 Thanks for all the info, you've been really helpful. I pushed a change that prepends the invoice_id of the transaction to the description in Firefly. I've also added a check to see if item_details is available. Let me know how it goes!

m4t7 commented 2 years ago

Thanks for all your work. The item_details issue is solved. I looked into my database and it seems to look good but the payer_name is not extended all the time for records. I will look tomorrow with rest again over some transactions and will let you know.

Maybe you find something regarding the new issue I receive:

Start pulling data from PayPal

In Sync.php line 53:

  Undefined property: stdClass::$email_address  
robvankeilegom commented 2 years ago

I pushed a change that makes the email_adress optionally. I checked my records and all 400 transactions I synced from the PayPal api have an email address and name.

The names are populated with payer_info.payer_name.alternate_full_name or payer_info.payer_name.given_name whichever isn't empty. If you can get a hold of a record that isn't populated correctly lmk what field i should be using.

m4t7 commented 2 years ago

Thank you very very much for all your fixes so far.

The database contains now every transaction. (over 700)

Payer ID without email

I found the pp_id without any email address, it was paypal itself^^ (I think email is today mandatory , maybe pp accounts that where opened before a specifc date may contain this blank email)

paypal_inc_without_email

Transaction Example

Here is an example of a transaction that do not contain the payer_name as alternative if no item_name is assigend.

Database

payer_id_4

The transaction with payer_id 4 had initial no description, then your fix added the invoice_id , but it failed to add the payer_name. It would be great if you can check this again. payer_id_is_not_populated

JSON Output

The transaction with pp_id and reference_id contains no alternative full name transaction_with_both_pp_and_reference_id

The transaction with only the reference_id contains the alternative_full_name but it is still not populated into the DB as shown above.

transaction_with_only_reference_id

New Issue

Since I have all transactions, the sync now completes the pulling phase and moves into the pushing phase.

root@8562e6701a2c:/var/www/html# php artisan sync
Start pulling data from PayPal
Pushing data to Firefly

In Firefly.php line 69:

  Call to undefined method GuzzleHttp\Exception\ConnectException::getResponse()  

I'm facing a new issue, is this really undefined or is this any thing other? I found nothing in the storage log.

robvankeilegom commented 2 years ago

@m4t7 I messed up there, that should be fixed now. Make sure the FIREFLY_URL value in your .env file just the root domain without a path.

I purposely didn't populate the transaction description with the payer name. The description will be empty if no invoice_id or items names are returned from the PayPal api but that's fine. In Firefly you'll always see the payer alongside the transaction.

m4t7 commented 2 years ago

@robvankeilegom yes you fixed it. I agree with you on that, the import with incoice_id or items_names is completely fine.It looks really fine in firefly :+1:

Unfortunately after 7 entries the import into firefly stops with a new issue.

I have all 5 transactions from march and my first 2 transactions from february.

root@7bc27f9fbf27:/var/www/html# php artisan sync
Start pulling data from PayPal
Pushing data to Firefly

In RequestException.php line 113:

  Client error: `POST https://cash.mt.rpn/api/v1/accounts` resulted in a `422 Unprocessable Entity` response:  
  {"message":"The given data was invalid.","errors":{"name":["This account name is already in use."]}}     
robvankeilegom commented 2 years ago

@m4t7 I created #4 for this.