Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/env #89

Merged
merged 3 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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:
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions config/dev.sample.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions lib/at_ex/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down