From be3dbe7d17bf67b3ac7a224f58dd372ca9a139a8 Mon Sep 17 00:00:00 2001
From: Krishan Koenig <krishan.koenig@googlemail.com>
Date: Tue, 10 Dec 2024 14:00:14 +0100
Subject: [PATCH 1/7] wip

---
 src/Endpoints/SalesInvoiceEndpoint.php   | 123 +++++++++++++++++
 src/MollieApiClient.php                  |   9 ++
 src/Resources/SalesInvoice.php           | 167 +++++++++++++++++++++++
 src/Resources/SalesInvoiceCollection.php |  22 +++
 src/Types/SalesInvoiceStatus.php         |  21 +++
 5 files changed, 342 insertions(+)
 create mode 100644 src/Endpoints/SalesInvoiceEndpoint.php
 create mode 100644 src/Resources/SalesInvoice.php
 create mode 100644 src/Resources/SalesInvoiceCollection.php
 create mode 100644 src/Types/SalesInvoiceStatus.php

diff --git a/src/Endpoints/SalesInvoiceEndpoint.php b/src/Endpoints/SalesInvoiceEndpoint.php
new file mode 100644
index 00000000..9be1aded
--- /dev/null
+++ b/src/Endpoints/SalesInvoiceEndpoint.php
@@ -0,0 +1,123 @@
+<?php
+
+namespace Mollie\Api\Endpoints;
+
+use Mollie\Api\Exceptions\ApiException;
+use Mollie\Api\Resources\LazyCollection;
+use Mollie\Api\Resources\SalesInvoice;
+use Mollie\Api\Resources\SalesInvoiceCollection;
+
+class SalesInvoiceEndpoint extends CollectionEndpointAbstract
+{
+    protected $resourcePath = "sales-invoices";
+
+    /**
+     * @var string
+     */
+    public const RESOURCE_ID_PREFIX = 'invoice_';
+
+    /**
+     * @return SalesInvoice
+     */
+    protected function getResourceObject(): SalesInvoice
+    {
+        return new SalesInvoice($this->client);
+    }
+
+    /**
+     * Get the collection object that is used by this API endpoint. Every API endpoint uses one type of collection object.
+     *
+     * @param int $count
+     * @param \stdClass $_links
+     *
+     * @return SalesInvoiceCollection
+     */
+    protected function getResourceCollectionObject($count, $_links): SalesInvoiceCollection
+    {
+        return new SalesInvoiceCollection($this->client, $count, $_links);
+    }
+
+    /**
+     * Creates a payment in Mollie.
+     *
+     * @param array $data An array containing details on the payment.
+     * @param array $filters
+     *
+     * @return SalesInvoice
+     * @throws ApiException
+     */
+    public function create(array $data = []): SalesInvoice
+    {
+        return $this->rest_create($data, []);
+    }
+
+    /**
+     * Update the given Payment.
+     *
+     * Will throw a ApiException if the payment id is invalid or the resource cannot be found.
+     *
+     * @param string $salesInvoiceId
+     *
+     * @param array $data
+     * @return SalesInvoice
+     * @throws ApiException
+     */
+    public function update($salesInvoiceId, array $data = []): SalesInvoice
+    {
+        if (empty($salesInvoiceId) || strpos($salesInvoiceId, self::RESOURCE_ID_PREFIX) !== 0) {
+            throw new ApiException("Invalid sales invoice ID: '{$salesInvoiceId}'. A sales invoice ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
+        }
+
+        return parent::rest_update($salesInvoiceId, $data);
+    }
+
+    /**
+     * @param string $salesInvoiceId
+     * @param array $parameters
+     * @return SalesInvoice
+     * @throws ApiException
+     */
+    public function get($salesInvoiceId, array $parameters = []): SalesInvoice
+    {
+        if (empty($salesInvoiceId) || strpos($salesInvoiceId, self::RESOURCE_ID_PREFIX) !== 0) {
+            throw new ApiException("Invalid sales invoice ID: '{$salesInvoiceId}'. A sales invoice ID should start with '" . self::RESOURCE_ID_PREFIX . "'.");
+        }
+
+        return parent::rest_read($salesInvoiceId, $parameters);
+    }
+
+    /**
+     * @param string $salesInvoiceId
+     *
+     * @param array $data
+     * @throws ApiException
+     */
+    public function delete($salesInvoiceId, array $data = []): void
+    {
+        $this->rest_delete($salesInvoiceId, $data);
+    }
+
+    /**
+     * @param string $from The first payment ID you want to include in your list.
+     * @param int $limit
+     *
+     * @return SalesInvoiceCollection
+     * @throws ApiException
+     */
+    public function page($from = null, $limit = null)
+    {
+        return $this->rest_list($from, $limit, []);
+    }
+
+    /**
+     * @param string $from The first resource ID you want to include in your list.
+     * @param int $limit
+     * @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
+     *
+     * @return LazyCollection
+     */
+    public function iterator(?string $from = null, ?int $limit = null, bool $iterateBackwards = false): LazyCollection
+    {
+        return $this->rest_iterator($from, $limit, [], $iterateBackwards);
+    }
+}
diff --git a/src/MollieApiClient.php b/src/MollieApiClient.php
index 6ae63f25..04b02d74 100644
--- a/src/MollieApiClient.php
+++ b/src/MollieApiClient.php
@@ -32,6 +32,7 @@
 use Mollie\Api\Endpoints\ProfileEndpoint;
 use Mollie\Api\Endpoints\ProfileMethodEndpoint;
 use Mollie\Api\Endpoints\RefundEndpoint;
+use Mollie\Api\Endpoints\SalesInvoiceEndpoint;
 use Mollie\Api\Endpoints\SessionEndpoint;
 use Mollie\Api\Endpoints\SettlementCaptureEndpoint;
 use Mollie\Api\Endpoints\SettlementChargebackEndpoint;
@@ -122,6 +123,13 @@ class MollieApiClient
      */
     public $customerPayments;
 
+    /**
+     * RESTful Sales Invoice resource.
+     *
+     * @var SalesInvoiceEndpoint
+     */
+    public $salesInvoices;
+
     /**
      * RESTful Settlement resource.
      *
@@ -444,6 +452,7 @@ public function initializeEndpoints()
         $this->profileMethods = new ProfileMethodEndpoint($this);
         $this->profiles = new ProfileEndpoint($this);
         $this->refunds = new RefundEndpoint($this);
+        $this->salesInvoices = new SalesInvoiceEndpoint($this);
         $this->settlementCaptures = new SettlementCaptureEndpoint($this);
         $this->settlementChargebacks = new SettlementChargebackEndpoint($this);
         $this->settlementPayments = new SettlementPaymentEndpoint($this);
diff --git a/src/Resources/SalesInvoice.php b/src/Resources/SalesInvoice.php
new file mode 100644
index 00000000..432d0cde
--- /dev/null
+++ b/src/Resources/SalesInvoice.php
@@ -0,0 +1,167 @@
+<?php
+
+namespace Mollie\Api\Resources;
+
+use Mollie\Api\Types\SalesInvoiceStatus;
+
+class SalesInvoice extends BaseResource
+{
+    /**
+     * @var string
+     */
+    public $resource;
+
+    /**
+     * @var string
+     */
+    public $id;
+
+    /**
+     * @var string|null
+     */
+    public $profileId;
+
+    /**
+     * @var string|null
+     */
+    public $invoiceNumber;
+
+    /**
+     * @var string
+     */
+    public $currency;
+
+    /**
+     * @var string
+     */
+    public $status;
+
+    /**
+     * @var string
+     */
+    public $vatScheme;
+
+    /**
+     * @var string
+     */
+    public $vatMode;
+
+    /**
+     * @var string|null
+     */
+    public $memo;
+
+    /**
+     * @var string
+     */
+    public $paymentTerm;
+
+    /**
+     * @var object
+     */
+    public $paymentDetails;
+    /**
+     * @var object
+     */
+    public $emailDetails;
+
+    /**
+     * @var string
+     */
+    public $recipientIdentifier;
+
+    /**
+     * @var object
+     */
+    public $recipient;
+
+    /**
+     * @var array
+     */
+    public $lines;
+
+    /**
+     * @var string
+     */
+    public $webhookUrl;
+
+    /**
+     * @var object|null
+     */
+    public $discount;
+
+    /**
+     * @var object
+     */
+    public $amountDue;
+
+    /**
+     * @var object
+     */
+    public $subtotalAmount;
+
+    /**
+     * @var object
+     */
+    public $totalAmount;
+
+    /**
+     * @var object
+     */
+    public $totalVatAmount;
+
+    /**
+     * @var object
+     */
+    public $discountedSubtotalAmount;
+
+    /**
+     * @var string
+     */
+    public $createdAt;
+
+    /**
+     * @var string|null
+     */
+    public $issuedAt;
+
+    /**
+     * @var string|null
+     */
+    public $dueAt;
+
+    /**
+     * @var object
+     */
+    public $_links;
+
+    /**
+     * Returns whether the sales invoice is in draft status.
+     *
+     * @return bool
+     */
+    public function isDraft()
+    {
+        return $this->status === SalesInvoiceStatus::DRAFT;
+    }
+
+    /**
+     * Returns whether the sales invoice is issued.
+     *
+     * @return bool
+     */
+    public function isIssued()
+    {
+        return $this->status === SalesInvoiceStatus::ISSUED;
+    }
+
+    /**
+     * Returns whether the sales invoice is paid.
+     *
+     * @return bool
+     */
+    public function isPaid()
+    {
+        return $this->status === SalesInvoiceStatus::PAID;
+    }
+}
diff --git a/src/Resources/SalesInvoiceCollection.php b/src/Resources/SalesInvoiceCollection.php
new file mode 100644
index 00000000..6a76b995
--- /dev/null
+++ b/src/Resources/SalesInvoiceCollection.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Mollie\Api\Resources;
+
+class SalesInvoiceCollection extends CursorCollection
+{
+    /**
+     * @return string
+     */
+    public function getCollectionResourceName()
+    {
+        return "sales_invoices";
+    }
+
+    /**
+     * @return BaseResource
+     */
+    protected function createResourceObject()
+    {
+        return new SalesInvoice($this->client);
+    }
+}
diff --git a/src/Types/SalesInvoiceStatus.php b/src/Types/SalesInvoiceStatus.php
new file mode 100644
index 00000000..02dc1369
--- /dev/null
+++ b/src/Types/SalesInvoiceStatus.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Mollie\Api\Types;
+
+class SalesInvoiceStatus
+{
+    /**
+     * The sales invoice is in draft status and has not been sent or paid.
+     */
+    const DRAFT = 'draft';
+
+    /**
+     * The sales invoice has been issued to the customer but has not been paid yet.
+     */
+    const ISSUED = 'issued';
+
+    /**
+     * The sales invoice has been fully paid.
+     */
+    const PAID = 'paid';
+}

