starkbank v2.4.1 StarkBank.Invoice View Source
Groups Invoice related functions
Link to this section Summary
Functions
When you initialize a Invoice struct, the entity will not be automatically sent to the Stark Bank API. The 'create' function sends the structs to the Stark Bank API and returns the list of created structs.
Send a list of Invoice structs for creation in the Stark Bank API
Same as create(), but it will unwrap the error tuple and raise in case of errors.
Receive a single Invoice struct previously created in the Stark Bank API by passing its id
Same as get(), but it will unwrap the error tuple and raise in case of errors.
Receive a single Invoice pdf file generated in the Stark Bank API by passing its id.
Same as pdf(), but it will unwrap the error tuple and raise in case of errors.
Receive a single Invoice QR Code png file generated in the Stark Bank API by passing its id.
Same as qrcode(), but it will unwrap the error tuple and raise in case of errors.
Receive a stream of Invoice structs previously created in the Stark Bank API
Same as query(), but it will unwrap the error tuple and raise in case of errors.
Update an Invoice by passing id, if it hasn't been paid yet.
Same as update(), but it will unwrap the error tuple and raise in case of errors.
Link to this section Types
t()
View Sourcet() :: %StarkBank.Invoice{ amount: term(), brcode: term(), created: term(), descriptions: term(), discount_amount: term(), discounts: term(), due: term(), expiration: term(), fee: term(), fine: term(), fine_amount: term(), id: term(), interest: term(), interest_amount: term(), name: term(), nominal_amount: term(), pdf: term(), status: term(), tags: term(), tax_id: term(), updated: term() }
Link to this section Functions
When you initialize a Invoice struct, the entity will not be automatically sent to the Stark Bank API. The 'create' function sends the structs to the Stark Bank API and returns the list of created structs.
Parameters (required):
:amount
[integer]: Invoice value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34):tax_id
[string]: payer tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80":name
[string]: payer name. ex: "Iron Bank S.A."
Parameters (optional):
:due
[DateTime or string, default now + 2 days]: Invoice due date in UTC ISO format. ex: ~U[2021-03-26 19:32:35.418698Z]:expiration
[integer, default 59 days]: time interval in seconds between due date and expiration date. ex 123456789:fine
[float, default 0.0]: Invoice fine for overdue payment in %. ex: 2.5:interest
[float, default 0.0]: Invoice monthly interest for overdue payment in %. ex: 5.2:discounts
[list of dictionaries, default nil]: list of dictionaries with "percentage":float and "due":string pairs:tags
[list of strings, default nil]: list of strings for tagging:descriptions
[list of dictionaries, default nil]: list of dictionaries with "key":string and (optional) "value":string pairs
Attributes (return-only):
:pdf
[string, default nil]: public Invoice PDF URL. ex: "https://invoice.starkbank.com/pdf/d454fa4e524441c1b0c1a729457ed9d8":nominal_amount
[integer, default nil]: Invoice emission value in cents (will change if invoice is updated, but not if it's paid). ex: 400000:fine_amount
[integer, default nil]: Invoice fine value calculated over nominal_amount. ex: 20000:interest_amount
[integer, default nil]: Invoice interest value calculated over nominal_amount. ex: 10000:discount_amount
[integer, default nil]: Invoice discount value calculated over nominal_amount. ex: 3000:id
[string, default nil]: unique id returned when Invoice is created. ex: "5656565656565656":brcode
[string, default nil]: BR Code for the Invoice payment. ex: "00020101021226800014br.gov.bcb.pix2558invoice.starkbank.com/f5333103-3279-4db2-8389-5efe335ba93d5204000053039865802BR5913Arya Stark6009Sao Paulo6220051656565656565656566304A9A0":status
[string, default nil]: current Invoice status. ex: "created", "paid", "canceled" or "overdue":fee
[integer, default nil]: fee charged by this Invoice. ex: 65 (= R$ 0.65):created
[DateTime, default nil]: creation datetime for the Invoice. ex: ~U[2020-03-26 19:32:35.418698Z]:updated
[DateTime, default nil]: latest update datetime for the Invoice. ex: ~U[2020-11-26 17:31:45.482618Z]
create(invoices, options \\ [])
View Sourcecreate([StarkBank.Invoice.t() | map()], [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: {:ok, [StarkBank.Invoice.t()]} | {:error, [StarkBank.Error.t()]}
Send a list of Invoice structs for creation in the Stark Bank API
Parameters (required):
invoices
[list of Invoice structs]: list of Invoice structs to be created in the API
Options:
:user
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- list of Invoice structs with updated attributes
create!(invoices, options \\ [])
View Sourcecreate!([StarkBank.Invoice.t() | map()], [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: any()
Same as create(), but it will unwrap the error tuple and raise in case of errors.
get(id, options \\ [])
View Sourceget(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: {:ok, StarkBank.Invoice.t()} | {:error, [%StarkBank.Error{code: term(), message: term()}]}
Receive a single Invoice struct previously created in the Stark Bank API by passing its id
Parameters (required):
id
[string]: struct unique id. ex: "5656565656565656"
Options:
:user
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- Invoice struct with updated attributes
get!(id, options \\ [])
View Sourceget!(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: StarkBank.Invoice.t()
Same as get(), but it will unwrap the error tuple and raise in case of errors.
Receive a single Invoice pdf file generated in the Stark Bank API by passing its id.
Parameters (required):
id
[string]: struct unique id. ex: "5656565656565656"
Options:
:user
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- Invoice pdf file content
Same as pdf(), but it will unwrap the error tuple and raise in case of errors.
Receive a single Invoice QR Code png file generated in the Stark Bank API by passing its id.
Parameters (required):
id
[string]: struct unique id. ex: "5656565656565656"
Options:
:user
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- Invoice QR Code png file content
Same as qrcode(), but it will unwrap the error tuple and raise in case of errors.
query(options \\ [])
View Sourcequery( limit: integer(), after: Date.t() | binary(), before: Date.t() | binary(), status: binary(), tags: [binary()], ids: [binary()], user: StarkBank.User.Project.t() | StarkBank.User.Organization.t() ) :: ({:cont, {:ok, [StarkBank.Invoice.t()]}} | {:error, [StarkBank.Error.t()]} | {:halt, any()} | {:suspend, any()}, any() -> any())
Receive a stream of Invoice structs previously created in the Stark Bank API
Options:
:limit
[integer, default nil]: maximum number of structs to be retrieved. Unlimited if nil. ex: 35:after
[Date or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]:before
[Date or string, default nil]: date filter for structs created only before specified date. ex: ~D[2020-03-25]:status
[string, default nil]: filter for status of retrieved structs. ex: "created", "paid", "canceled" or "overdue":tags
[list of strings, default nil]: tags to filter retrieved structs. ex: ["tony", "stark"]:ids
[list of strings, default nil]: list of ids to filter retrieved structs. ex: ["5656565656565656", "4545454545454545"]:user
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- stream of Invoice structs with updated attributes
Same as query(), but it will unwrap the error tuple and raise in case of errors.
Update an Invoice by passing id, if it hasn't been paid yet.
Parameters (required):
:id
[string]: Invoice id. ex: '5656565656565656'
Parameters (optional):
:status
[string]: You may cancel the invoice by passing "canceled" in the status:amount
[string]: Nominal amount charge by the invoice. ex: 100 (R$1.00):due
[DateTime or string]: Invoice due date in UTC ISO format. ex: ~U[2021-03-26 19:32:35.418698Z]:expiration
[integer]: time interval in seconds between due date and expiration date. ex 123456789:user
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- target Invoice with updated attributes
update!(id, parameters \\ [])
View Sourceupdate!(binary(), status: bool(), amount: integer(), due: DateTime, expiration: integer(), user: StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil ) :: StarkBank.Invoice.t()
Same as update(), but it will unwrap the error tuple and raise in case of errors.