vormkracht10/wefact-php

PHP package to provide a fluent interface to communicate with WeFact

v0.6.2 2023-10-09 23:16 UTC

This package is auto-updated.

Last update: 2024-11-26 07:19:34 UTC


README

GitHub release (latest by date) Tests Packagist PHP Version Support Latest Version on Packagist Total Downloads

This package provides a fluent interface to communicate with the WeFact API. For the full documentation of the WeFact API, please visit https://www.wefact.nl/api/.

Table of Contents

Minimum requirements

  • PHP 8.1 or higher
  • Guzzle 7.0 or higher

Installation

You can install the package via composer:

composer require vormkracht10/wefact-php

Usage

Then you can use the package like this:

$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']);
}

Available methods

Creditor

List creditors

$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']);
}

Create creditor

Required parameters: CompanyName or SurName.

$response = $weFact->creditors()->create([
    'CompanyName' => 'Your company name',
  ]);
if ($result['status'] == 'success') {
  print_r($response['company']);
}

Update creditor

Required parameter: Identifier or CreditorCode.

$result = $weFact->creditors()->edit([
    'Identifier' => $creditorId,
    'CompanyName' => 'Your company name',
  ]);

if ($result['status'] == 'error') {
  // Something went wrong
  print_r($result['errors']);
}

Show creditor

Required parameter: Identifier or CreditorCode.

$weFact->creditors()->show(['Identifier' => $creditorId]);
// or
$weFact->creditors()->show(['CreditorCode' => $creditorCode]);

Delete creditor

Required parameter: Identifier or CreditorCode.

$weFact->creditors()->delete(['Identifier' => $creditorId]);
// or
$weFact->creditors()->delete(['CreditorCode' => $creditorCode]);

Credit Invoice

List credit invoices

$weFact->creditInvoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->creditInvoices()->listAll();

Create credit invoice

Required parameters: InvoiceCode, Creditor or CreditorCode and InvoiceLines.

$weFact->creditInvoices()->create([
    'InvoiceCode' => 'your-invoice-code',
    'CreditorCode' => 'CD10001'
    'InvoiceLines' => [
        [
            'Description' => 'Your description',
            'PriceExcl' => 10,
        ],
    ],
  ])

Update credit invoice

Required parameter: Identifier or CreditInvoiceCode.

$weFact->creditInvoices()->edit([
    'Identifier' => $creditInvoiceId,
    'Comment' => 'Your comment',
  ])

Show credit invoice

Required parameter: Identifier or CreditInvoiceCode.

$weFact->creditInvoices()->show(['Identifier' => $creditInvoiceId]);
// or
$weFact->creditInvoices()->show(['CreditInvoiceCode' => $creditInvoiceCode]);

Delete credit invoice

Required parameter: Identifier or CreditInvoiceCode.

$weFact->creditInvoices()->delete(['Identifier' => $creditInvoiceId]);
// or
$weFact->creditInvoices()->delete(['CreditInvoiceCode' => $creditInvoiceCode]);

Debtor

List debtors

$weFact->debtors()->list();
// or use listAll to call the show method for each item
$response = $weFact->debtors()->listAll();

You can also search for debtors:

$weFact->debtors()->list([
  'searchat' => 'EmailAddress',
  'searchfor' => 'example@example.com'
]);

Create debtor

Required parameters: CompanyName or SurName.

$weFact->debtors()->create([
    'CompanyName' => 'Your company name',
  ])

Update debtor

Required parameter: Identifier or DebtorCode, CompanyName or SurName.

$weFact->debtors()->edit([
    'Identifier' => $debtorId,
    'CompanyName' => 'Your company name',
  ])

Show debtor

Required parameter: Identifier or DebtorCode.

$weFact->debtors()->show(['Identifier' => $debtorId]);
// or
$weFact->debtors()->show(['DebtorCode' => $debtorCode]);

Group

List groups

Required parameter: Type.

