Den Integrations-Handler erstellen
Ein Rechnungs-Synchronizer muss das App\Framework\Core\Billing\Invoice\InvoiceSynchronizerHandlerInterface und alle seine Methoden implementieren. Du musst in Deiner Basisklasse in der Funktion install() auf Deine Klasse verweisen.
Deine Handler-Klasse könnte so aussehen:
<?php
namespace custom\modules\HwSevdeskIntegration\Handlers;
use App\Framework\Core\Billing\Invoice\InvoiceSynchronizerHandlerInterface;
use App\Framework\Core\Billing\Invoice\Responses\InvoiceSynchronizerCreatedResponse;
use App\Models\Invoice\Invoice;
class HwSevdeskIntegrationHandler implements InvoiceSynchronizerHandlerInterface {
public function create(Invoice $invoice): InvoiceSynchronizerCreatedResponse {
// TODO create on remote
return new InvoiceSynchronizerCreatedResponse(
true, // successfully created
[ // array of customFields. Save the remote id to refetch the invoice afterwards
SevdeskHelper::HW_SEVDESK_INVOICE_KEY => $invoiceId
]
);
}
public function viewInvoice(Invoice $invoice): ?string {
// TODO fetch pdf from remote
return $pdfContents ?? ""; // return the raw pdf contents
}
}War das hilfreich?