• Stars
    star
    181
  • Rank 212,110 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

💰 Simple invoicing service (REST API): from JSON to PDF

Invoice as a service

This service generates professional looking PDF invoices, from a simple POST HTTP request with json payload.

File destinations / storage

Rendered file can be returned into the HTTP response or exported to:

  • AWS S3 (and any compatible storage destination)
  • FTP server
  • Webhook
  • Zapier: "Catch hook" trigger, can be linked to Drive, Dropbox...

Demo

Screenshot

Usage

I provide invoice-as-a-service with a full hosted environment for fast and easy setup (endpoint: https://invoice-as-a-service.cleverapps.io).

For improved privacy, you can also deploy the project on your own infrastructure for free.

Hosted

$ curl "https://invoice-as-a-service.cleverapps.io/api/invoice/generate" \
     -X POST -H "content-type: application/json" \
     -d '{

        "id": "42",
        "currency": "€",
        "lang": "en",
        "date": 1520852472,
        "due_date": 1521457272,
        "paid": false,
        "payment_link": "https://screeb.app/user/invoices/42/pay",
        "decimals": 2,
        "notes": "Lorem ipsum dolor sit amet.",

        "items": [
            {
                "title": "'Growth' plan Screeb.app",
                "description": "1 year subscription",
                "price": 42,
                "quantity": 1,
                "tax": 20
            }
        ],

        "customer": {
            "summary": "John Doe",
            "address_line_1": "Baxter Building, 42nd street, Madison Avenue",
            "address_line_2": "Manhattan, NY, 11234",
            "address_line_3": "United States",
            "address_line_4": "Earth",
            "phone": "1-888-548-0034",
            "email": "[email protected]"
        },

        "company": {
            "summary": "Screeb",
            "address_line_1": "123, place de Bretagne",
            "address_line_2": "44000 Nantes",
            "address_line_3": "France",
            "address_line_4": "Earth",
            "phone": "1-888-548-0034",
            "email": "[email protected]",
            "logo_url": "https://raw.githubusercontent.com/samber/invoice-as-a-service/master/screeb-logo.png",
            "other": [
                "EMEA office",
                {
                    "title": "Business hours",
                    "content": "9am - 6pm"
                }
            ]
        },

        "s3": {
            "presigned_url": null
        },

        "ftp": {
        	"host": "127.0.0.1",
        	"username": "ftpuser",
        	"password": "superSecretPassword",
        	"path" : "/var/html/share/"
        },

        "webhook": {
            "url": "https://webhook.example.com/invoice/store",
            "headers": {
                "x-token": "very-secret-token"
            }
        },

        "zapier": {
            "zap_url": "https://hooks.zapier.com/hooks/catch/xxxxxxx/yyyyyy",
            "filename": "invoice-42.pdf"
        }

     }'

Self hosted

$ composer install
$ php artisan serve
$ curl "http://localhost:8000/api/invoice/generate" \
     -X POST -H "content-type: application/json" \
     -d '{ ... }'

User interface from contributor

Here => crocomo2744.github.io/Invoicing-form

Properties

Property Type Required Description Example
id string yes Your invoice reference "42"
currency string yes Your billing currency "€"
lang string yes Only english supported for now "en"
tax float yes Tax percentage 20
date integer yes Timestamp of invoice creation date 1520852472
due_date integer yes Timestamp of invoice due date 1521457272
paid boolean no Adding a "paid" image (default: false) false
payment_link string no Payment link "https://screeb.app/user/invoices/42/pay"
decimals integer no Number decimals for prices (default: 2) 2
notes string no Terms, conditions or anything you have to write in order to edit a valid invoice. "Lorem ipsum dolor sit amet."
items array yes List of items [ Item(...), Item(...) ]
customer object yes Customer infos Customer(...)
company object yes Company infos Company(...)
s3 object false AWS S3 invoice upload S3Upload(...)
ftp object false FTP invoice upload FTPUpload(...)
webhook object false Webhook invoice upload WebhookUpload(...)
zapier object false Zapier invoice upload ZapierUpload(...)