From 894e3acbbececda1b8ab490d421167da12830ac6 Mon Sep 17 00:00:00 2001
From: Krishan Koenig <krishan.koenig@googlemail.com>
Date: Tue, 10 Dec 2024 14:08:24 +0100
Subject: [PATCH 2/7] wip

---
 .../sales-invoices/create-sales-invoice.php   | 51 +++++++++++++++++++
 .../sales-invoices/delete-sales-invoice.php   | 25 +++++++++
 .../sales-invoices/list-sales-invoices.php    | 28 ++++++++++
 .../sales-invoices/update-sales-invoice.php   | 40 +++++++++++++++
 4 files changed, 144 insertions(+)
 create mode 100644 examples/sales-invoices/create-sales-invoice.php
 create mode 100644 examples/sales-invoices/delete-sales-invoice.php
 create mode 100644 examples/sales-invoices/list-sales-invoices.php
 create mode 100644 examples/sales-invoices/update-sales-invoice.php

diff --git a/examples/sales-invoices/create-sales-invoice.php b/examples/sales-invoices/create-sales-invoice.php
new file mode 100644
index 00000000..ffdc5215
--- /dev/null
+++ b/examples/sales-invoices/create-sales-invoice.php
@@ -0,0 +1,51 @@
+<?php
+
+use Mollie\Api\Types\PaymentTerm;
+use Mollie\Api\Types\SalesInvoiceStatus;
+
+/*
+ * Create a sales invoice using the Mollie API.
+ */
+
+try {
+    /*
+     * Initialize the Mollie API library with your API key or OAuth access token.
+     */
+    require "../initialize.php";
+
+    /*
+     * Create a sales invoice
+     */
+    $salesInvoice = $mollie->salesInvoices->create([
+        'currency' => 'EUR',
+        'status' => SalesInvoiceStatus::DRAFT,
+        'vatScheme' => 'standard',
+        'vatMode' => 'inclusive',
+        'paymentTerm' => PaymentTerm::DAYS_30,
+        'recipientIdentifier' => 'XXXXX',
+        'recipient' => [
+            'type' => 'consumer',
+            'email' => 'darth@vader.deathstar',
+            'streetAndNumber' => 'Sample Street 12b',
+            'postalCode' => '2000 AA',
+            'city' => 'Amsterdam',
+            'country' => 'NL',
+            'locale' => 'nl_NL'
+        ],
+        'lines' => [
+            [
+                'description' => 'Monthly subscription fee',
+                'quantity' => 1,
+                'vatRate' => '21',
+                'unitPrice' => [
+                    'currency' => 'EUR',
+                    'value' => '10.00'  // Corrected the format from '10,00' to '10.00' to match typical API expectations
+                ]
+            ]
+        ]
+    ]);
+
+    echo "<p>New sales invoice created with ID: " . htmlspecialchars($salesInvoice->id) . "</p>";
+} catch (\Mollie\Api\Exceptions\ApiException $e) {
+    echo "API call failed: " . htmlspecialchars($e->getMessage());
+}
diff --git a/examples/sales-invoices/delete-sales-invoice.php b/examples/sales-invoices/delete-sales-invoice.php
new file mode 100644
index 00000000..3b154b80
--- /dev/null
+++ b/examples/sales-invoices/delete-sales-invoice.php
@@ -0,0 +1,25 @@
+<?php
+/*
+ * Delete a sales invoice using the Mollie API.
+ */
+
+try {
+    /*
+     * Initialize the Mollie API library with your API key or OAuth access token.
+     */
+    require "../initialize.php";
+
+    /*
+     * Assume we have an invoice ID 'inv_xxx' that we wish to delete.
+     */
+    $invoiceId = 'invoice_xxx';
+
+    /*
+     * Delete the sales invoice
+     */
+    $mollie->salesInvoices->delete($invoiceId);
+
+    echo "<p>Sales invoice deleted with ID: " . htmlspecialchars($invoiceId) . "</p>";
+} catch (\Mollie\Api\Exceptions\ApiException $e) {
+    echo "API call failed: " . htmlspecialchars($e->getMessage());
+}
diff --git a/examples/sales-invoices/list-sales-invoices.php b/examples/sales-invoices/list-sales-invoices.php
new file mode 100644
index 00000000..49d6d361
--- /dev/null
+++ b/examples/sales-invoices/list-sales-invoices.php
@@ -0,0 +1,28 @@
+<?php
+/*
+ * List sales invoices using the Mollie API.
+ */
+
+try {
+    /*
+     * Initialize the Mollie API library with your API key or OAuth access token.
+     */
+    require "../initialize.php";
+
+    /*
+     * List the most recent sales invoices
+     *
+     * See: https://docs.mollie.com/reference/v2/sales-invoices-api/list-sales-invoices
+     */
+    echo '<ul>';
+    $salesInvoices = $mollie->salesInvoices->page();
+    foreach ($salesInvoices as $invoice) {
+        echo '<li><b>Invoice ' . htmlspecialchars($invoice->id) . ':</b> (' . htmlspecialchars($invoice->issuedAt) . ')';
+        echo '<br>Status: <b>' . htmlspecialchars($invoice->status) . '</b>';
+        echo '<br>Total Amount: <b>' . htmlspecialchars($invoice->amount->currency) . ' ' . htmlspecialchars($invoice->amount->value) . '</b>';
+        echo '</li>';
+    }
+    echo '</ul>';
+} catch (\Mollie\Api\Exceptions\ApiException $e) {
+    echo "API call failed: " . htmlspecialchars($e->getMessage());
+}
diff --git a/examples/sales-invoices/update-sales-invoice.php b/examples/sales-invoices/update-sales-invoice.php
new file mode 100644
index 00000000..2442be42
--- /dev/null
+++ b/examples/sales-invoices/update-sales-invoice.php
@@ -0,0 +1,40 @@
+<?php
+/*
+ * Update a sales invoice using the Mollie API.
+ */
+
+try {
+    /*
+     * Initialize the Mollie API library with your API key or OAuth access token.
+     */
+    require "../initialize.php";
+
+    /*
+     * Assume we have an invoice ID 'inv_xxx' that we wish to update.
+     */
+    $invoiceId = 'invoice_xxx';
+
+    /*
+     * Update the sales invoice
+     */
+    $updatedInvoice = $mollie->salesInvoices->update($invoiceId, [
+        'status' => \Mollie\Api\Types\SalesInvoiceStatus::PAID,
+        'recipientIdentifier' => 'XXXXX',
+        'lines' => [
+            [
+                'id' => 'line_001',
+                'description' => 'Updated subscription fee',
+                'quantity' => 2,
+                'vatRate' => '21',
+                'unitPrice' => [
+                    'currency' => 'EUR',
+                    'value' => '15.00'
+                ]
+            ]
+        ]
+    ]);
+
+    echo "<p>Sales invoice updated with ID: " . htmlspecialchars($updatedInvoice->id) . "</p>";
+} catch (\Mollie\Api\Exceptions\ApiException $e) {
+    echo "API call failed: " . htmlspecialchars($e->getMessage());
+}

