• Stars
    star
    181
  • Rank 204,394 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 6 years ago
  • Updated 9 months 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
15,102
star
2

awesome-prometheus-alerts

🚨 Collection of Prometheus alerting rules
HTML
5,944
star
3

mo

πŸ¦„ Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)
Go
2,207
star
4

do

βš™οΈ A dependency injection toolkit based on Go 1.18+ Generics.
Go
1,555
star
5

slog-multi

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

oops

πŸ”₯ Error handling library with context, assertion, stack trace and source fragments
Go
164
star
7

sync-ssh-keys

πŸ” Sync public ssh keys to ~/.ssh/authorized_keys, based on Github/Gitlab organization membership.
Go
134
star
8

chartjs-plugin-datasource-prometheus

πŸ“Š Chart.js plugin for Prometheus
TypeScript
95
star
9

slog-formatter

🚨 slog: Attribute formatting
Go
79
star
10

go-gpt-3-encoder

Go BPE tokenizer (Encoder+Decoder) for GPT2 and GPT3
Go
77
star
11

slog-echo

🚨 Echo middleware for slog logger
Go
72
star
12

slog-gin

🚨 Gin middleware for slog logger
Go
65
star
13

the-great-gpt-firewall

πŸ€– A curated list of websites that restrict access to AI Agents, AI crawlers and GPTs
Python
65
star
14

prometheus-query-js

πŸ“Š A Javascript client for Prometheus query API
TypeScript
60
star
15

github-actions-runner

βœ… Docker images for starting self-hosted Github Actions runner(s).
Dockerfile
57
star
16

grafana-flamegraph-panel

πŸ“Š Flame graph panels for Grafana
JavaScript
37
star
17

slog-fiber

🚨 Fiber middleware for slog logger
Go
35
star
18

slog-sampling

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

workshop-prometheus-grafana

πŸ“Š Prometheus and Grafana 101
JavaScript
30
star
20

slog-sentry

🚨 slog: Sentry handler
Go
30
star
21

slog-chi

🚨 Chi middleware for slog logger
Go
22
star
22

awesome-olap

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

go-amqp-pubsub

Fault tolerant Pub/Sub library for RabbitMQ
Go
16
star
24

pg_cron

⏰ PostgreSQL extension for running periodic jobs
C
15
star
25

slog-loki

🚨 slog: Loki handler
Go
14
star
26

arp-spoofing

πŸ’₯ Simple implementation of arp poisoning attack ;)
C
14
star
27

slog-slack

🚨 slog: Slack handler
Go
14
star
28

slog-zap

🚨 slog: Zap handler
Go
12
star
29

slog-zerolog

🚨 slog: Zerolog handler
Go
12
star
30

go-tcp-pool

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

refined-hn

JavaScript
11
star
32

slog-logrus

🚨 slog: Logrus handler
Go
11
star
33

slog-http

🚨 net/http middleware for slog logger
Go
10
star
34

free_proxy_list

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

slog-syslog

🚨 slog: Syslog handler
Go
9
star
36

slog-parquet

🚨 slog: Parquet handler + Object Storage
Go
9
star
37

go-type-to-string

πŸ•΅οΈβ€β™‚οΈ Extract a string representation of Go type
Go
8
star
38

git-contrib-graph

πŸ“Š Displays a github-like contribution graph, of every contributors of a repository
Go
8
star
39

powEUr

Python
7
star
40

node-promfiler

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

slog-datadog

🚨 slog: Datadog handler
Go
7
star
42

slog-channel

🚨 slog: Go channel handler
Go
5
star
43

go-singleflightx

🧬 x/sync/singleflight but with generics, batching and nullable result
Go
5
star
44

slog-nats

🚨 slog: NATS handler
Go
5
star
45

slog-kafka

🚨 slog: Kafka handler
Go
4
star
46

remote-dev-environment

πŸ‘¨β€πŸ’» My development environment is too slow, let's fix that !
4
star
47

GoogleCalendarNotifier-FitbitTracker

Google Calendar notifier for Fitbit Tracker
Gosu
4
star
48

ansible-role-airbyte

Ansible role for Airbyte
4
star
49

criterion-rpm-package

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

dagobert

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

rabbitmq-flooding

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

slog-graylog

🚨 slog: Graylog handler
Go
3
star
53

go-psi

πŸ₯΅ Pressure Stall Informations (PSI) and starvation notifier
Go
3
star
54

slog-telegram

🚨 slog: Telegram handler
Go
3
star
55

hot

🌢️ In-memory caching library for Go
Go
3
star
56

llvm_dart_binding

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

slog-webhook

🚨 slog: Webhook handler
Go
3
star
58

slog-common

Common toolchain for slog
Go
2
star
59

slog-logstash

🚨 slog: Logstash handler
Go
2
star
60

lab-langchain-getting-started

Python
2
star
61

BTCC_api

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

github-stackoverflow-email-scrapping

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

ngx-domarrow

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

celery_demonstration

Async worker + scheduling
Python
2
star
65

go-metered-io

πŸ“ A drop-in replacement to io.Reader and io.Writer with the total number of bytes transfered.
Go
2
star
66

dotfiles

@samber's dotfiles
JavaScript
1
star
67

grafana-dashboard-nomad

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

slog-fluentd

🚨 slog: Fluentd handler
Go
1
star
69

go-clevercloud-api

Go library for Clever-Cloud api
Go
1
star
70

lab-langchain

Python
1
star
71

slog-mattermost

🚨 slog: Mattermost handler
Go
1
star
72

dockerfiles

Dockerfile
1
star
73

jitsi-virtual-background

JavaScript
1
star
74

SaaS-Cookbook-List

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

raw-ip-udp-sockets-chap

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

lab-parquet

Go
1
star
77

nft-http-api

🚦 NFT over HTTP API
Go
1
star
78

canvas-to-bmp

TypeScript
1
star
79

refined-cycle-app

JavaScript
1
star
80

azure-ad-oauth2-proxy

Dockerfile
1
star
81

packer-qemu-debian

Builds Debian 8 image for Qemu
Shell
1
star
82

poc-selenium-unit-test-css

Python
1
star
83

maxscale-experiments

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

messenger-bot-clock

Messenger bot replying with current time
JavaScript
1
star
85

hello-world-node-pg-redis

Simple health check with NodeJS + Redis + PostgreSQL
JavaScript
1
star
86

slog-microsoft-teams

🚨 slog: Microsoft Teams handler
Go
1
star
87

fb-messenger-bot-psychologist

πŸ€– A Messenger bot talking like a psychologist
Emacs Lisp
1
star