Module: SpreedlyCore
- Defined in:
- lib/spreedly-core-ruby.rb,
lib/spreedly-core-ruby/base.rb,
lib/spreedly-core-ruby/gateway.rb,
lib/spreedly-core-ruby/version.rb,
lib/spreedly-core-ruby/test_gateway.rb,
lib/spreedly-core-ruby/transactions.rb,
lib/spreedly-core-ruby/payment_method.rb,
lib/spreedly-core-ruby/test_extensions.rb
Defined Under Namespace
Modules: HasIpAddress, NullifiableTransaction, TestHelper Classes: AddPaymentMethodTransaction, AuthorizeTransaction, Base, CaptureTransaction, CreditTransaction, Error, Gateway, InvalidResponse, PaymentMethod, PurchaseTransaction, RedactTransaction, Response, RetainTransaction, TestGateway, TimeOutError, Transaction, UnprocessableRequest, VoidedTransaction
Constant Summary collapse
- CARD_TYPES =
Hash of user friendly credit card name to Spreedly API name
{ "Visa" => "visa", "MasterCard" => "master", "American Express" => "american_express", "Discover" => "discover" }
- Version =
VERSION = "0.3.0"
- ApiVersion =
API_VERSION = "v1"
Class Method Summary collapse
-
.configure(options = {}) ⇒ Object
Configure Spreedly with a particular account.
-
.environment_key ⇒ Object
returns the configured Spreedly environment key.
- .gateway_token ⇒ Object
- .gateway_token=(gateway_token) ⇒ Object
Class Method Details
.configure(options = {}) ⇒ Object
Configure Spreedly with a particular account. Strongly prefers environment variables for credentials and will issue a stern warning should they not be present. Reluctantly accepts :environment_key and :access_secret as options
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/spreedly-core-ruby.rb', line 49 def self.configure( = {}) environment_key = (ENV["SPREEDLYCORE_ENVIRONMENT_KEY"] || ENV['SPREEDLYCORE_API_LOGIN']) secret = (ENV["SPREEDLYCORE_ACCESS_SECRET"] || ENV['SPREEDLYCORE_API_SECRET']) gateway_token = ENV['SPREEDLYCORE_GATEWAY_TOKEN'] if([:environment_key] || [:api_login]) Kernel.warn("ENV and arg both present for environment_key. Defaulting to arg value") if environment_key environment_key = ([:environment_key] || [:api_login]) end if([:access_secret] || [:api_secret]) Kernel.warn("ENV and arg both present for access_secret. Defaulting to arg value") if secret secret = ([:access_secret] || [:api_secret]) end if [:gateway_token] Kernel.warn("ENV and arg both present for gateway_token. Defaulting to arg value") if gateway_token gateway_token = [:gateway_token] end [:gateway_token] ||= gateway_token if([:environment_key] || [:access_secret]) Kernel.warn("It is STRONGLY preferred that you house your Spreedly credentials only in environment variables.") Kernel.warn("This gem prefers only environment variables named SPREEDLYCORE_ENVIRONMENT_KEY, SPREEDLYCORE_ACCESS_SECRET, and optionally SPREEDLYCORE_GATEWAY_TOKEN.") end if environment_key.nil? || secret.nil? raise ArgumentError.new("You must provide a environment_key and a secret. Gem will look for ENV['SPREEDLYCORE_ENVIRONMENT_KEY'] and ENV['SPREEDLYCORE_ACCESS_SECRET'], but you may also pass in a hash with :environment_key and :access_secret keys.") end [:endpoint] ||= "https://core.spreedly.com/#{SpreedlyCore::API_VERSION}" Base.configure(environment_key, secret, ) end |
.environment_key ⇒ Object
returns the configured Spreedly environment key
93 |
# File 'lib/spreedly-core-ruby.rb', line 93 def self.environment_key; Base.environment_key; end |
.gateway_token ⇒ Object
88 89 90 |
# File 'lib/spreedly-core-ruby.rb', line 88 def self.gateway_token Base.gateway_token end |
.gateway_token=(gateway_token) ⇒ Object
84 85 86 |
# File 'lib/spreedly-core-ruby.rb', line 84 def self.gateway_token=(gateway_token) Base.gateway_token = gateway_token end |