项目作者: invoiceninja

项目描述 :
Create PDF invoices and accept payments in a Flutter app
高级语言: Dart
项目地址: git://github.com/invoiceninja/flutter-package.git
创建时间: 2020-07-17T04:55:28Z
项目社区:https://github.com/invoiceninja/flutter-package

开源协议:MIT License

下载


Invoice Ninja

Create PDF invoices and accept payments in a Flutter app


Sample

YouTube Video

YouTube Video

Features

  • Accept online payment in mobile, web and desktop Flutter apps
  • Supports many payment gateways including Stripe, PayPal and more
  • Create professional PDF invoices
  • Includes a self-service client portal
  • Many more 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 which uses token based security. Using this class requires an API token to access the account.

Storefront API

Configure

  1. InvoiceNinja.configure(
  2. 'KEY', // Set your company key or use 'KEY' to test
  3. url: 'https://demo.invoiceninja.com', // Set your selfhost app URL
  4. debugEnabled: true,
  5. );

Load the product list

  1. final products = await InvoiceNinja.products.load();

Find the product by key

  1. final product = await InvoiceNinja.products.findByKey('product_key');

Create/persist the client

  1. var client = Client.forContact(email: 'test@example.com');
  2. client = await InvoiceNinja.clients.save(client);

Create/persist the invoice

  1. var invoice = Invoice.forClient(client, products: [product]);
  2. invoice = await InvoiceNinja.invoices.save(invoice);

Display the PDF invoice

  1. launch(
  2. 'https://docs.google.com/gview?embedded=true&url=${invoice.pdfUrl}',
  3. forceWebView: true,
  4. );

Accept the payment

  1. var invoiceKey = invoice.key;
  2. launch(invoice.url);
  3. // ...
  4. final invoice = await InvoiceNinja.invoices.findByKey(invoiceKey);
  5. if (invoice.isPaid) {
  6. // ...
  7. }

You can use the WidgetsBindingObserver interface to run code when the app is resumed.

Consider giving issue #57536 a thumbs up to make this better in the future.

Admin API

Configure

  1. InvoiceNinjaAdmin.configure(
  2. 'TOKEN', // Set your API token or use 'TOKEN' to test
  3. url: 'https://demo.invoiceninja.com', // Set your selfhost app URL
  4. debugEnabled: true,
  5. );

Find a client by email

  1. final client = await InvoiceNinjaAdmin.clients.findByEmail(email);

Load all invoices

  1. final payments = await InvoiceNinjaAdmin.payments.load();

Load the payments list

  1. final payments = await InvoiceNinjaAdmin.payments.load();

Find a payment by id

  1. final payment = await InvoiceNinjaAdmin.payments.findById(id);

Create/persist an invoice and auto-bill it

  1. var invoice = Invoice.forClient(client, products: [product]);
  2. invoice = await InvoiceNinjaAdmin.invoices.save(invoice, action: InvoiceAction.autoBill);