Class: ArrowPayments::Client
- Inherits:
-
Object
- Object
- ArrowPayments::Client
- 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
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
Instance Method Summary collapse
-
#debug? ⇒ Boolean
Check if debug mode is enabled.
-
#initialize(options = {}) ⇒ Client
constructor
Initialize a new client instance Available options:.
-
#production? ⇒ Boolean
Check if client is in production mode.
-
#sandbox? ⇒ Boolean
Check if client is in sandbox mode.
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
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
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(={}) @api_key = [:api_key] || ArrowPayments::Configuration.api_key @mode = ([:mode] || ArrowPayments::Configuration.mode || 'production').to_s @merchant_id = [:merchant_id] || ArrowPayments::Configuration.merchant_id @debug = ([: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_key ⇒ Object (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 |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
8 9 10 |
# File 'lib/arrow_payments/client.rb', line 8 def debug @debug end |
#merchant_id ⇒ Object (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 |
#mode ⇒ Object (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
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
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
41 42 43 |
# File 'lib/arrow_payments/client.rb', line 41 def sandbox? mode == 'sandbox' end |