From a26842c211dc221ca7eb339b19e1c632edf2eb91 Mon Sep 17 00:00:00 2001 From: Edwin Hoffland Date: Thu, 12 Sep 2024 21:50:15 +0200 Subject: [PATCH 1/2] setState function added setState function to add a state to the authUrl query parameters. This implementation is copied from the Exact library. --- .../Financials/Moneybird/Connection.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Picqer/Financials/Moneybird/Connection.php b/src/Picqer/Financials/Moneybird/Connection.php index 3758f5a..99b00f2 100644 --- a/src/Picqer/Financials/Moneybird/Connection.php +++ b/src/Picqer/Financials/Moneybird/Connection.php @@ -68,6 +68,11 @@ class Connection */ private $redirectUrl; + /** + * @var string|null + */ + private ?string $state = null; + /** * @var Client */ @@ -346,10 +351,11 @@ public function upload($url, $options) public function getAuthUrl() { return $this->authUrl . '?' . http_build_query([ - 'client_id' => $this->clientId, - 'redirect_uri' => $this->redirectUrl, + 'client_id' => $this->clientId, + 'redirect_uri' => $this->redirectUrl, 'response_type' => 'code', - 'scope' => $this->scopes ? implode(' ', $this->scopes) : 'sales_invoices documents estimates bank time_entries settings', + 'state' => $this->state, + 'scope' => $this->scopes ? implode(' ', $this->scopes) : 'sales_invoices documents estimates bank time_entries settings', ]); } @@ -403,6 +409,14 @@ public function setRedirectUrl($redirectUrl) $this->redirectUrl = $redirectUrl; } + /** + * @param string $state + */ + public function setState(string $state): void + { + $this->state = $state; + } + /** * @return bool */ From ca39f070376ec2fd8b773faf8ccbb44bd152a9af Mon Sep 17 00:00:00 2001 From: Edwin Hoffland Date: Thu, 12 Sep 2024 22:00:29 +0200 Subject: [PATCH 2/2] Update Connection.php --- src/Picqer/Financials/Moneybird/Connection.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Picqer/Financials/Moneybird/Connection.php b/src/Picqer/Financials/Moneybird/Connection.php index 99b00f2..480cd34 100644 --- a/src/Picqer/Financials/Moneybird/Connection.php +++ b/src/Picqer/Financials/Moneybird/Connection.php @@ -351,11 +351,11 @@ public function upload($url, $options) public function getAuthUrl() { return $this->authUrl . '?' . http_build_query([ - 'client_id' => $this->clientId, - 'redirect_uri' => $this->redirectUrl, + 'client_id' => $this->clientId, + 'redirect_uri' => $this->redirectUrl, 'response_type' => 'code', - 'state' => $this->state, - 'scope' => $this->scopes ? implode(' ', $this->scopes) : 'sales_invoices documents estimates bank time_entries settings', + 'state' => $this->state, + 'scope' => $this->scopes ? implode(' ', $this->scopes) : 'sales_invoices documents estimates bank time_entries settings', ]); }