Class: ArrowPayments::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Customers, PaymentMethods, Transactions
Defined in:
lib/arrow_payments/client.rb

Constant Summary

Constants included from Connection

ArrowPayments::Connection::API_PRODUCTION, ArrowPayments::Connection::API_SANDBOX, ArrowPayments::Connection::CONNECTION_OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Transactions

#capture_transaction, #create_transaction, #transaction, #transactions, #void_transaction

Methods included from PaymentMethods

#complete_payment_method, #create_payment_method, #delete_payment_method, #payment_method, #setup_payment_method, #start_payment_method

Methods included from Customers

#create_customer, #customer, #customers, #delete_customer, #update_customer

Methods included from Connection

#get, #post, #post_to_url

Constructor Details

#initialize(options = {}) ⇒ Client

Initialize a new client instance Available options:

:api_key - Your API key (required)
:mode - API mode (sandox / production)
:merchant_id - Your merchant ID 
:debug - True for request logging

Parameters:

  • client (Hash)

    connection options



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/arrow_payments/client.rb', line 20

def initialize(options={})
  @api_key     = options[:api_key] || ArrowPayments::Configuration.api_key
  @mode        = (options[:mode] || ArrowPayments::Configuration.mode || 'production').to_s
  @merchant_id = options[:merchant_id] || ArrowPayments::Configuration.merchant_id
  @debug       = (options[:debug] || ArrowPayments::Configuration.debug) === true

  if api_key.to_s.empty?
    raise ArgumentError, "API key required"
  end

  if merchant_id.to_s.empty?
    raise ArgumentError, "Merchant ID required"
  end

  unless %(sandbox production).include?(mode)
    raise ArgumentError, "Invalid mode: #{mode}"
  end
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/arrow_payments/client.rb', line 8

def api_key
  @api_key
end

#debugObject (readonly)

Returns the value of attribute debug.



8
9
10
# File 'lib/arrow_payments/client.rb', line 8

def debug
  @debug
end

#merchant_idObject (readonly)

Returns the value of attribute merchant_id.



8
9
10
# File 'lib/arrow_payments/client.rb', line 8

def merchant_id
  @merchant_id
end

#modeObject (readonly)

Returns the value of attribute mode.



8
9
10
# File 'lib/arrow_payments/client.rb', line 8

def mode
  @mode
end

Instance Method Details

#debug?Boolean

Check if debug mode is enabled

Returns:

  • (Boolean)


53
54
55
# File 'lib/arrow_payments/client.rb', line 53

def debug?
  debug == true
end

#production?Boolean

Check if client is in production mode

Returns:

  • (Boolean)


47
48
49
# File 'lib/arrow_payments/client.rb', line 47

def production?
  mode == 'production'
end

#sandbox?Boolean

Check if client is in sandbox mode

Returns:

  • (Boolean)


41
42
43
# File 'lib/arrow_payments/client.rb', line 41

def sandbox?
  mode == 'sandbox'
end