How to use the braintree package is there any example?

Hi everyone,

Is there any tutorial or example, of how to use the Braintree library?

alias Braintree.Customer
alias Braintree.ErrorResponse, as: Error

case Customer.create(%{company: "Whale Corp"}) do
  {:ok, %Customer{} = customer} -> do_stuff_with_customer(customer)
  {:error, %Error{} = error}    -> do_stuff_with_error(error)
end

What can I do here?

do_stuff_with_customer(customer)

I need the customer the amount and the country

PS: I can’t use stripe because it is unavailable in my country.

UPDATE: For anybody else that wants to use this, some examples can be found in the repo inside files so for payments you can find them in transactions.ex, here is the link https://github.com/sorentwo/braintree-elixir/blob/master/lib/transaction.ex

Thanks in advance for any tips or help on this.

Anything missing in the documentation?

https://hexdocs.pm/braintree/readme.html

1 Like

From my point of view yes.

What are the methods to get the customer the price and the country.

Also How can I refund a customer?

I don’t see any example with these methods.

Someone new may get confused without seeing how it works.

I am definitely in that boat now.

Thanks for helping me clarify my problem @NobbZ

I’m the author and maintainer of the Braintree library, though I haven’t been a user of it for many years now. It didn’t get much doc love because it aimed to mirror the official Ruby client.

For use cases beyond initial setup I suggest referencing the Ruby docs. In fact, the individual module docs point to the official Ruby docs in many places.

1 Like

Thanks @sorentwo, for the explanations and also for mentioning what the purpose of the package is.