$weFact->groups()->list([
    'type' => 'debtor',
]);

Create group

Required parameters: Type and GroupName.

$weFact->groups()->create([
    'Type' => 'debtor',
    'GroupName' => 'Your group name',
  ])

Update group

Required parameter: Identifier.

$weFact->groups()->edit([
    'Identifier' => $groupId,
    'GroupName' => 'Your group name',
  ])

Show group

Required parameter: Identifier.

$weFact->groups()->show(['Identifier' => $groupId]);

Delete group

Required parameter: Identifier.

$weFact->groups()->delete(['Identifier' => $groupId]);

Invoice

List invoices

$weFact->invoices()->list();
// or use listAll to call the show method for each item
$response = $weFact->invoices()->listAll();

Create invoice

Required parameters: DebtorCode or DebtorCode and InvoiceLines.

$weFact->invoices()->create([
    'DebtorCode' => 'DB10000',
    'InvoiceLines' => [
      [
        'Number' => 1,
        'ProductCode' => 'P0001'
      ]
    ],
    [
      'Description' => 'Your product description',
      'PriceExcl' => 100
    ]
  ])

Update invoice

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->edit([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Number' => 1,
        'ProductCode' => 'P0001'
      ]
    ],
    [
      'Description' => 'Your product description',
      'PriceExcl' => 100
    ]
  ])

