A Python 3 module to interact with the Green Invoice API.
Project description
Green Invoice API
A Python 3 module to interact with the Green Invoice API.
Install
pip install green-invoice
Example
from datetime import datetime
import logging
import green_invoice
from green_invoice.models import (
Currency,
DocumentLanguage,
DocumentType,
PaymentCardType,
PaymentDealType,
PaymentType,
IncomeVatType,
)
from green_invoice.resources import DocumentResource
def main():
green_invoice.client.configure(
env="sandbox",
# Authentication
api_key_id="YOUR_API_KEY_ID",
api_key_secret="YOUR_API_KEY_SECRET",
# Logger
logger=logging.root,
)
order_amount = 50
order_amount_currency = Currency.USD
create_document_for_order(order_amount, order_amount_currency)
def create_document_for_order(amount, amount_currency):
documentResource = DocumentResource()
created_document = documentResource.create(
{
"type": DocumentType.TAX_INVOICE_RECEIPT,
"client": {
"name": "Tom Hanks",
"add": False,
},
"currency": amount_currency,
"lang": DocumentLanguage.ENGLISH,
"signed": True,
"rounding": False,
"income": [
{
"price": amount,
"currency": amount_currency,
"quantity": 1,
"description": "My Cool Product",
"vatType": IncomeVatType.INCLUDED,
}
],
"payment": [
{
"type": PaymentType.CREDIT_CARD,
"date": datetime.today().strftime("%Y-%m-%d"),
"dealType": PaymentDealType.REGULAR,
"cardNum": "4242",
"cardType": PaymentCardType.VISA,
"price": amount,
"currency": amount_currency,
}
],
}
)
print(created_document)
if __name__ == "__main__":
main()
Author
Yaniv Pinchas
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
green_invoice-1.3.0.tar.gz
(12.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file green_invoice-1.3.0.tar.gz.
File metadata
- Download URL: green_invoice-1.3.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9ba74884d1f6f042688f246cc3b37e7cb10164662f1281c5f00a4d0112312e7
|
|
| MD5 |
b65498b93b240520a03f7f8860d1c2e9
|
|
| BLAKE2b-256 |
f16f305ed625b4f5c5e943c8aedc90e3fb9c06b3eefd60f543d5d3543fdb1655
|
File details
Details for the file green_invoice-1.3.0-py3-none-any.whl.
File metadata
- Download URL: green_invoice-1.3.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b18dbac2dd943e436be4a371e5889f86aff8ab0770473b680e612fa330560b6
|
|
| MD5 |
99077b4882a4e3a9d36b33489081a146
|
|
| BLAKE2b-256 |
261e2679c7e7ebaaf3ab7a762d0b7efbb17d14011beae58642e9967fdcea9214
|