Using Laravel Dusk to download Paddle payout PDFs

When you have multiple Paddle accounts for different products—monthly accounting tasks end up consuming more time than you’d like. For each payout, I’d log into all my accounts, download the payout PDFs split up between the US and RoW (rest of world) regions, and import them into my accounting software. After a few times, I decided to automate it using Laravel Dusk and I figured I’d share the solution here. This blog post introduces a new GitHub repository that uses Laravel Dusk to log into Paddle’s web interface, navigate to the payouts page, and download payout PDFs. If you find yourself manually retrieving Paddle payout data every month, this might just be the automation you need. Continue reading for the context and a walkthrough, or go directly to the repo: https://github.com/smitmartijn/laravel-dusk-paddle-payouts-download Why? If you’re using Paddle as a payment processor, you know that their payouts arrive monthly, and each payout comes with a PDF you’ll need for accounting. If you have multiple products with separate Paddle accounts, this can quickly become a time-consuming task. So, this post and project is for anyone using Paddle and has multiple accounts, or just want to make their life a bit easier. How does it work? There’s a Laravel Dusk test script in the repository that handles everything from logging in to downloading the payout PDFs. Here’s a quick breakdown of the steps it follows: Fetching Paddle accounts: Before running the script, make sure you have PaddleAccount records set up in your database. You can also strip out the PaddleAccount and PaddlePayout models if you’d like. Logging in and navigating: The script logs into the Paddle dashboard using the credentials provided and navigates to the Payouts page. Downloading the PDFs: It retrieves the available payout PDFs for both “US” and “RoW” (Rest of World) invoices and stores them in storage/app/private/paddle_invoices/. Extracting totals: Using the PdfToText package, it extracts the total payout amounts from the PDFs. Updating records: Finally, it creates or updates the PaddlePayout records in the database with the extracted data. Getting started The GitHub repository contains an example Laravel project with the PaddleDownloadPayoutPdfTest.php file as how I am using it myself. You can strip that file for parts, or clone the entire project, create a database and run the migrations, create a PaddleAccount record, and then run php artisan dusk to test it out. What’s next? This script solved a recurring annoyance for me by turning hours of manual work (even if it was just once a month) into a task that runs in minutes without my involvement. While I haven’t added the code where it takes the PaddlePayouts and syncs them to my accounting software, you can basically do anything with the PDFs, once they’re stored locally. If you want to check out the full code or give it a try, head over to the GitHub repository. Contributions and feedback are always welcome.

Jan 16, 2025 - 11:25
Using Laravel Dusk to download Paddle payout PDFs

When you have multiple Paddle accounts for different products—monthly accounting tasks end up consuming more time than you’d like. For each payout, I’d log into all my accounts, download the payout PDFs split up between the US and RoW (rest of world) regions, and import them into my accounting software. After a few times, I decided to automate it using Laravel Dusk and I figured I’d share the solution here.

This blog post introduces a new GitHub repository that uses Laravel Dusk to log into Paddle’s web interface, navigate to the payouts page, and download payout PDFs. If you find yourself manually retrieving Paddle payout data every month, this might just be the automation you need.

Continue reading for the context and a walkthrough, or go directly to the repo: https://github.com/smitmartijn/laravel-dusk-paddle-payouts-download

Why?

If you’re using Paddle as a payment processor, you know that their payouts arrive monthly, and each payout comes with a PDF you’ll need for accounting. If you have multiple products with separate Paddle accounts, this can quickly become a time-consuming task. So, this post and project is for anyone using Paddle and has multiple accounts, or just want to make their life a bit easier.

How does it work?

There’s a Laravel Dusk test script in the repository that handles everything from logging in to downloading the payout PDFs. Here’s a quick breakdown of the steps it follows:

  1. Fetching Paddle accounts: Before running the script, make sure you have PaddleAccount records set up in your database. You can also strip out the PaddleAccount and PaddlePayout models if you’d like.
  2. Logging in and navigating: The script logs into the Paddle dashboard using the credentials provided and navigates to the Payouts page.
  3. Downloading the PDFs: It retrieves the available payout PDFs for both “US” and “RoW” (Rest of World) invoices and stores them in storage/app/private/paddle_invoices/.
  4. Extracting totals: Using the PdfToText package, it extracts the total payout amounts from the PDFs.
  5. Updating records: Finally, it creates or updates the PaddlePayout records in the database with the extracted data.

Getting started

The GitHub repository contains an example Laravel project with the PaddleDownloadPayoutPdfTest.php file as how I am using it myself. You can strip that file for parts, or clone the entire project, create a database and run the migrations, create a PaddleAccount record, and then run php artisan dusk to test it out.

What’s next?

This script solved a recurring annoyance for me by turning hours of manual work (even if it was just once a month) into a task that runs in minutes without my involvement. While I haven’t added the code where it takes the PaddlePayouts and syncs them to my accounting software, you can basically do anything with the PDFs, once they’re stored locally.

If you want to check out the full code or give it a try, head over to the GitHub repository. Contributions and feedback are always welcome.