From 34f2335fb6a9adcde6b26983b39025d78395d417 Mon Sep 17 00:00:00 2001
From: Naoray <Naoray@users.noreply.github.com>
Date: Tue, 10 Dec 2024 13:08:45 +0000
Subject: [PATCH 3/7] Fix styling

---
 examples/sales-invoices/create-sales-invoice.php | 10 +++++-----
 examples/sales-invoices/update-sales-invoice.php |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/examples/sales-invoices/create-sales-invoice.php b/examples/sales-invoices/create-sales-invoice.php
index ffdc5215..69f93a84 100644
--- a/examples/sales-invoices/create-sales-invoice.php
+++ b/examples/sales-invoices/create-sales-invoice.php
@@ -30,7 +30,7 @@
             'postalCode' => '2000 AA',
             'city' => 'Amsterdam',
             'country' => 'NL',
-            'locale' => 'nl_NL'
+            'locale' => 'nl_NL',
         ],
         'lines' => [
             [
@@ -39,10 +39,10 @@
                 'vatRate' => '21',
                 'unitPrice' => [
                     'currency' => 'EUR',
-                    'value' => '10.00'  // Corrected the format from '10,00' to '10.00' to match typical API expectations
-                ]
-            ]
-        ]
+                    'value' => '10.00',  // Corrected the format from '10,00' to '10.00' to match typical API expectations
+                ],
+            ],
+        ],
     ]);
 
     echo "<p>New sales invoice created with ID: " . htmlspecialchars($salesInvoice->id) . "</p>";