Item:

Property Type Required Description Example
title string yes Product or service name "'Growth' plan Screeb.app"
description string no Product or service description "1 year subscription"
price float yes Product or service price 42
quantity float no Product or service quantity (default: 1) 1
tax float no Tax rate (default: 0) 1

Customer:

Property Type Required Description Example
summary string yes Organisation or customer name "John Doe"
address_line_1 string yes Customer address, line 1 "Baxter Building, 42nd street, Madison Avenue"
address_line_2 string no Customer address, line 2 "Manhattan, NY, 11234"
address_line_3 string no Customer address, line 3 "United States"
address_line_4 string no Customer address, line 4 "Earth"
phone string no Customer phone number "1-888-548-0034"
email string no Customer email address "[email protected]"
siret (deprecated) string no French company identification number "539 138 107 00021"
other array of mixed string and Other() no Customer additional infos [ String, Other(), ... ]

Company:

Property Type Required Description Example
summary string yes Your organisation name "Screeb"
address_line_1 string yes Customer address, line 1 "123, place de Bretagne"
address_line_2 string no Customer address, line 2 "44000 Nantes"
address_line_3 string no Customer address, line 3 "France"
address_line_4 string no Customer address, line 4 "Earth"
phone string no Customer phone number "1-888-548-0034"
email string no Customer email address "[email protected]"
logo_url string no URL of your company logo "https://acme.corp/logo.png"
logo_b64 string no Base64 encoded image of your company logo "data:image/png;base64,........."
siret (deprecated) string no French company identification number "539 138 107 00021"
other array of mixed string and Other() no Company additional infos [ String, Other(), ... ]

customer.other[].* and company.other[].*

customer.other and company.other fields are arrays of mixed type: simple string or the following object:

Property Type Required Description Example
title string true Field name "Twitter handle"
content string true Field value "@foobar"

S3 upload

Property Type Required Description Example
presigned_url string false Presigned AWS S3 upload url "https://my-bucket.s3.eu-central-1.amazonaws.com/[email protected]?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxx&X-Amz-Date=xxxx&X-Amz-Expires=xxxx&X-Amz-Signature=xxxx&X-Amz-SignedHeaders=host"

FTP upload

Property Type Required Description Example
host string true The host, IP Address of the server "ftp.example.com"
username string true The ftp username to connect "john"
password string true The ftp password of the user you are trying to connect "test1234"
port integer false The port used to connect, default is 21. 21
ssl boolean false If the connection supports SSL mention that here, default is false. true
passive boolean false If it should use a passive connection, default is true. true
path string true The full path on the server where you want the invoice to be uploaded. "/home/john/share"

Webhook upload

Property Type Required Description Example
url string true The URL of the destination webhook "https://webhook.example.com/invoice/store"
headers object false These headers will be inserted into webhook request { "x-token": "very-secret-token" }

Zapier upload

Property Type Required Description Example
zap_url string true URL of Zapier Hook "https://hooks.zapier.com/hooks/catch/xxxxxxx/yyyyyy"
filename string false Filename that will be provided into Zapier Hook "invoice-42.pdf"

Notes

The provided logo_url (optional) must be accessible from the invoice-as-a-service API !

Contribute

Hell yeah!

Clone + pull-request.

I usually reply in hours or days ;)

Magic happens here:

  • template: resources/views/invoices/default.blade.php
  • controller + input validation: app/Http/Controllers/InvoiceController.php
  • pdf build: app/Helpers/PDF.php
  • invoice storage: app/Helpers/Storage.php

AWS S3 - Generate presigned upload url:

$ aws configure
$ node ./scripts/presign-upload-url.js <region> <my-bucket> invoices/[email protected]

Update dependencies

$ composer outdated -D
$ composer update <package-name> --with-dependencies

More Repositories

1

lo

💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)
Go
17,419
star
2

awesome-prometheus-alerts

🚨 Collection of Prometheus alerting rules
HTML
6,502
star
3

mo

🦄 Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)
Go
2,587
star
4

do

