- Notifications
You must be signed in to change notification settings - Fork 53
Home
Pankaj Kumar Rawat edited this page Dec 27, 2017 · 2 revisions
Make the following changes to the mix.exs file.
Add gringotts to the list of dependencies.
def deps do [ {:gringotts, "~> 1.0"} ] endAdd gringotts to the list of applications to be started.
def application do [ extra_applications: [:gringotts] ] endThis simple example demonstrates how a purchase can be made using a person's credit card details.
Add configs in config/config.exs file.
config :gringotts, Gringotts.Gateways.Stripe, adapter: Gringotts.Gateways.Stripe, api_key: "YOUR_KEY", default_currency: "USD"Copy and paste this code in your module
alias Gringotts.Gateways.Stripe alias Gringotts.{CreditCard, Address, Worker, Gateways} card = %CreditCard{ first_name: "John", last_name: "Smith", number: "4242424242424242", year: "2017", month: "12", cvc: "123" } address = %Address{ street1: "123 Main", city: "New York", region: "NY", country: "US", postal_code: "11111" } case Gringotts.purchase(:my_gateway, Stripe, 199.95, card, billing_address: address, description: "Amazing T-Shirt") do {:ok, %{authorization: authorization}} -> IO.puts("Payment authorized #{authorization}") {:error, %{code: :declined, reason: reason}} -> IO.puts("Payment declined #{reason}") {:error, %{code: error}} -> IO.puts("Payment error #{error}") endChat/Discuss with the core team directly on gitter!