Coder Social home page Coder Social logo

invoiceninja / flutter-package Goto Github PK

View Code? Open in Web Editor NEW
39.0 8.0 13.0 10.19 MB

Create PDF invoices and accept payments in a Flutter app

Home Page: https://invoiceninja.com

License: MIT License

Dart 93.11% Kotlin 0.02% Swift 0.06% Objective-C 0.01% CMake 2.45% C++ 3.89% C 0.22% HTML 0.24%
invoices flutter tasks expenses laravel php dart

flutter-package's Introduction

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

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

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

Find the product by key

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

Create/persist the client

var client = Client.forContact(email: '[email protected]');
client = await InvoiceNinja.clients.save(client);

Create/persist the invoice

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

Display the PDF invoice

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

Accept the payment

var invoiceKey = invoice.key;
launch(invoice.url);

// ...

final invoice = await InvoiceNinja.invoices.findByKey(invoiceKey);
if (invoice.isPaid) {
  // ...
}

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

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

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

Load all invoices

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

Load the payments list

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

Find a payment by id

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

Create/persist an invoice and auto-bill it

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

flutter-package's People

Contributors

ggasbarri avatar hillelcoren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter-package's Issues

What is "KEY" and No query results for model [App\\Models\\Company

When following documentation:

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

Where can I find the 'KEY'? Nothing in the self-hosted installation is called a 'key'. Is this supposed to say API Token?

If I assumed the API Token is what you meant, and my self hosted install is at mydomain.com/payments/public, when using the following:

InvoiceNinja.configure(
  'My API Token', // Set your company key or use 'KEY' to test
  url: 'https://mydomain.com/payments/public', // Set your selfhost app URL
  debugEnabled: true,
);

and I execute:

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

I end up with the following error:

{"message":"No query results for model [App\\Models\\Company]."}

However, if I run the following, the product list is returned in json as expected.

Future<List<InvoiceNinjaProduct>> _loadProductsByGet() async {
    String url = 'https://carlinehound.com/payments/public/api/v1/products';

    List data;
    List<InvoiceNinjaProduct> productList = [];

    var response = await http.get(Uri.encodeFull(url), headers: {
      'Content-Type': 'application/json',
      'X-Api-Secret': 'secret',
      'X-Api-Token': 'My API Token',
      'X-Requested-With': 'XMLHttpRequest'
    });

    var resBody = json.decode(response.body);

    data = resBody['data'];

    data.forEach((productJson) {
      InvoiceNinjaProduct product = InvoiceNinjaProduct.fromJson(productJson);
      productList.add(product);
    });

    print(productList[0].name);

    return productList;
  }

So the question is what is the "KEY"?

Can't specify a vendorId when creating a Quote

Trying to run the following code:

  Future<void> createNewQuote(InvoiceNinjaClient invoiceClient) async {
   

    Product product = = await InvoiceNinja.products.findByKey("myProductKey");

    Client client = await InvoiceNinjaAdmin.clients.findByEmail(invoiceClient.email).timeout(Duration(seconds: 30));

    print('Client retrieved');

    Quote quote = Quote.forClient(client, products: [product]);

    print('Ready to send quote');

    await InvoiceNinjaAdmin.quotes.save(quote);
    print('Quote sent to invoice Ninja');
  }

results in the following error:

package:invoiceninja/models/quote.freezed.dart': Failed assertion: line 795 pos 16: 'vendorId != null': is not true.

I cannot figure out how to specify the vendorId for the Quote. Creating an invoice works fine, this only appears when creating a quote.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.