module Od::Payments
Constants
- ADAPTERS
- VERSION
Attributes
access_token_square[RW]
api_key_stripe[RW]
client_square[RW]
environment_square[RW]
production[RW]
Public Class Methods
adapter()
click to toggle source
# File lib/od/payments.rb, line 45 def adapter return @adapter if @adapter self.adapter = :stripe @adapter end
adapter=(adapter)
click to toggle source
# File lib/od/payments.rb, line 52 def adapter=(adapter) raise Od::Payments::APIError, 'Invalid Adapter' if adapter.class != Symbol || !ADAPTERS.include?(adapter) @adapter = adapter end
configure(adapter, options = {})
click to toggle source
# File lib/od/payments.rb, line 16 def configure(adapter, options = {}) self.adapter = adapter @api_key_stripe = options[:api_key_stripe] @access_token_square = options[:access_token_square] @environment_square = options[:environment_square] @production = options[:production] initializate_stripe if validate_stripe initializate_square if validate_square end
initializate_square()
click to toggle source
# File lib/od/payments.rb, line 38 def initializate_square @client_square = Square::Client.new( access_token: access_token_square, environment: production ? 'production' : 'sandbox' ) end
initializate_stripe()
click to toggle source
# File lib/od/payments.rb, line 34 def initializate_stripe Stripe.api_key = api_key_stripe end
validate_square()
click to toggle source
# File lib/od/payments.rb, line 30 def validate_square !access_token_square.nil? || !access_token_square&.strip&.empty? end
validate_stripe()
click to toggle source
# File lib/od/payments.rb, line 26 def validate_stripe !api_key_stripe.nil? && !api_key_stripe&.strip&.empty? end