diff --git a/examples/sales-invoices/update-sales-invoice.php b/examples/sales-invoices/update-sales-invoice.php
index 2442be42..08c6e671 100644
--- a/examples/sales-invoices/update-sales-invoice.php
+++ b/examples/sales-invoices/update-sales-invoice.php
@@ -28,10 +28,10 @@
                 'vatRate' => '21',
                 'unitPrice' => [
                     'currency' => 'EUR',
-                    'value' => '15.00'
-                ]
-            ]
-        ]
+                    'value' => '15.00',
+                ],
+            ],
+        ],
     ]);
 
     echo "<p>Sales invoice updated with ID: " . htmlspecialchars($updatedInvoice->id) . "</p>";

From 6915f0d440b53ebf5ddf5f69dc23201dc59f7234 Mon Sep 17 00:00:00 2001
From: Krishan Koenig <krishan.koenig@googlemail.com>
Date: Tue, 10 Dec 2024 14:10:13 +0100
Subject: [PATCH 4/7] fix phpstan

---
 phpstan-baseline.neon                  | 25 +++++++++++++++++++++++++
 src/Endpoints/SalesInvoiceEndpoint.php |  1 -
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index a8db7218..67a10b8f 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -220,6 +220,31 @@ parameters:
 			count: 1
 			path: examples/profiles/update-profile.php
 