⚙️ A dependency injection toolkit based on Go 1.18+ Generics.
Go
1,807
star
5

oops

🔥 Error handling library with context, assertion, stack trace and source fragments
Go
384
star
6

slog-multi

🚨 Design workflows of slog handlers: pipeline, middleware, fanout, routing, failover, load balancing...
Go
342
star
7

sync-ssh-keys

🔐 Sync public ssh keys to ~/.ssh/authorized_keys, based on Github/Gitlab organization membership.
Go
138
star
8

slog-gin

🚨 Gin middleware for slog logger
Go
109
star
9

chartjs-plugin-datasource-prometheus

📊 Chart.js plugin for Prometheus
TypeScript
107
star
10

slog-formatter

🚨 slog: Attribute formatting
Go
107
star
11

slog-echo

🚨 Echo middleware for slog logger
Go
100
star
12

go-gpt-3-encoder

Go BPE tokenizer (Encoder+Decoder) for GPT2 and GPT3
Go
78
star
13

the-great-gpt-firewall

🤖 A curated list of websites that restrict access to AI Agents, AI crawlers and GPTs
Python
75
star
14

prometheus-query-js

📊 A Javascript client for Prometheus query API
TypeScript
58
star
15

hot

🌶️ In-memory caching library for Go
Go
58
star
16

github-actions-runner

✅ Docker images for starting self-hosted Github Actions runner(s).
Dockerfile
57
star
17

slog-fiber

🚨 Fiber middleware for slog logger
Go
52
star
18

slog-sampling

🚨 slog sampling: drop repetitive log records
Go
49
star
19

slog-chi

🚨 Chi middleware for slog logger
Go
43
star
20

slog-sentry

🚨 slog: Sentry handler
Go
43
star
21

awesome-olap

A curated list of awesome Online Analytical Processing databases, frameworks, ressources and other awesomeness.
37
star
22

grafana-flamegraph-panel

📊 Flame graph panels for Grafana
JavaScript
37
star
23

slog-loki

🚨 slog: Loki handler
Go
36
star
24

slog-http

🚨 net/http middleware for slog logger
Go
32
star
25

slog-zerolog

🚨 slog: Zerolog handler
Go
30
star
26

workshop-prometheus-grafana

📊 Prometheus and Grafana 101
JavaScript
30
star
27

slog-zap

🚨 slog: Zap handler
Go
23
star
28

go-metered-io

📐 A drop-in replacement to io.Reader and io.Writer with the total number of bytes transfered.
Go
23
star
29

go-amqp-pubsub

Fault tolerant Pub/Sub library for RabbitMQ
Go
21
star
30

go-singleflightx

🧬 x/sync/singleflight but with generics, batching, sharding and nullable result
Go
19
star
31

slog-logrus

🚨 slog: Logrus handler
Go
18
star
32

slog-slack

🚨 slog: Slack handler
Go
18
star
33

arp-spoofing

💥 Simple implementation of arp poisoning attack ;)
C
16
star
34

pg_cron

⏰ PostgreSQL extension for running periodic jobs
C
15
star
35

go-tcp-pool

✨ Drop-in replacement to net.Conn with pooling and auto-reconnect
Go
14
star
36

go-type-to-string

🕵️‍♂️ Extract a string representation of Go type
Go
14
star
37

slog-syslog

🚨 slog: Syslog handler
Go
13
star
38

refined-hn

JavaScript
11
star
39

git-contrib-graph

📊 Displays a github-like contribution graph, of every contributors of a repository
Go
10
star
40

slog-nats

🚨 slog: NATS handler
Go
10
star
41

slog-parquet

🚨 slog: Parquet handler + Object Storage
Go
10
star
42

slog-datadog

🚨 slog: Datadog handler
Go
10
star
43

free_proxy_list

Free proxy list [NOT MAINTAINED ANYMORE - please fork]
Shell
9
star
44

slog-otel

OTEL toolchain for slog
Makefile
8
star
45

slog-graylog

🚨 slog: Graylog handler
Go
7
star
46

powEUr

Python
7
star
47

slog-telegram

