defmodule Beanstream.Gateway do @moduledoc """ Configuration for Beanstream Gateway. """ defstruct [ merchant_id: nil, payments_passcode: nil, # API access passcode profiles_passcode: nil, reporting_passcode: nil, # reporting and transaction download # recurring billing passcode # batch file upload passcode ] @type t :: %Beanstream.Gateway{ merchant_id: String.t, payments_passcode: String.t, profiles_passcode: String.t, reporting_passcode: String.t, } @spec auth_header(Beanstream.Gateway.t, String.t) :: Keyword.t def auth_header(gw, "payments") do make_auth_header(gw.merchant_id, gw.payments_passcode) end @spec auth_header(Beanstream.Gateway.t, String.t) :: Keyword.t def auth_header(gw, "profiles") do make_auth_header(gw.merchant_id, gw.profiles_passcode) end defp make_auth_header(merchant_id, passcode) do auth = Base.encode64("#{merchant_id}:#{passcode}") [{"Authorization", "Passcode #{auth}"}] end end