diff --git a/README.md b/README.md index c7589e7..cff004e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Available in Hex, the package can be installed by adding `at_ex` to your list of ```elixir def deps do [ - {:at_ex, "~> 0.20.21"} + {:at_ex, "~> 0.20.22"} ] end ``` @@ -48,22 +48,23 @@ end - Go to [Africas Talking](https://account.africastalking.com/auth/register) to register for an account. - On signing up go to the `https://account.africastalking.com/apps/sandbox` to get an **api key** - Add the **api key** in the `api_key:`value in the `config/dev.exs` created above. +- For sandbox, set the `sandbox` key to `true` ## Example Configuration setup Below is an example configuration for `dev.exs` this is suitable for testing with the sandbox: ``` elixir config :at_ex, - api_key: "===INSERT AFRICAS_TALKING_SANDBOX_API_KEY HERE ===", - username: "sandbox", #change to live username if you want to use the live endpoint while in development - stk_product_name: "AtEx", #Add your specific product name. + api_key: "===INSERT AFRICAS_TALKING_API_KEY HERE ===", + # When changed to "false" one will use the live endpoint url + sandbox: true, + username: "sandbox", + stk_product_name: "AtEx", b2c_product_name: "AtEx", b2b_product_name: "AtEx", bank_checkout_product_name: "AtEx", bank_transfer_product_name: "AtEx", - card_checkout_product_name: "AtEx", - # When changed to "YES" one will use the live endpoint url when in development - force_live_url: "NO" + card_checkout_product_name: "AtEx" ``` Below is an example configuration for `prod.exs` this is when you go live: @@ -73,6 +74,8 @@ Below is an example configuration for `prod.exs` this is when you go live: config :at_ex, api_key: "===INSERT AFRICAS_TALKING_LIVE_API_KEY HERE ===", username: "LIVE_USERNAME", + # When changed to "false" one will use the live endpoint url + sandbox: false, stk_product_name: "AtEx", #Add your specific product name. b2c_product_name: "AtEx", b2b_product_name: "AtEx", diff --git a/config/dev.sample.exs b/config/dev.sample.exs index e8455ed..62a2cf8 100644 --- a/config/dev.sample.exs +++ b/config/dev.sample.exs @@ -4,12 +4,12 @@ use Mix.Config config :at_ex, api_key: "===INSERT AFRICAS_TALKING_API_KEY HERE ===", + # When changed to "false" one will use the live endpoint url + sandbox: true, username: "sandbox", stk_product_name: "AtEx", b2c_product_name: "AtEx", b2b_product_name: "AtEx", bank_checkout_product_name: "AtEx", bank_transfer_product_name: "AtEx", - card_checkout_product_name: "AtEx", - # When changed to "YES" one will use the live endpoint url - force_live_url: "NO" + card_checkout_product_name: "AtEx" diff --git a/lib/at_ex/util.ex b/lib/at_ex/util.ex index 1b55ea3..bb5f06a 100644 --- a/lib/at_ex/util.ex +++ b/lib/at_ex/util.ex @@ -5,8 +5,8 @@ defmodule AtEx.Util do @spec get_url(String.t(), String.t()) :: String.t() def get_url(live_url, sandbox_url) do cond do - Mix.env() == :prod -> live_url - Application.get_env(:at_ex, :force_live_url) == "YES" -> live_url + Application.get_env(:at_ex, :sandbox) === false -> live_url + Application.get_env(:at_ex, :sandbox) === true -> sandbox_url true -> sandbox_url end end diff --git a/mix.exs b/mix.exs index 81e505f..1f09f70 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule AtEx.MixProject do def project do [ app: :at_ex, - version: "0.20.21", + version: "0.20.22", elixir: "~> 1.8", start_permanent: Mix.env() == :prod, deps: deps(),