From 894e3acbbececda1b8ab490d421167da12830ac6 Mon Sep 17 00:00:00 2001 From: Krishan Koenig Date: Tue, 10 Dec 2024 14:08:24 +0100 Subject: [PATCH] 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 000000000..ffdc52159 --- /dev/null +++ b/examples/sales-invoices/create-sales-invoice.php @@ -0,0 +1,51 @@ +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 "

New sales invoice created with ID: " . htmlspecialchars($salesInvoice->id) . "

"; +} 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 000000000..3b154b802 --- /dev/null +++ b/examples/sales-invoices/delete-sales-invoice.php @@ -0,0 +1,25 @@ +salesInvoices->delete($invoiceId); + + echo "

Sales invoice deleted with ID: " . htmlspecialchars($invoiceId) . "

"; +} 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 000000000..49d6d3611 --- /dev/null +++ b/examples/sales-invoices/list-sales-invoices.php @@ -0,0 +1,28 @@ +'; + $salesInvoices = $mollie->salesInvoices->page(); + foreach ($salesInvoices as $invoice) { + echo '
  • Invoice ' . htmlspecialchars($invoice->id) . ': (' . htmlspecialchars($invoice->issuedAt) . ')'; + echo '
    Status: ' . htmlspecialchars($invoice->status) . ''; + echo '
    Total Amount: ' . htmlspecialchars($invoice->amount->currency) . ' ' . htmlspecialchars($invoice->amount->value) . ''; + echo '
  • '; + } + echo ''; +} 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 000000000..2442be423 --- /dev/null +++ b/examples/sales-invoices/update-sales-invoice.php @@ -0,0 +1,40 @@ +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 "

    Sales invoice updated with ID: " . htmlspecialchars($updatedInvoice->id) . "

    "; +} catch (\Mollie\Api\Exceptions\ApiException $e) { + echo "API call failed: " . htmlspecialchars($e->getMessage()); +}