PHP code example of vormkracht10 / wefact-php
1. Go to this page and download the library: Download vormkracht10/wefact-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vormkracht10 / wefact-php example snippets
$weFact = new \Vormkracht10\WeFact\WeFact('your-api-key');
$response = $weFact->invoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->invoices()->listAll();
if (isset($response['invoices'])) {
print_r($response['invoices']);
}
$response = $weFact->creditors()->list();
// or use listAll to call the show method for each item
$response = $weFact->creditors()->listAll();
if (isset($response['creditors'])) {
print_r($response['creditors']);
}
$response = $weFact->creditors()->create([
'CompanyName' => 'Your company name',
]);
if ($result['status'] == 'success') {
print_r($response['company']);
}
$result = $weFact->creditors()->edit([
'Identifier' => $creditorId,
'CompanyName' => 'Your company name',
]);
if ($result['status'] == 'error') {
// Something went wrong
print_r($result['errors']);
}
$weFact->creditors()->show(['Identifier' => $creditorId]);
// or
$weFact->creditors()->show(['CreditorCode' => $creditorCode]);
$weFact->creditors()->delete(['Identifier' => $creditorId]);
// or
$weFact->creditors()->delete(['CreditorCode' => $creditorCode]);
$weFact->creditInvoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->creditInvoices()->listAll();
$weFact->creditInvoices()->create([
'InvoiceCode' => 'your-invoice-code',
'CreditorCode' => 'CD10001'
'InvoiceLines' => [
[
'Description' => 'Your description',
'PriceExcl' => 10,
],
],
])
$weFact->creditInvoices()->edit([
'Identifier' => $creditInvoiceId,
'Comment' => 'Your comment',
])
$weFact->creditInvoices()->show(['Identifier' => $creditInvoiceId]);
// or
$weFact->creditInvoices()->show(['CreditInvoiceCode' => $creditInvoiceCode]);
$weFact->creditInvoices()->delete(['Identifier' => $creditInvoiceId]);
// or
$weFact->creditInvoices()->delete(['CreditInvoiceCode' => $creditInvoiceCode]);
$weFact->debtors()->list();
// or use listAll to call the show method for each item
$response = $weFact->debtors()->listAll();
$weFact->debtors()->list([
'searchat' => 'EmailAddress',
'searchfor' => '[email protected] '
]);
$weFact->debtors()->create([
'CompanyName' => 'Your company name',
])
$weFact->debtors()->edit([
'Identifier' => $debtorId,
'CompanyName' => 'Your company name',
])
$weFact->debtors()->show(['Identifier' => $debtorId]);
// or
$weFact->debtors()->show(['DebtorCode' => $debtorCode]);
$weFact->groups()->list([
'type' => 'debtor',
]);
$weFact->groups()->create([
'Type' => 'debtor',
'GroupName' => 'Your group name',
])
$weFact->groups()->edit([
'Identifier' => $groupId,
'GroupName' => 'Your group name',
])
$weFact->groups()->show(['Identifier' => $groupId]);
$weFact->groups()->delete(['Identifier' => $groupId]);
$weFact->invoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->invoices()->listAll();
$weFact->invoices()->create([
'DebtorCode' => 'DB10000',
'InvoiceLines' => [
[
'Number' => 1,
'ProductCode' => 'P0001'
]
],
[
'Description' => 'Your product description',
'PriceExcl' => 100
]
])
$weFact->invoices()->edit([
'Identifier' => $invoiceId,
'InvoiceLines' => [
[
'Number' => 1,
'ProductCode' => 'P0001'
]
],
[
'Description' => 'Your product description',
'PriceExcl' => 100
]
])
$weFact->invoices()->show(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->show(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->delete(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->delete(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->credit(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->credit(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->partPayment(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->partPayment(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->markAsPaid(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->markAsPaid(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->markAsUnpaid(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->markAsUnpaid(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->sendByEmail(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->sendByEmail(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->sendReminderByEmail(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->sendReminderByEmail(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->download(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->download(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->block(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->block(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->unblock(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->unblock(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->schedule([
'Identifier' => $invoiceId,
'ScheduledAt' => '2020-01-01 00:00:00'
])
// or
$weFact->invoices()->schedule([
'InvoiceCode' => $invoiceCode,
'ScheduledAt' => '2020-01-01 00:00:00'
])
$weFact->invoices()->cancelSchedule(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->cancelSchedule(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->paymentProcessPause(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->paymentProcessPause(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->paymentProcessReactivate(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->paymentProcessReactivate(['InvoiceCode' => $invoiceCode]);
$weFact->invoices()->sortLines([
'Identifier' => $invoiceId,
'InvoiceLines' => [
[
'Identifier' => $invoiceLineId,
]
]
]);
$weFact->invoices()->addLine([
'Identifier' => $invoiceId,
'InvoiceLines' => [
[
'Number' => 1,
'ProductCode' => 'P0001'
]
],
]);
$weFact->invoices()->deleteLine([
'Identifier' => $invoiceId,
'InvoiceLines' => [
[
'Identifier' => $invoiceLineId,
]
]
]);
$weFact->invoices()->addAttachment([
'ReferenceIdentifier' => $invoiceId,
'Type' => 'invoice',
'Filename' => 'test.pdf',
'Base64' => 'base64string'
]);
$weFact->invoices()->deleteAttachment([
'Identifier' => $attachmentId,
'ReferenceIdentifier' => $invoiceId,
'Type' => 'invoice',
]);
$weFact->invoices()->downloadAttachment([
'ReferenceIdentifier' => $invoiceId,
'Filename' => 'test.pdf',
'Type' => 'invoice',
]);
$weFact->products()->list();
// or use listAll to call the show method for each item
$response = $weFact->products()->listAll();
$weFact->products()->create([
'ProductName' => 'Your product name',
'ProductKeyPhrase' => 'Your product key phrase',
'PriceExcl' => 100
])
$weFact->products()->edit([
'Identifier' => $productId,
'ProductName' => 'Your product name',
'ProductKeyPhrase' => 'Your product key phrase',
'PriceExcl' => 100
])
$weFact->products()->show(['Identifier' => $productId]);
$weFact->products()->delete(['Identifier' => $productId]);
// or
$weFact->products()->delete(['ProductCode' => $productCode]);
$weFact->settings()->list();
$weFact->costCategories()->list();
// or use listAll to call the show method for each item
$response = $weFact->costCategories()->listAll();
$weFact->costCategories()->create([
'Title' => 'Your cost category title',
]);
$weFact->costCategories()->edit([
'Identifier' => $costCategoryId,
]);
$weFact->costCategories()->show(['Identifier' => $costCategoryId]);
$weFact->costCategories()->delete(['Identifier' => $costCategoryId]);
$weFact->subscriptions()->list();
// or use listAll to call the show method for each item
$response = $weFact->subscriptions()->listAll();
$weFact->subscriptions()->create([
'DebtorCode' => 'DB10000',
'ProductCode' => 'P0001',
'Description' => 'Your product description',
'PriceExcl' => 100,
'Periodic' => 'month',
'TerminateAfter' => 12
])
$weFact->subscriptions()->edit([
'Identifier' => $subscriptionId,
'Description' => 'Your product description',
'PriceExcl' => 100,
'Periodic' => 'month',
'TerminateAfter' => 12
])
$weFact->subscriptions()->show(['Identifier' => $subscriptionId]);
$weFact->subscriptions()->terminate(['Identifier' => $subscriptionId]);
bash
composer