Create the integration handler
An invoice synchronizer needs to implement the App\Framework\Core\Billing\Invoice\InvoiceSynchronizerHandlerInterface and all of its methods. You have to reference your class inside the install() function in your base class.
Your handler class could look like this:
<?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
}
}Was this helpful?