https://github.com/invoiceninja/flutter-package
Create PDF invoices and accept payments in a Flutter app
https://github.com/invoiceninja/flutter-package
dart expenses flutter invoices laravel php tasks
Last synced: about 2 months ago
JSON representation
Create PDF invoices and accept payments in a Flutter app
- Host: GitHub
- URL: https://github.com/invoiceninja/flutter-package
- Owner: invoiceninja
- License: mit
- Created: 2020-07-17T04:55:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-31T10:17:42.000Z (about 2 years ago)
- Last Synced: 2024-08-22T23:37:17.660Z (10 months ago)
- Topics: dart, expenses, flutter, invoices, laravel, php, tasks
- Language: Dart
- Homepage: https://invoiceninja.com
- Size: 9.95 MB
- Stars: 38
- Watchers: 8
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Invoice Ninja
Create PDF invoices and accept payments in a Flutter app
![]()
## YouTube Video
[](https://www.youtube.com/watch?v=iefk6TOU-Ts)
## Features
* Accept online payment in mobile, web and desktop Flutter apps
* Supports many payment gateways including Stripe, PayPal and [more](https://invoiceninja.com/payments/)
* Create professional [PDF invoices](https://invoiceninja.com/invoice-templates/)
* Includes a self-service client portal
* Many [more features](https://invoiceninja.com/features/)...## Overview
The package provides two main classes:
* `InvoiceNinja`: Supports the public 'Storefront' routes which allow reading the list of products and creating/finding clients and invoices. Using this class works with restricted access to the account.
* `InvoiceNinjaAdmin`: Supports the [REST Admin API](https://api-docs.invoicing.co) which uses token based security. Using this class requires an API token to access the account.## Storefront API
### Configure
```dart
InvoiceNinja.configure(
'KEY', // Set your company key or use 'KEY' to test
url: 'https://demo.invoiceninja.com', // Set your selfhost app URL
debugEnabled: true,
);
```### Load the product list
```dart
final products = await InvoiceNinja.products.load();
```### Find the product by key
```dart
final product = await InvoiceNinja.products.findByKey('product_key');
```### Create/persist the client
```dart
var client = Client.forContact(email: '[email protected]');
client = await InvoiceNinja.clients.save(client);
```### Create/persist the invoice
```dart
var invoice = Invoice.forClient(client, products: [product]);
invoice = await InvoiceNinja.invoices.save(invoice);
```### Display the PDF invoice
```dart
launch(
'https://docs.google.com/gview?embedded=true&url=${invoice.pdfUrl}',
forceWebView: true,
);
```### Accept the payment
```dart
var invoiceKey = invoice.key;
launch(invoice.url);// ...
final invoice = await InvoiceNinja.invoices.findByKey(invoiceKey);
if (invoice.isPaid) {
// ...
}
```You can use the [WidgetsBindingObserver](https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver-class.html) interface to run code when the app is resumed.
Consider giving issue [#57536](https://github.com/flutter/flutter/issues/57536) a thumbs up to make this better in the future.
## Admin API
### Configure
```dart
InvoiceNinjaAdmin.configure(
'TOKEN', // Set your API token or use 'TOKEN' to test
url: 'https://demo.invoiceninja.com', // Set your selfhost app URL
debugEnabled: true,
);
```### Find a client by email
```dart
final client = await InvoiceNinjaAdmin.clients.findByEmail(email);
```### Load all invoices
```dart
final payments = await InvoiceNinjaAdmin.payments.load();
```### Load the payments list
```dart
final payments = await InvoiceNinjaAdmin.payments.load();
```### Find a payment by id
```dart
final payment = await InvoiceNinjaAdmin.payments.findById(id);
```### Create/persist an invoice and auto-bill it
```dart
var invoice = Invoice.forClient(client, products: [product]);
invoice = await InvoiceNinjaAdmin.invoices.save(invoice, action: InvoiceAction.autoBill);
```