diff --git a/README.md b/README.md index 9198f22..cc67803 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Gringotts Examples -Repository contains example usage for all the payment gateway integartions in [kuber hex](https://github.com/aviabird/gringotts) +Repository contains example usage for all the payment gateway integartions in [Gringotts](https://github.com/aviabird/gringotts) Gringotts is a payment processing library for Elixir. Based on [Shopify's](http://shopify.com) [ActiveMerchant](http://github.com/Shopify/active_merchant) ruby gem. @@ -9,6 +9,6 @@ Gringotts is a payment processing library for Elixir. Based on [Shopify's](http: * `mix deps.get` * `mix test` -## TODO's +## TODO's * Add test cases diff --git a/config/config.exs b/config/config.exs index d7b7e3f..91e375d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -33,6 +33,16 @@ config :gringotts, Gringotts.Gateways.Bogus, api_key: "sk_test_mnrVg6z2G0HeDzwy5gxJfmfP", default_currency: "USD" +config :gringotts, Gringotts.Gateways.Paymill, + adapter: Gringotts.Gateways.Paymill, + private_key: "8f16b021d4fb1f8d9263cbe346f32688", + public_key: "72294854039fcf7fd55eaeeb594577e7" + +config :gringotts, Gringotts.Gateways.AuthorizeNet, + adapter: Gringotts.Gateways.AuthorizeNet, + name: "64jKa6NA", + transactionKey: "4vmE338dQmAN6m7B", + default_currency: "USD" config :gringotts, Gringotts.Gateways.WireCard, adapter: Gringotts.Gateways.WireCard, @@ -40,6 +50,11 @@ config :gringotts, Gringotts.Gateways.WireCard, password: "TestXAPTER", signature: "00000031629CAFD5" +config :gringotts, Gringotts.Gateways.Trexle, + adapter: Gringotts.Gateways.Trexle, + api_key: "J5RGMpDlFlTfv9mEFvNWYoqHufyukPP4", + default_currency: "USD" + # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. diff --git a/lib/gringotts_examples/trexle.ex b/lib/gringotts_examples/trexle.ex new file mode 100644 index 0000000..2f0cd3f --- /dev/null +++ b/lib/gringotts_examples/trexle.ex @@ -0,0 +1,54 @@ +defmodule Gringotts.Examples.Trexle do + + alias Gringotts, as: Billing + alias Billing.{CreditCard, Address} + alias Gringotts.Gateways.Trexle + + @payment %CreditCard{ + number: "5200828282828210", + month: 12, + year: 2018, + first_name: "John", + last_name: "Doe", + verification_code: "123", + brand: "visa" + } + + @address %Address{ + street1: "123 Main", + street2: "Suite 100", + city: "New York", + region: "NY", + country: "US", + postal_code: "11111", + phone: "(555)555-5555" + } + + @amount %{amount: Decimal.new(50), currency: "USD"} + + @options [ email: "john@trexle.com", + ip_address: "66.249.79.118", + billing_address: @address, + description: "Store Purchase 1437598192"] + + def authorize() do + Billing.authorize(Trexle, @amount, @payment, @options) + end + + def purchase() do + Billing.purchase(Trexle, @amount, @payment, @options) + end + + def capture(charge_token) do + Billing.capture(Trexle, charge_token, @amount) + end + + def refund(charge_token) do + Billing.refund(Trexle, @amount, charge_token, @options) + end + + def store() do + Billing.store(Trexle, @payment, @options) + end + +end diff --git a/mix.exs b/mix.exs index 54bc60e..1526256 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule Gringotts.Examples.Mixfile do [ app: :gringotts_examples, version: "0.1.0", - elixir: "~> 1.5.2", + elixir: "~> 1.5.1", start_permanent: Mix.env == :prod, deps: deps() ] @@ -22,7 +22,8 @@ defmodule Gringotts.Examples.Mixfile do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:gringotts, path: "../gringotts"} + {:gringotts, path: "../gringotts"}, + {:ex_money, "~> 1.1.0"} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}, ] diff --git a/mix.lock b/mix.lock index 27f3017..34ecbbf 100644 --- a/mix.lock +++ b/mix.lock @@ -1,12 +1,12 @@ -%{"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [], [], "hexpm"}, - "elixir_xml_to_map": {:hex, :elixir_xml_to_map, "0.1.1", "57e924cd11731947bfd245ce57d0b8dd8b7168bf8edb20cd156a2982ca96fdfa", [], [{:erlsom, "~>1.4", [hex: :erlsom, repo: "hexpm", optional: false]}], "hexpm"}, - "erlsom": {:hex, :erlsom, "1.4.1", "53dbacf35adfea6f0714fd0e4a7b0720d495e88c5e24e12c5dc88c7b62bd3e49", [], [], "hexpm"}, - "hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, - "httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, - "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, - "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], [], "hexpm"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"}, - "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [], [], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [], [], "hexpm"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [], [], "hexpm"}, - "xml_builder": {:hex, :xml_builder, "0.1.2", "b48ab9ed0a24f43a6061e0c21deda88b966a2121af5c445d4fc550dd822e23dc", [], [], "hexpm"}} +%{"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"}, + "elixir_xml_to_map": {:hex, :elixir_xml_to_map, "0.1.1", "57e924cd11731947bfd245ce57d0b8dd8b7168bf8edb20cd156a2982ca96fdfa", [:mix], [{:erlsom, "~>1.4", [hex: :erlsom, repo: "hexpm", optional: false]}], "hexpm"}, + "erlsom": {:hex, :erlsom, "1.4.1", "53dbacf35adfea6f0714fd0e4a7b0720d495e88c5e24e12c5dc88c7b62bd3e49", [:rebar3], [], "hexpm"}, + "hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, + "httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"}, + "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, + "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}, + "xml_builder": {:hex, :xml_builder, "0.1.2", "b48ab9ed0a24f43a6061e0c21deda88b966a2121af5c445d4fc550dd822e23dc", [:mix], [], "hexpm"}}