Show invoice

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->show(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->show(['InvoiceCode' => $invoiceCode]);

Delete invoice

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->delete(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->delete(['InvoiceCode' => $invoiceCode]);

Credit

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->credit(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->credit(['InvoiceCode' => $invoiceCode]);

Part payment

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->partPayment(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->partPayment(['InvoiceCode' => $invoiceCode]);

Mark invoice as paid

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->markAsPaid(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->markAsPaid(['InvoiceCode' => $invoiceCode]);

Mark invoice as unpaid

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->markAsUnpaid(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->markAsUnpaid(['InvoiceCode' => $invoiceCode]);

Send by email

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->sendByEmail(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->sendByEmail(['InvoiceCode' => $invoiceCode]);

Send reminder by email

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->sendReminderByEmail(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->sendReminderByEmail(['InvoiceCode' => $invoiceCode]);

Download

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->download(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->download(['InvoiceCode' => $invoiceCode]);

Block

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->block(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->block(['InvoiceCode' => $invoiceCode]);

Unblock

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->unblock(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->unblock(['InvoiceCode' => $invoiceCode]);

Schedule

Required parameter: Identifier or InvoiceCode and ScheduledAt.

$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'
  ])

Cancel schedule

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->cancelSchedule(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->cancelSchedule(['InvoiceCode' => $invoiceCode]);

Pause payment process

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->paymentProcessPause(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->paymentProcessPause(['InvoiceCode' => $invoiceCode]);

Reactivate payment process

Required parameter: Identifier or InvoiceCode.

$weFact->invoices()->paymentProcessReactivate(['Identifier' => $invoiceId]);
// or
$weFact->invoices()->paymentProcessReactivate(['InvoiceCode' => $invoiceCode]);

Sort lines

Required parameter: Identifier or InvoiceCode and InvoiceLines Identifier.

$weFact->invoices()->sortLines([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Identifier' => $invoiceLineId,
      ]
    ]
  ]);

Add invoice line

Required parameter: Identifier or InvoiceCode and InvoiceLines.

$weFact->invoices()->addLine([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Number' => 1,
        'ProductCode' => 'P0001'
      ]
    ],
  ]);

Delete invoice line

Required parameter: Identifier or InvoiceCode and InvoiceLines Identifier.

$weFact->invoices()->deleteLine([
    'Identifier' => $invoiceId,
    'InvoiceLines' => [
      [
        'Identifier' => $invoiceLineId,
      ]
    ]
  ]);

Add attachment

Required parameter: ReferenceIdentifier or InvoiceCode, Tyoe, Filename and Base64.

$weFact->invoices()->addAttachment([
    'ReferenceIdentifier' => $invoiceId,
    'Type' => 'invoice',
    'Filename' => 'test.pdf',
    'Base64' => 'base64string'
  ]);

Delete attachment

Required parameter: Identifier or Filename, ReferenceIdentifier or InvoiceCode and Type.

$weFact->invoices()->deleteAttachment([
    'Identifier' => $attachmentId,
    'ReferenceIdentifier' => $invoiceId,
    'Type' => 'invoice',
  ]);

Download attachment

Required parameter: Identifier or Filename, ReferenceIdentifier or InvoiceCode and Type.

$weFact->invoices()->downloadAttachment([
    'ReferenceIdentifier' => $invoiceId,
    'Filename' => 'test.pdf',
    'Type' => 'invoice',
  ]);

Product

List products

$weFact->products()->list();
// or use listAll to call the show method for each item
$response = $weFact->products()->listAll();

Create product

Required parameters: ProductName, ProductKeyPhrase and PriceExcl.

$weFact->products()->create([
    'ProductName' => 'Your product name',
    'ProductKeyPhrase' => 'Your product key phrase',
    'PriceExcl' => 100
  ])

Update product

Required parameter: Identifier or ProductCode.

$weFact->products()->edit([
    'Identifier' => $productId,
    'ProductName' => 'Your product name',
    'ProductKeyPhrase' => 'Your product key phrase',
    'PriceExcl' => 100
  ])

Show product

Required parameter: Identifier

$weFact->products()->show(['Identifier' => $productId]);

Delete product

Required parameter: Identifier or ProductCode.

$weFact->products()->delete(['Identifier' => $productId]);
// or
$weFact->products()->delete(['ProductCode' => $productCode]);

Settings

List settings

$weFact->settings()->list();

Settings - Cost Category

List cost categories

$weFact->costCategories()->list();
// or use listAll to call the show method for each item
$response = $weFact->costCategories()->listAll();

Create cost category

Required parameters: Title.

$weFact->costCategories()->create([
    'Title' => 'Your cost category title',
  ]);

Update cost category

Required parameter: Identifier.

$weFact->costCategories()->edit([
  'Identifier' => $costCategoryId,
]);

Show cost category

Required parameter: Identifier.

$weFact->costCategories()->show(['Identifier' => $costCategoryId]);

Delete cost category

Required parameter: Identifier.

$weFact->costCategories()->delete(['Identifier' => $costCategoryId]);

Subscription

List subscriptions

$weFact->subscriptions()->list();
// or use listAll to call the show method for each item
$response = $weFact->subscriptions()->listAll();

Create subscription

Required parameters: Debtor or DebtorCode and ProductCode. When ProductCode is empty, Description, PriceExcl and Periodic are required.

Please note: You can pass either the TerminateAfter or the TerminationDate, not both. The TerminateAfter includes the number of times the subscription has been billed in the past.

$weFact->subscriptions()->create([
    'DebtorCode' => 'DB10000',
    'ProductCode' => 'P0001',
    'Description' => 'Your product description',
    'PriceExcl' => 100,
    'Periodic' => 'month',
    'TerminateAfter' => 12
  ])

Update subscription

Required parameter: Identifier.

Please note: You can pass either the TerminateAfter or the TerminationDate, not both. The TerminateAfter includes the number of times the subscription has been billed in the past.

$weFact->subscriptions()->edit([
    'Identifier' => $subscriptionId,
    'Description' => 'Your product description',
    'PriceExcl' => 100,
    'Periodic' => 'month',
    'TerminateAfter' => 12
  ])

Show subscription

Required parameter: Identifier.

$weFact->subscriptions()->show(['Identifier' => $subscriptionId]);

Terminate subscription

Required parameter: Identifier.

$weFact->subscriptions()->terminate(['Identifier' => $subscriptionId]);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.