recurly v0.2.2 Recurly.Transaction
Module for handling transactions in Recurly. See the developer docs on transactions for more details
Summary
Functions
Creates an transaction from a changeset. Supports nesting the billing_info
Finds an transaction given a transaction uuid. Returns the transaction or an error
Generates the path to an transaction given the transaction code
Creates a stream of transactions given some options
Updates an transaction from a changeset
Functions
Creates an transaction from a changeset. Supports nesting the billing_info
Parameters
changeset
Keyword list changeset
Examples
alias Recurly.ValidationError
case Recurly.Transaction.create(transaction_code: "mytransactioncode") do
{:ok, transaction} ->
# created the transaction
{:error, %ValidationError{errors: errors}} ->
# will give you a list of validation errors
end
Finds an transaction given a transaction uuid. Returns the transaction or an error.
Parameters
uuid
String transaction uuid
Examples
alias Recurly.NotFoundError
case Recurly.Transaction.find("ialskdjaldkjsaldkjas") do
{:ok, transaction} ->
# Found the transaction
{:error, %NotFoundError{}} ->
# 404 transaction was not found
end
Generates the path to an transaction given the transaction code
Parameters
transaction_code
String transaction code
Creates a stream of transactions given some options.
Parameters
options
Keyword list of the request options. See options in the transaction list section of the docs.
Examples
See Recurly.Resource.stream/3
for more detailed examples of
working with resource streams.
# stream of successful transactions sorted from most recently
# created to least recently created
stream = Recurly.Transaction.stream(state: :successful, sort: :created_at)
Updates an transaction from a changeset
Parameters
transaction
transaction resource structchangeset
Keyword list changeset representing the updates
Examples
alias Recurly.ValidationError
changes = [
first_name: "Benjamin",
last_name: nil
]
case Recurly.transaction.update(transaction, changes) do
{:ok, transaction} ->
# the updated transaction
{:error, %ValidationError{errors: errors}} ->
# will give you a list of validation errors
end