+		-
+			message: "#^Access to constant DAYS_30 on an unknown class Mollie\\\\Api\\\\Types\\\\PaymentTerm\\.$#"
+			count: 1
+			path: examples/sales-invoices/create-sales-invoice.php
+
+		-
+			message: "#^Variable \\$mollie might not be defined\\.$#"
+			count: 1
+			path: examples/sales-invoices/create-sales-invoice.php
+
+		-
+			message: "#^Variable \\$mollie might not be defined\\.$#"
+			count: 1
+			path: examples/sales-invoices/delete-sales-invoice.php
+
+		-
+			message: "#^Variable \\$mollie might not be defined\\.$#"
+			count: 1
+			path: examples/sales-invoices/list-sales-invoices.php
+
+		-
+			message: "#^Variable \\$mollie might not be defined\\.$#"
+			count: 1
+			path: examples/sales-invoices/update-sales-invoice.php
+
 		-
 			message: "#^Variable \\$mollie might not be defined\\.$#"
 			count: 1
diff --git a/src/Endpoints/SalesInvoiceEndpoint.php b/src/Endpoints/SalesInvoiceEndpoint.php
index 9be1aded..e0379d32 100644
--- a/src/Endpoints/SalesInvoiceEndpoint.php
+++ b/src/Endpoints/SalesInvoiceEndpoint.php
@@ -41,7 +41,6 @@ protected function getResourceCollectionObject($count, $_links): SalesInvoiceCol
      * Creates a payment in Mollie.
      *
      * @param array $data An array containing details on the payment.
