View Source StarkBank.Invoice (starkbankpublish v0.0.1)
Groups Invoice related functions
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. To create scheduled Invoices, which will display the discount, interest, etc. on the final users banking interface, use dates instead of datetimes on the "due" and "discounts" fields.
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 list of up to 100 Invoice objects previously created in the Stark Bank API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.
Same as page(), but it will unwrap the error tuple and raise in case of errors.
Receive the Invoice.Payment sub-resource associated with a paid Invoice.
Same as payment(), 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.
Types
@type t() :: %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(), link: term(), name: term(), nominal_amount: term(), pdf: term(), status: term(), tags: term(), tax_id: term(), transaction_ids: term(), updated: term() }
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. To create scheduled Invoices, which will display the discount, interest, etc. on the final users banking interface, use dates instead of datetimes on the "due" and "discounts" fields.
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, Date or string, default now + 2 days]: Invoice due date in UTC ISO format. ex: ~U[2021-03-26 19:32:35.418698Z] for immediate invoices and ~D[2020-10-28] for scheduled invoices: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":link
[string, default nil]: public Invoice webpage URL. ex: "https://my-workspace.sandbox.starkbank.com/invoicelink/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):transaction_ids
[list of strings, default nil]: ledger transaction ids linked to this boleto. ex: ["19827356981273"]: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]
@spec create([t() | map()], [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: {:ok, [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, default nil]: 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
@spec create!([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.
@spec get(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: {:ok, 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, default nil]: 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
@spec get!(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: t()
Same as get(), but it will unwrap the error tuple and raise in case of errors.
@spec page( cursor: binary(), 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() ) :: {:ok, {binary(), [t()]}} | {:error, [%StarkBank.Error{code: term(), message: term()}]}
Receive a list of up to 100 Invoice objects previously created in the Stark Bank API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.
Options:
:cursor
[string, default nil]: cursor returned on the previous page function call: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, default nil]: 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 and cursor to retrieve the next page of Invoice objects
@spec page!( cursor: binary(), 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() ) :: [t()]
Same as page(), but it will unwrap the error tuple and raise in case of errors.
@spec payment(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: {:ok, StarkBank.Invoice.Payment.t()} | {:error, [%StarkBank.Error{code: term(), message: term()}]}
Receive the Invoice.Payment sub-resource associated with a paid Invoice.
Parameters (required):
:id
[string]: Invoice id. ex: '5656565656565656'
Parameters (optional):
:user
[Organization/Project, default nil]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- Invoice.Payment sub-resource
@spec payment!(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: StarkBank.Invoice.Payment.t()
Same as payment(), but it will unwrap the error tuple and raise in case of errors.
@spec pdf(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: {:ok, binary()} | {:error, [%StarkBank.Error{code: term(), message: term()}]}
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, default nil]: 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
@spec pdf!(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: binary()
Same as pdf(), but it will unwrap the error tuple and raise in case of errors.
@spec qrcode(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: {:ok, binary()} | {:error, [%StarkBank.Error{code: term(), message: term()}]}
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, default nil]: 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
@spec qrcode!(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: binary()
Same as qrcode(), but it will unwrap the error tuple and raise in case of errors.
@spec query( 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, [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, default nil]: 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
@spec query!( 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, [t()]} | {:halt, any()} | {:suspend, any()}, any() -> any())
Same as query(), but it will unwrap the error tuple and raise in case of errors.
@spec update(binary(), status: bool(), amount: integer(), due: DateTime, expiration: integer(), user: StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil ) :: {:ok, t()} | {:error, [%StarkBank.Error{code: term(), message: term()}]}
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, default nil]: 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
@spec update!(binary(), status: bool(), amount: integer(), due: DateTime, expiration: integer(), user: StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil ) :: t()
Same as update(), but it will unwrap the error tuple and raise in case of errors.