Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Dec 10, 2024
1 parent be3dbe7 commit 894e3ac
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
51 changes: 51 additions & 0 deletions examples/sales-invoices/create-sales-invoice.php
Original file line number Diff line number Diff line change
@@ -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([

Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.4

Variable $mollie might not be defined.

Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8

Variable $mollie might not be defined.

Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.2

Variable $mollie might not be defined.

Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.3

Variable $mollie might not be defined.

Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.3

Variable $mollie might not be defined.

Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.1

Variable $mollie might not be defined.

Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.4

Variable $mollie might not be defined.
'currency' => 'EUR',
'status' => SalesInvoiceStatus::DRAFT,
'vatScheme' => 'standard',
'vatMode' => 'inclusive',
'paymentTerm' => PaymentTerm::DAYS_30,

Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.4

Access to constant DAYS_30 on an unknown class Mollie\Api\Types\PaymentTerm.

Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8

Access to constant DAYS_30 on an unknown class Mollie\Api\Types\PaymentTerm.

Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.2

Access to constant DAYS_30 on an unknown class Mollie\Api\Types\PaymentTerm.

Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.3

Access to constant DAYS_30 on an unknown class Mollie\Api\Types\PaymentTerm.

Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.3

Access to constant DAYS_30 on an unknown class Mollie\Api\Types\PaymentTerm.

Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.1

Access to constant DAYS_30 on an unknown class Mollie\Api\Types\PaymentTerm.

Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.4

Access to constant DAYS_30 on an unknown class Mollie\Api\Types\PaymentTerm.
'recipientIdentifier' => 'XXXXX',
'recipient' => [
'type' => 'consumer',
'email' => '[email protected]',
'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());
}
25 changes: 25 additions & 0 deletions examples/sales-invoices/delete-sales-invoice.php
Original file line number Diff line number Diff line change
@@ -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);

Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.4

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.2

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.3

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.3

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.1

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.4

Variable $mollie might not be defined.

echo "<p>Sales invoice deleted with ID: " . htmlspecialchars($invoiceId) . "</p>";
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo "API call failed: " . htmlspecialchars($e->getMessage());
}
28 changes: 28 additions & 0 deletions examples/sales-invoices/list-sales-invoices.php
Original file line number Diff line number Diff line change
@@ -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();

Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php

View workflow job for this annotation

GitHub Actions / PHP - 7.4

Variable $mollie might not be defined.

Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php

View workflow job for this annotation

GitHub Actions / PHP - 8

Variable $mollie might not be defined.

Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php

View workflow job for this annotation

GitHub Actions / PHP - 8.2

Variable $mollie might not be defined.

Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php

View workflow job for this annotation

GitHub Actions / PHP - 7.3

Variable $mollie might not be defined.

Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php

View workflow job for this annotation

GitHub Actions / PHP - 8.3

Variable $mollie might not be defined.

Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php

View workflow job for this annotation

GitHub Actions / PHP - 8.1

Variable $mollie might not be defined.

Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php

View workflow job for this annotation

GitHub Actions / PHP - 8.4

Variable $mollie might not be defined.
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());
}
40 changes: 40 additions & 0 deletions examples/sales-invoices/update-sales-invoice.php
Original file line number Diff line number Diff line change
@@ -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, [

Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.4

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.2

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 7.3

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.3

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.1

Variable $mollie might not be defined.

Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php

View workflow job for this annotation

GitHub Actions / PHP - 8.4

Variable $mollie might not be defined.
'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());
}

0 comments on commit 894e3ac

Please sign in to comment.