Current section
20 Versions
Jump to
Current section
20 Versions
Compare versions
19
files changed
+388
additions
-42
deletions
| @@ -1,3 +1,25 @@ | |
| 1 | + ## v0.7.0 2016-09-20 |
| 2 | + |
| 3 | + ### Enhancements |
| 4 | + |
| 5 | + * [Braintree.ClientToken] Set the default client token version to `2`. |
| 6 | + * [Braintree.Discount] Add support for discounts |
| 7 | + * [Braintree.AddOn] Add support for add-ons |
| 8 | + * [Braintree.SettlementBatchSummary] Add support for settlement reports |
| 9 | + * [Braintree.Subscription] Support updating with `update/2` |
| 10 | + * [Braintree.Subscription] Convert add-on and transaction lists to structs |
| 11 | + |
| 12 | + ### Changes |
| 13 | + |
| 14 | + * [Braintree.XML] Strictly accept maps for generation, not keyword lists. |
| 15 | + |
| 16 | + ### Bug Fixes |
| 17 | + |
| 18 | + * [Braintree.XML] Correctly handle decoding entities such as `&`, `>` |
| 19 | + and `<`. |
| 20 | + * [Braintree.XML] Fix encoding XML array values |
| 21 | + * [Braintree.XML] Add encoding of binaries |
| 22 | + |
| 1 23 | ## v0.6.0 2016-08-10 |
| 2 24 | |
| 3 25 | ### Enhancements |
| @@ -14,7 +14,7 @@ Add braintree to your list of dependencies in `mix.exs`: | |
| 14 14 | |
| 15 15 | ```elixir |
| 16 16 | def deps do |
| 17 | - [{:braintree, "~> 0.0.1"}] |
| 17 | + [{:braintree, "~> 0.7"}] |
| 18 18 | end |
| 19 19 | ``` |
| 20 20 | |
| @@ -80,6 +80,11 @@ end | |
| 80 80 | You'll need a Braintree sandbox account to run the integration tests. Also, be |
| 81 81 | sure that your account has [Duplicate Transaction Checking][dtc] disabled. |
| 82 82 | |
| 83 | + Your environment needs to have the following: |
| 84 | + - Add-ons with ids: "bronze", "silver" and "gold" |
| 85 | + - Plans with ids: "starter", "business" |
| 86 | + - "business" plan needs to include the following Add-ons: "bronze" and "silver" |
| 87 | + |
| 83 88 | [dtc]: https://articles.braintreepayments.com/control-panel/transactions/duplicate-checking |
| 84 89 | |
| 85 90 | ## License |
| @@ -3,11 +3,12 @@ | |
| 3 3 | {<<"description">>,<<"Native Braintree client library for Elixir">>}. |
| 4 4 | {<<"elixir">>,<<"~> 1.3">>}. |
| 5 5 | {<<"files">>, |
| 6 | - [<<"lib/braintree.ex">>,<<"lib/client_token.ex">>,<<"lib/construction.ex">>, |
| 7 | - <<"lib/credit_card.ex">>,<<"lib/customer.ex">>,<<"lib/error_response.ex">>, |
| 8 | - <<"lib/http.ex">>,<<"lib/payment_method.ex">>, |
| 9 | - <<"lib/payment_method_nonce.ex">>,<<"lib/paypal_account.ex">>, |
| 10 | - <<"lib/plan.ex">>,<<"lib/subscription.ex">>, |
| 6 | + [<<"lib/add_on.ex">>,<<"lib/braintree.ex">>,<<"lib/client_token.ex">>, |
| 7 | + <<"lib/construction.ex">>,<<"lib/credit_card.ex">>,<<"lib/customer.ex">>, |
| 8 | + <<"lib/discount.ex">>,<<"lib/error_response.ex">>,<<"lib/http.ex">>, |
| 9 | + <<"lib/payment_method.ex">>,<<"lib/payment_method_nonce.ex">>, |
| 10 | + <<"lib/paypal_account.ex">>,<<"lib/plan.ex">>, |
| 11 | + <<"lib/settlement_batch_summary.ex">>,<<"lib/subscription.ex">>, |
| 11 12 | <<"lib/testing/credit_card_numbers.ex">>,<<"lib/testing/nonces.ex">>, |
| 12 13 | <<"lib/testing/test_transaction.ex">>,<<"lib/transaction.ex">>, |
| 13 14 | <<"lib/util.ex">>,<<"lib/xml/decoder.ex">>,<<"lib/xml/encoder.ex">>, |
| @@ -23,4 +24,4 @@ | |
| 23 24 | {<<"name">>,<<"hackney">>}, |
| 24 25 | {<<"optional">>,false}, |
| 25 26 | {<<"requirement">>,<<"~> 1.6">>}]]}. |
| 26 | - {<<"version">>,<<"0.6.0">>}. |
| 27 | + {<<"version">>,<<"0.7.0">>}. |
| @@ -0,0 +1,56 @@ | |
| 1 | + defmodule Braintree.AddOn do |
| 2 | + @moduledoc """ |
| 3 | + Add-ons and discounts are created in the Control Panel. You cannot create or |
| 4 | + update them through the API. |
| 5 | + |
| 6 | + Add-ons and discounts can be applied manually on a case-by-case basis, or you |
| 7 | + can associate them with certain plans to apply them automatically to new |
| 8 | + subscriptions. When creating a subscription, it will automatically inherit |
| 9 | + any add-ons and/or discounts associated with the plan. You can override those |
| 10 | + details at the time you create or update the subscription. |
| 11 | + """ |
| 12 | + |
| 13 | + use Braintree.Construction |
| 14 | + |
| 15 | + alias Braintree.HTTP |
| 16 | + alias Braintree.ErrorResponse, as: Error |
| 17 | + |
| 18 | + @type t :: %__MODULE__{ |
| 19 | + id: String.t, |
| 20 | + amount: String.t, |
| 21 | + current_billing_cycle: integer, |
| 22 | + description: String.t, |
| 23 | + kind: String.t, |
| 24 | + name: String.t, |
| 25 | + never_expires?: boolean, |
| 26 | + number_of_billing_cycles: integer, |
| 27 | + quantity: integer |
| 28 | + } |
| 29 | + |
| 30 | + defstruct id: nil, |
| 31 | + amount: 0, |
| 32 | + current_billing_cycle: nil, |
| 33 | + description: nil, |
| 34 | + kind: nil, |
| 35 | + name: nil, |
| 36 | + never_expires?: false, |
| 37 | + number_of_billing_cycles: 0, |
| 38 | + quantity: 0 |
| 39 | + |
| 40 | + @doc """ |
| 41 | + Returns a list of Braintree::AddOn structs. |
| 42 | + |
| 43 | + ## Example |
| 44 | + |
| 45 | + {:ok, addons} = Braintree.AddOns.all() |
| 46 | + """ |
| 47 | + @spec all() :: {:ok, [t]} | {:error, Error.t} |
| 48 | + def all do |
| 49 | + case HTTP.get("add_ons") do |
| 50 | + {:ok, %{"add_ons" => add_ons}} -> |
| 51 | + {:ok, construct(add_ons)} |
| 52 | + {:error, %{"api_error_response" => error}} -> |
| 53 | + {:error, Error.construct(error)} |
| 54 | + end |
| 55 | + end |
| 56 | + end |
| @@ -59,6 +59,21 @@ defmodule Braintree do | |
| 59 59 | end |
| 60 60 | end |
| 61 61 | |
| 62 | + @doc """ |
| 63 | + Convenience function for setting `braintree` application environment |
| 64 | + variables. |
| 65 | + |
| 66 | + ## Example |
| 67 | + |
| 68 | + iex> Braintree.put_env(:thingy, "thing") |
| 69 | + ...> Braintree.get_env(:thingy) |
| 70 | + "thing" |
| 71 | + """ |
| 72 | + @spec put_env(atom, any) :: :ok |
| 73 | + def put_env(key, value) do |
| 74 | + Application.put_env(:braintree, key, value) |
| 75 | + end |
| 76 | + |
| 62 77 | defp fallback_or_raise(key, nil, nil), do: raise ConfigError, key |
| 63 78 | defp fallback_or_raise(_, nil, default), do: default |
| 64 79 | defp fallback_or_raise(_, value, _), do: value |
Loading more files…