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
Release history Release notifications | RSS feed
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.2.tar.gz
(11.2 kB
view hashes)
Built Distribution
Close
Hashes for green_invoice-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e960d6183f8642c6dbcbb3e582dee83e2308246537171b18231afaaa9e73da7 |
|
MD5 | 8b835f67ae53eb93a245feb39eb16f4f |
|
BLAKE2b-256 | b7db62632c52d906a00be64c2f6e161f5f0e119d52fb810b10e855662ae7ab5b |