Braintree.Transaction (Braintree v0.13.0)

Create a new sale.

To create a transaction, you must include an amount and either a payment_method_nonce or a payment_method_token.

https://developers.braintreepayments.com/reference/response/transaction/ruby

Link to this section Summary

Functions

Find an existing transaction by transaction_id

Convert a map into a Transaction struct.

Use a transaction_id and optional amount to issue a refund for that transaction

Use a payment_method_nonce or payment_method_token to make a one time charge against a payment method.

Use a transaction_id and optional amount to settle the transaction. Use this if submit_for_settlement was false while creating the charge using sale.

Use a transaction_id to issue a void for that transaction

Link to this section Types

@type t() :: %Braintree.Transaction{
  add_ons: [Braintree.AddOn.t()],
  additional_processor_response: String.t(),
  amount: number(),
  android_pay_card: map(),
  apple_pay: map(),
  avs_error_response_code: String.t(),
  avs_postal_code_response_code: String.t(),
  avs_street_address_response_code: String.t(),
  billing: map(),
  channel: String.t(),
  coinbase_details: String.t(),
  created_at: String.t(),
  credit_card: map(),
  currency_iso_code: String.t(),
  custom_fields: map(),
  customer: map(),
  cvv_response_code: String.t(),
  descriptor: map(),
  disbursement_details: map(),
  discounts: [any()],
  disputes: [any()],
  escrow_status: String.t(),
  gateway_rejection_reason: String.t(),
  id: String.t(),
  merchant_account_id: String.t(),
  order_id: String.t(),
  payment_instrument_type: String.t(),
  paypal: map(),
  plan_id: String.t(),
  processor_authorization_code: String.t(),
  processor_response_code: String.t(),
  processor_response_text: String.t(),
  processor_settlement_response_code: String.t(),
  processor_settlement_response_text: String.t(),
  purchase_order_number: String.t(),
  recurring: String.t(),
  refund_ids: String.t(),
  refunded_transaction_id: String.t(),
  risk_data: String.t(),
  service_fee_amount: number(),
  settlement_batch_id: String.t(),
  shipping: map(),
  status: String.t(),
  status_history: String.t(),
  subscription_details: map(),
  subscription_id: String.t(),
  tax_amount: number(),
  tax_exempt: boolean(),
  type: String.t(),
  updated_at: String.t(),
  voice_referral_number: String.t()
}

Link to this section Functions

Link to this function

find(transaction_id, opts \\ [])

@spec find(String.t(), Keyword.t()) ::
  {:ok, t()} | {:error, Braintree.ErrorResponse.t()}

Find an existing transaction by transaction_id

example

Example

{:ok, transaction} = Transaction.find("123")

Convert a map into a Transaction struct.

Add_ons are converted to a list of structs as well.

example

Example

transaction = Braintree.Transaction.new(%{

"subscription_id" => "subxid",
"status" => "submitted_for_settlement"

})

Link to this function

refund(transaction_id, params, opts \\ [])

@spec refund(String.t(), map(), Keyword.t()) ::
  {:ok, t()} | {:error, Braintree.ErrorResponse.t()}

Use a transaction_id and optional amount to issue a refund for that transaction

example

Example

{:ok, transaction} = Transaction.refund("123", %{amount: "100.00"})

transaction.status # "refunded"
Link to this function

sale(params, opts \\ [])

@spec sale(map(), Keyword.t()) :: {:ok, t()} | {:error, Braintree.ErrorResponse.t()}

Use a payment_method_nonce or payment_method_token to make a one time charge against a payment method.

example

Example

{:ok, transaction} = Transaction.sale(%{
  amount: "100.00",
  payment_method_nonce: @payment_method_nonce,
  options: %{submit_for_settlement: true}
})

transaction.status # "settling"
Link to this function

submit_for_settlement(transaction_id, params, opts \\ [])

@spec submit_for_settlement(String.t(), map(), Keyword.t()) ::
  {:ok, t()} | {:error, Braintree.ErrorResponse.t()}

Use a transaction_id and optional amount to settle the transaction. Use this if submit_for_settlement was false while creating the charge using sale.

example

Example

{:ok, transaction} = Transaction.submit_for_settlement("123", %{amount: "100"})
transaction.status # "settling"
Link to this function

void(transaction_id, opts \\ [])

@spec void(String.t(), Keyword.t()) ::
  {:ok, t()} | {:error, Braintree.ErrorResponse.t()}

Use a transaction_id to issue a void for that transaction

example

Example

{:ok, transaction} = Transaction.void("123")

transaction.status # "voided"