-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
- Loading branch information
There are no files selected for viewing
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 GitHub Actions / PHP - 7.4
Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8
Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8.2
Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 7.3
Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8.3
Check failure on line 19 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8.1
|
||
'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 GitHub Actions / PHP - 7.4
Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8
Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8.2
Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 7.3
Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8.3
Check failure on line 24 in examples/sales-invoices/create-sales-invoice.php GitHub Actions / PHP - 8.1
|
||
'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()); | ||
} |
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 GitHub Actions / PHP - 7.4
Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php GitHub Actions / PHP - 8
Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php GitHub Actions / PHP - 8.2
Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php GitHub Actions / PHP - 7.3
Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php GitHub Actions / PHP - 8.3
Check failure on line 20 in examples/sales-invoices/delete-sales-invoice.php GitHub Actions / PHP - 8.1
|
||
|
||
echo "<p>Sales invoice deleted with ID: " . htmlspecialchars($invoiceId) . "</p>"; | ||
} catch (\Mollie\Api\Exceptions\ApiException $e) { | ||
echo "API call failed: " . htmlspecialchars($e->getMessage()); | ||
} |
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 GitHub Actions / PHP - 7.4
Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php GitHub Actions / PHP - 8
Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php GitHub Actions / PHP - 8.2
Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php GitHub Actions / PHP - 7.3
Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php GitHub Actions / PHP - 8.3
Check failure on line 18 in examples/sales-invoices/list-sales-invoices.php GitHub Actions / PHP - 8.1
|
||
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()); | ||
} |
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 GitHub Actions / PHP - 7.4
Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php GitHub Actions / PHP - 8
Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php GitHub Actions / PHP - 8.2
Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php GitHub Actions / PHP - 7.3
Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php GitHub Actions / PHP - 8.3
Check failure on line 20 in examples/sales-invoices/update-sales-invoice.php GitHub Actions / PHP - 8.1
|
||
'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()); | ||
} |