🚨 slog: Telegram handler
Go
7
star
48

node-promfiler

Expose a http endpoint for exporting node.js v8 profiling
JavaScript
7
star
49

slog-webhook

🚨 slog: Webhook handler
Go
7
star
50

slog-betterstack

🚨 slog: Betterstack handler
Go
7
star
51

slog-common

Common toolchain for slog
Go
6
star
52

slog-kafka

🚨 slog: Kafka handler
Go
6
star
53

slog-channel

🚨 slog: Go channel handler
Go
6
star
54

slog-logstash

🚨 slog: Logstash handler
Go
5
star
55

ansible-role-airbyte

Ansible role for Airbyte
5
star
56

slog-fluentd

🚨 slog: Fluentd handler
Go
4
star
57

remote-dev-environment

👨‍💻 My development environment is too slow, let's fix that !
4
star
58

GoogleCalendarNotifier-FitbitTracker

Google Calendar notifier for Fitbit Tracker
Gosu
4
star
59

slog-mock

🚨 slog: mock handler
Go
4
star
60

slog-quickwit

🚨 slog: Quickwit handler
Go
4
star
61

criterion-rpm-package

RPM package for Criterion (C unit testing)
Shell
3
star
62

dagobert

A simple Go client for the clip-as-service server
Go
3
star
63

rabbitmq-flooding

Cluster recovery testing. Floods RabbitMQ with random data.
Python
3
star
64

go-psi

🥵 Pressure Stall Informations (PSI) and starvation notifier
Go
3
star
65

slog-microsoft-teams

🚨 slog: Microsoft Teams handler
Go
3
star
66

llvm_dart_binding

Binding Dart/LLVM (using LLVM bytecode from Dart)
Dart
3
star
67

lab-langchain-getting-started

Python
2
star
68

BTCC_api

A basic API wrapper for the BTCC Trading and Market FIX API.
JavaScript
2
star
69

ngx-domarrow

Declarative and template-driven DOMArrow integration for Angular2+
TypeScript
2
star
70

github-stackoverflow-email-scrapping

Scrape top Github and Stack-Overflow users to find email address
Go
2
star
71

nft-http-api

🚦 NFT over HTTP API
Go
2
star
72

go-quickwit

🍱 A Go ingestion client for Quickwit
Go
2
star
73

celery_demonstration

Async worker + scheduling
Python
2
star
74

dockerfiles

Dockerfile
1
star
75

SaaS-Cookbook-List

List of Cookbook about SaaS development (ENG/FR)
1
star
76

dotfiles

@samber's dotfiles
JavaScript
1
star
77

grafana-dashboard-nomad

Grafana dashboards for Nomad (Docker orchestrator from Hashicorp)
1
star
78

go-clevercloud-api

Go library for Clever-Cloud api
Go
1
star
79

lab-langchain

Python
1
star
80

slog-mattermost

🚨 slog: Mattermost handler
Go
1
star
81

jitsi-virtual-background

JavaScript
1
star
82

raw-ip-udp-sockets-chap

Simple implementation of CHAP protocol, with raw socket layers (3+4)
C
1
star
83

lab-parquet

Go
1
star
84

canvas-to-bmp

TypeScript
1
star
85

refined-cycle-app

JavaScript
1
star
86

azure-ad-oauth2-proxy

Dockerfile
1
star
87

packer-qemu-debian

Builds Debian 8 image for Qemu
Shell
1
star
88

poc-selenium-unit-test-css

Python
1
star
89

maxscale-experiments

Demonstration step-by-step of MaxScale for master/slave query spliting/routing #mysql #docker
Shell
1
star
90

google-takeout-to-s3

🚨 Simple script to upload encrypted Google Takeout archives to S3.
1
star
91

messenger-bot-clock

Messenger bot replying with current time
JavaScript
1
star
92

fb-messenger-bot-psychologist

🤖 A Messenger bot talking like a psychologist
Emacs Lisp
1
star
93

promql-exporter

Prometheus exporter for PromQL endpoints (replacing federation and remote-write)
Go
1
star