Skip to content

Commit

Permalink
Change for the name of the library
Browse files Browse the repository at this point in the history
Kuber.Hex -> Gringotts
  • Loading branch information
ashish173 committed Dec 19, 2017
1 parent 8020b98 commit f03d034
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 114 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4

working_directory: ~/kuber_hex
working_directory: ~/gringotts
steps:
- checkout

# specify any bash command here prefixed with `run: `
- run: mix local.hex --force
- run: mix local.rebar --force
- run: mix deps.get
- run: mix coveralls.circle
- run: mix test
# Let CircleCI run integration tests separately.
- run: mix test --only integration
test:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Kuber.Hex
Gringotts
=================

[![CircleCI](https://circleci.com/bb/aviabird/kuber_hex/tree/master.svg?style=svg)](https://circleci.com/bb/aviabird/kuber_hex/tree/master)
[![CircleCI](https://circleci.com/bb/aviabird/gringotts/tree/master.svg?style=svg)](https://circleci.com/bb/aviabird/gringotts/tree/master)

Payment processing library for Elixir. Based on [Shopify's](http://shopify.com) [ActiveMerchant](http://github.com/Shopify/active_merchant) ruby gem

Expand All @@ -27,7 +27,7 @@ An open source initiative of [Aviabird Technologies](https://aviabird.com)
## Card processing example

```elixir
alias Kuber.Hex
alias Gringotts
alias Billing.{CreditCard, Address, Worker, Gateways}

config = %{credentials: {"sk_test_BQokikJOvBiI2HlWgH4olfQ2", ""},
Expand Down
34 changes: 17 additions & 17 deletions lib/kuber_hex.ex
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
defmodule Kuber.Hex do
defmodule Gringotts do
@moduledoc ~S"""
Kuber.Hex is a payment gateway integration library supporting many gateway integrations.
Gringotts is a payment gateway integration library supporting many gateway integrations.
Where the configuration for `Kuber.Hex` must be in your application
Where the configuration for `Gringotts` must be in your application
environment, usually defined in your `config/config.exs`:
config :kuber_hex, Kuber.Hex.Gateways.Stripe,
adapter: Kuber.Hex.Gateways.Stripe,
config :Gringotts, Gringotts.Gateways.Stripe,
adapter: Gringotts.Gateways.Stripe,
api_key: "sk_test_vIX41hC0sdfBKrPWQerLuOMld",
default_currency: "USD"
Expand All @@ -28,10 +28,10 @@ defmodule Kuber.Hex do
> This option is going to be removed in our next version.
### Gateway Name
eg: Kuber.Hex.Gateways.Stripe
eg: Gringotts.Gateways.Stripe
This option specifies which payment gateway this request should be called for.
Since `Kuber.Hex` supports multiple payment gateway integrations at the same time
Since `Gringotts` supports multiple payment gateway integrations at the same time
so this information get's critical.
### Amount
Expand Down Expand Up @@ -86,7 +86,7 @@ defmodule Kuber.Hex do
@options [currency: "usd"]
Kuber.Hex.purchase(:payment_worker, Kuber.Hex.Gateways.Stripe, 5, @payment, @options)
Gringotts.purchase(:payment_worker, Gringotts.Gateways.Stripe, 5, @payment, @options)
This method is expected to authorize payment and transparently trigger eventual
settlement. Preferably it is implemented as a single call to the gateway,
Expand Down Expand Up @@ -118,7 +118,7 @@ defmodule Kuber.Hex do
@options [currency: "usd"]
Kuber.Hex.authorize(:payment_worker, Kuber.Hex.Gateways.Stripe, 5, @payment, @options)
Gringotts.authorize(:payment_worker, Gringotts.Gateways.Stripe, 5, @payment, @options)
"""
def authorize(worker, gateway, amount, card, opts \\ []) do
validate_config(gateway)
Expand Down Expand Up @@ -152,7 +152,7 @@ defmodule Kuber.Hex do
id = "ch_1BYvGkBImdnrXiZwet3aKkQE"
Kuber.Hex.capture(:payment_worker, Kuber.Hex.Gateways.Stripe, id, 5)
Gringotts.capture(:payment_worker, Gringotts.Gateways.Stripe, id, 5)
"""
def capture(worker, gateway, id, amount, opts \\ []) do
validate_config(gateway)
Expand Down Expand Up @@ -181,7 +181,7 @@ defmodule Kuber.Hex do
id = "ch_1BYvGkBImdnrXiZwet3aKkQE"
Kuber.Hex.void(:payment_worker, Kuber.Hex.Gateways.Stripe, id)
Gringotts.void(:payment_worker, Gringotts.Gateways.Stripe, id)
"""
def void(worker, gateway, id, opts \\ []) do
Expand All @@ -208,7 +208,7 @@ defmodule Kuber.Hex do
id = "ch_1BYvGkBImdnrXiZwet3aKkQE"
Kuber.Hex.refund(:payment_worker, Kuber.Hex.Gateways.Stripe, 5, id)
Gringotts.refund(:payment_worker, Gringotts.Gateways.Stripe, 5, id)
"""
def refund(worker, gateway, amount, id, opts \\ []) do
validate_config(gateway)
Expand All @@ -217,10 +217,10 @@ defmodule Kuber.Hex do

@doc """
Tokenizes a supported payment method in the gateway's vault. If the gateway
conflates tokenization with customer management, `Kuber.Hex` should hide all
conflates tokenization with customer management, `Gringotts` should hide all
customer management and any customer identifier(s) within the token returned.
It's certainly legitimate to have a library that interacts with all the features
in a gateway's vault, but `Kuber.Hex` is not the right place for it.
in a gateway's vault, but `Gringotts` is not the right place for it.
It's critical that `store` returns a token that can be used against `purchase`
and `authorize`. Currently the standard is to return the token in the
Expand All @@ -241,7 +241,7 @@ defmodule Kuber.Hex do
id = "ch_1BYvGkBImdnrXiZwet3aKkQE"
Kuber.Hex.store(:payment_worker, Kuber.Hex.Gateways.Stripe, @payment)
Gringotts.store(:payment_worker, Gringotts.Gateways.Stripe, @payment)
"""
def store(worker, gateway, card, opts \\ []) do
validate_config(gateway)
Expand All @@ -258,7 +258,7 @@ defmodule Kuber.Hex do
id = "ch_1BYvGkBImdnrXiZwet3aKkQE"
customer_id = "random_customer"
Kuber.Hex.unstore(:payment_worker, Kuber.Hex.Gateways.Stripe, customer_id, id)
Gringotts.unstore(:payment_worker, Gringotts.Gateways.Stripe, customer_id, id)
"""
def unstore(worker, gateway, customer_id, card_id, opts \\ []) do
Expand All @@ -270,7 +270,7 @@ defmodule Kuber.Hex do
# time error reporting.
defp validate_config(gateway) do
# Keep the key name and adapter the same in the config in application
config = Application.get_env(:kuber_hex, gateway)
config = Application.get_env(:Gringotts, gateway)
gateway.validate_config(config)
end
end
2 changes: 1 addition & 1 deletion lib/kuber_hex/adapter.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Kuber.Hex.Adapter do
defmodule Gringotts.Adapter do
@moduledoc ~S"""
Adapter module is currently holding the validation part.
Expand Down
2 changes: 1 addition & 1 deletion lib/kuber_hex/address.ex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
defmodule Kuber.Hex.Address do
defmodule Gringotts.Address do
defstruct [:street1, :street2, :city, :region, :country, :postal_code, :phone]
end
10 changes: 5 additions & 5 deletions lib/kuber_hex/application.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Kuber.Hex.Application do
defmodule Gringotts.Application do
@moduledoc ~S"""
Has the supervision tree which monitors all the workers
that are handling the payments.
Expand All @@ -7,15 +7,15 @@ defmodule Kuber.Hex.Application do

def start(_type, _args) do
import Supervisor.Spec, warn: false
app_config = Application.get_all_env(:kuber_hex)
app_config = Application.get_all_env(:Gringotts)
adapters = Enum.filter(app_config, fn({key, klist}) -> klist != [] end)
|> Enum.map(fn({key, klist}) -> Keyword.get(klist, :adapter) end)

children = [
# Define workers and child supervisors to be supervised
# worker(Kuber.Hex.Worker, [arg1, arg2, arg3])
# worker(Gringotts.Worker, [arg1, arg2, arg3])
worker(
Kuber.Hex.Worker,
Gringotts.Worker,
[
adapters, # gateways
app_config, # options(config from application)
Expand All @@ -27,7 +27,7 @@ defmodule Kuber.Hex.Application do

# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Kuber.Hex.Supervisor]
opts = [strategy: :one_for_one, name: Gringotts.Supervisor]
Supervisor.start_link(children, opts)
end
end
2 changes: 1 addition & 1 deletion lib/kuber_hex/credit_card.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Kuber.Hex.CreditCard do
defmodule Gringotts.CreditCard do
@moduledoc ~S"""
CreditCard module defines the struct for the credit cards.
Expand Down
8 changes: 4 additions & 4 deletions lib/kuber_hex/gateways/authorize_net.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
defmodule Kuber.Hex.Gateways.AuthorizeNet do
defmodule Gringotts.Gateways.AuthorizeNet do
import XmlBuilder
import XmlToMap

use Kuber.Hex.Gateways.Base
use Kuber.Hex.Adapter, required_config: [:name, :transactionKey, :default_currency]
use Gringotts.Gateways.Base
use Gringotts.Adapter, required_config: [:name, :transactionKey, :default_currency]

@test_url "https://apitest.authorize.net/xml/v1/request.api"
@production_url "https://api.authorize.net/xml/v1/request.api"
Expand All @@ -23,7 +23,7 @@ defmodule Kuber.Hex.Gateways.AuthorizeNet do
}
@aut_net_namespace "AnetApi/xml/v1/schema/AnetApiSchema.xsd"

alias Kuber.Hex.{
alias Gringotts.{
CreditCard,
Address,
Response
Expand Down
4 changes: 2 additions & 2 deletions lib/kuber_hex/gateways/base.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Kuber.Hex.Gateways.Base do
alias Kuber.Hex.Response
defmodule Gringotts.Gateways.Base do
alias Gringotts.Response

@doc false
defmacro __using__(_) do
Expand Down
6 changes: 3 additions & 3 deletions lib/kuber_hex/gateways/bogus.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Kuber.Hex.Gateways.Bogus do
use Kuber.Hex.Gateways.Base
defmodule Gringotts.Gateways.Bogus do
use Gringotts.Gateways.Base

alias Kuber.Hex.{
alias Gringotts.{
CreditCard,
Response
}
Expand Down
8 changes: 4 additions & 4 deletions lib/kuber_hex/gateways/cams.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Kuber.Hex.Gateways.Cams do
defmodule Gringotts.Gateways.Cams do
@live_url "https://secure.centralams.com/gw/api/transact.php"
@supported_countries ["US"]
@default_currency "USD"
Expand All @@ -8,9 +8,9 @@ defmodule Kuber.Hex.Gateways.Cams do
@headers [{"Content-Type", "application/x-www-form-urlencoded"}]


use Kuber.Hex.Gateways.Base
use Kuber.Hex.Adapter, required_config: [:username, :password, :default_currency]
alias Kuber.Hex.{
use Gringotts.Gateways.Base
use Gringotts.Adapter, required_config: [:username, :password, :default_currency]
alias Gringotts.{
CreditCard,
Address,
Response
Expand Down
14 changes: 6 additions & 8 deletions lib/kuber_hex/gateways/monei.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Kuber.Hex.Gateways.Monei do
defmodule Gringotts.Gateways.Monei do
@moduledoc ~S"""
An API client for the [MONEI](https://www.monei.net) gateway.
Expand All @@ -17,7 +17,7 @@ defmodule Kuber.Hex.Gateways.Monei do
## The `opts` argument
Most `Kuber.Hex` API calls accept an optional `Keyword` list `opts` to supply
Most `Gringotts` API calls accept an optional `Keyword` list `opts` to supply
optional arguments for transactions with the MONEI gateway. The following keys
are supported:
Expand Down Expand Up @@ -50,10 +50,10 @@ defmodule Kuber.Hex.Gateways.Monei do
* [Reporting](https://docs.monei.net/tutorials/reporting)
"""

use Kuber.Hex.Gateways.Base
use Kuber.Hex.Adapter, required_config: [:userId, :entityId, :password]
use Gringotts.Gateways.Base
use Gringotts.Adapter, required_config: [:userId, :entityId, :password]
import Poison, only: [decode: 1]
alias Kuber.Hex.{CreditCard, Response}
alias Gringotts.{CreditCard, Response}

@base_url "https://test.monei-api.net"
@default_headers ["Content-Type": "application/x-www-form-urlencoded",
Expand Down Expand Up @@ -277,7 +277,7 @@ defmodule Kuber.Hex.Gateways.Monei do
end

@doc """
Parses MONEI's response and returns a `Kuber.Hex.Response` struct in a `:ok`, `:error` tuple.
Parses MONEI's response and returns a `Gringotts.Response` struct in a `:ok`, `:error` tuple.
"""
@spec respond(term) ::
{:ok, Response} |
Expand Down Expand Up @@ -322,5 +322,3 @@ defmodule Kuber.Hex.Gateways.Monei do
defp currency(opts), do: opts[:currency] || @default_currency
defp version(opts), do: opts[:api_version] || @version
end


8 changes: 4 additions & 4 deletions lib/kuber_hex/gateways/paymill.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Kuber.Hex.Gateways.Paymill do
use Kuber.Hex.Gateways.Base
alias Kuber.Hex.{ CreditCard, Address, Response}
defmodule Gringotts.Gateways.Paymill do
use Gringotts.Gateways.Base
alias Gringotts.{ CreditCard, Address, Response}

use Kuber.Hex.Adapter, required_config: [:private_key, :public_key]
use Gringotts.Adapter, required_config: [:private_key, :public_key]

@home_page "https://paymill.com"
@money_format :cents
Expand Down
Loading

0 comments on commit f03d034

Please sign in to comment.