Braintree v0.7.0 Braintree.Transaction

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

Summary

Functions

Convert a map into a Transaction struct. Add_ons are converted to a list of structs as well

Find an existing transaction by transaction_id

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

Types

t :: %Braintree.Transaction{amount: number, plan_id: Sting.t, apple_pay_details: String.t, tax_amount: number, add_ons: [], coinbase_details: String.t, processor_settlement_response_text: String.t, gateway_rejection_reason: String.t, recurring: String.t, processor_response_text: String.t, escrow_status: String.t, processor_authorization_code: String.t, subscription_id: String.t, refund_ids: String.t, currency_iso_code: String.t, custom_fields: Map.t, voice_referral_number: String.t, additional_processor_response: String.t, processor_settlement_response_code: String.t, cvv_response_code: String.t, avs_street_address_response_code: String.t, settlement_batch_id: String.t, disputes: [], billing_details: Map.t, refunded_transaction_id: String.t, paypal: Map.t, channel: String.t, type: String.t, subscription_details: Map.t, descriptor: Map.t, service_fee_amount: number, order_id: String.t, avs_postal_code_response_code: String.t, customer_details: Map.t, created_at: String.t, disbursement_details: Map.t, discounts: [], merchant_account_id: String.t, avs_error_response_code: String.t, payment_instrument_type: String.t, status_history: String.t, updated_at: String.t, tax_exempt: boolean, id: String.t, purchase_order_number: String.t, credit_card_details: Map.t, risk_data: String.t, status: String.t, processor_response_code: String.t, shipping_details: Map.t}

Functions

construct(params)

Specs

construct(Map.t | [Map.t]) :: t | [t]

Convert a map into a Transaction struct. Add_ons are converted to a list of structs as well.

Example

transaction = Braintree.Transaction.construct(%{"subscription_id" => "subxid",
                                                "status" => "submitted_for_settlement"})
find(transaction_id)

Specs

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

Find an existing transaction by transaction_id

Example

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

Specs

refund(String.t, Map.t) ::
  {:ok, t} |
  {:error, Braintree.ErrorResponse.t}

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

Example

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

transaction.status # "refunded"
sale(params)

Specs

sale(Map.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

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

transaction.status # "settling"
submit_for_settlement(transaction_id, params)

Specs

submit_for_settlement(String.t, Map.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

{:ok, transaction} = Transaction.submit_for_settlement("123", %{amount: "100"})
transaction.status # "settling"
void(transaction_id)

Specs

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

Use a transaction_id to issue a void for that transaction

Example

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

transaction.status # "voided"