If you find this project useful, you can show your appreciation and support by giving it a ⭐. Your support motivates us to work harder and make even better and more useful tools!
This package provides an expressive, fluent interface to ΑΑΔΕ myDATA invoicing REST API. It handles almost all the boilerplate code for sending, cancelling and requesting invoices.
- Official documentation is available 👉 on our documentation site
- myDATA webpage: AADE myDATA
- myDATA documentation (PDF): AADE myDATA REST API v1.0.10
In order to use this package, you will need first a aade id
and a Subscription key
. You can get these credentials by signing up to mydata rest api.
- Development: Sign up to mydata development api
- Production: Sign up to mydata production api
- guzzlehttp/guzzle >= 7.0
Version | PHP | myDATA | Support |
---|---|---|---|
^v5.x | 8.1 | v1.0.10 | Active |
^v4.x | 8.1 | v1.0.8 | Ended |
^v3.x | 8.1 | v1.0.7 | Ended |
^v2.x | 8.1 | v1.0.5 | Ended |
^v1.x | 8.0 | v1.0.3 | Ended |
To install through Composer, run the following command:
composer require firebed/aade-mydata
Once you have the user id and the subscription key use the following code to set the environment and the credentials:
$env = "dev"; // For production use "prod"
$user_id = "your-user-id";
$subscription_key = "your-subscription-key";
MyDataRequest::setEnvironment($env);
MyDataRequest::setCredentials($user_id, $subscription_key);
For development, you may need to disable client verification if you are not using https:
MyDataRequest::verifyClient(false);
use Firebed\AadeMyData\Http\SendInvoices;
use Firebed\AadeMyData\Models\Invoice;
use Firebed\AadeMyData\Exceptions\MyDataException;
// Prepare your invoices, for simplicity we will use an array of empty
// Invoice objects. You should populate these objects with your own data.
$invoices = [new Invoice(), new Invoice()];
$sender = new SendInvoices();
try {
$responses = $sender->handle($invoices);
$errors = [];
foreach ($responses as $response) {
if ($response->isSuccessful()) {
// This invoice was successfully sent to myDATA.
// Each response has an index value which corresponds
// to the index (-1) of the $invoices array.
$index = $response->getIndex();
$uid = $response->getInvoiceUid();
$mark = $response->getInvoiceMark();
$cancelledByMark = $response->getCancellationMark();
$qrUrl = $response->getQrUrl();
// If you need to relate the response to your local invoice
// $invoice = $invoices[$index - 1];
print_r(compact('index', 'uid', 'mark', 'cancelledByMark', 'qrUrl'));
} else {
// There were some errors for a specific invoice. See errors for details.
foreach ($response->getErrors() as $error) {
$errors[$response->getIndex() - 1][] = $error->getCode() . ': ' . $error->getMessage();
}
}
}
} catch (MyDataException $e) {
// There was a communication error. None of the invoices were sent.
echo "Σφάλμα επικοινωνίας: " . $e->getMessage();
}
Method | Availability |
---|---|
Validate VAT Number | ✅ |
SendInvoices | ✅ |
CancelInvoice | ✅ |
RequestDocs | ✅ |
RequestTransmittedDocs | ✅ |
RequestMyIncome | ✅ |
RequestMyExpenses | ✅ |
RequestVatInfo | ✅ |
RequestE3Info | ✅ |
SendPaymentsMethod | ✅ |
SendIncomeClassification | In progress |
SendExpensesClassification | In progress |
Method | Availability |
---|---|
SendClient | In progress |
UpdateClient | In progress |
RequestClients | In progress |
CancelClient | In progress |
ClientCorrelations | In progress |
If you are upgrading from a previous version, please see upgrade guide
composer test
Please see CONTRIBUTING for details.
AADE myDATA is licenced under the MIT License.
Copyright 2022 © Okan Giritli