-     * @param array $filters
      *
      * @return SalesInvoice
      * @throws ApiException

From 1f7a76f0cfc8fae2ee0271f327ff4cf7b2925c45 Mon Sep 17 00:00:00 2001
From: Krishan Koenig <krishan.koenig@googlemail.com>
Date: Wed, 11 Dec 2024 16:56:54 +0100
Subject: [PATCH 5/7] wip

---
 examples/sales-invoices/create-sales-invoice.php | 3 +--
 phpstan-baseline.neon                            | 5 -----
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/examples/sales-invoices/create-sales-invoice.php b/examples/sales-invoices/create-sales-invoice.php
index 69f93a84..a3a4aed1 100644
--- a/examples/sales-invoices/create-sales-invoice.php
+++ b/examples/sales-invoices/create-sales-invoice.php
@@ -1,6 +1,5 @@
 <?php
 
-use Mollie\Api\Types\PaymentTerm;
 use Mollie\Api\Types\SalesInvoiceStatus;
 
 /*
@@ -21,7 +20,7 @@
         'status' => SalesInvoiceStatus::DRAFT,
         'vatScheme' => 'standard',
         'vatMode' => 'inclusive',
-        'paymentTerm' => PaymentTerm::DAYS_30,
+        'paymentTerm' => '30 days',
         'recipientIdentifier' => 'XXXXX',
         'recipient' => [
             'type' => 'consumer',
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 67a10b8f..17bb3a20 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -220,11 +220,6 @@ parameters:
 			count: 1
 			path: examples/profiles/update-profile.php
 
-		-
-			message: "#^Access to constant DAYS_30 on an unknown class Mollie\\\\Api\\\\Types\\\\PaymentTerm\\.$#"
-			count: 1
-			path: examples/sales-invoices/create-sales-invoice.php
-
 		-
 			message: "#^Variable \\$mollie might not be defined\\.$#"
 			count: 1

From 7a41616469ce5861dd5ef8812b5e95a37906b1b8 Mon Sep 17 00:00:00 2001
From: Krishan Koenig <krishan.koenig@googlemail.com>
Date: Sun, 15 Dec 2024 14:00:35 +0100
Subject: [PATCH 6/7] wip

---
 .../sales-invoices/create-sales-invoice.php   |  3 ++-
 src/Types/PaymentTerm.php                     | 20 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 src/Types/PaymentTerm.php

diff --git a/examples/sales-invoices/create-sales-invoice.php b/examples/sales-invoices/create-sales-invoice.php
index a3a4aed1..69f93a84 100644
--- a/examples/sales-invoices/create-sales-invoice.php
+++ b/examples/sales-invoices/create-sales-invoice.php
@@ -1,5 +1,6 @@
 <?php
 
+use Mollie\Api\Types\PaymentTerm;
 use Mollie\Api\Types\SalesInvoiceStatus;
 
 /*
@@ -20,7 +21,7 @@
         'status' => SalesInvoiceStatus::DRAFT,
         'vatScheme' => 'standard',
         'vatMode' => 'inclusive',
-        'paymentTerm' => '30 days',
+        'paymentTerm' => PaymentTerm::DAYS_30,
         'recipientIdentifier' => 'XXXXX',
         'recipient' => [
             'type' => 'consumer',
diff --git a/src/Types/PaymentTerm.php b/src/Types/PaymentTerm.php
new file mode 100644
index 00000000..7691a2e0
--- /dev/null
+++ b/src/Types/PaymentTerm.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Mollie\Api\Types;
+
+class PaymentTerm
+{
+    const DAYS_7 = '7 days';
+
+    const DAYS_14 = '14 days';
+
+    const DAYS_30 = '30 days';
+
+    const DAYS_45 = '45 days';
+
+    const DAYS_60 = '60 days';
+
+    const DAYS_90 = '90 days';
+
+    const DAYS_120 = '120 days';
+}

From 011ade9be7a5713b515145c90e0aa0575586ea6f Mon Sep 17 00:00:00 2001
From: Krishan Koenig <krishan.koenig@googlemail.com>
Date: Sun, 15 Dec 2024 14:02:15 +0100
Subject: [PATCH 7/7] wip

---
 src/Types/SalesInvoiceStatus.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Types/SalesInvoiceStatus.php b/src/Types/SalesInvoiceStatus.php
index 02dc1369..e97f883d 100644
--- a/src/Types/SalesInvoiceStatus.php
+++ b/src/Types/SalesInvoiceStatus.php
@@ -7,15 +7,15 @@ class SalesInvoiceStatus
     /**
      * The sales invoice is in draft status and has not been sent or paid.
      */
-    const DRAFT = 'draft';
+    public const DRAFT = 'draft';
 
     /**
      * The sales invoice has been issued to the customer but has not been paid yet.
      */
-    const ISSUED = 'issued';
+    public const ISSUED = 'issued';
 
     /**
      * The sales invoice has been fully paid.
      */
-    const PAID = 'paid';
+    public const PAID = 'paid';
 }