Module: Pin

Defined in:
lib/pin-payments.rb,
lib/pin-payments/base.rb,
lib/pin-payments/card.rb,
lib/pin-payments/charge.rb,
lib/pin-payments/refund.rb,
lib/pin-payments/customer.rb,
lib/pin-payments/response.rb

Defined Under Namespace

Classes: APIError, Base, Card, Charge, CollectionResponse, Customer, Error, Refund

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.authObject (readonly)

Returns the value of attribute auth.



29
30
31
# File 'lib/pin-payments.rb', line 29

def auth
  @auth
end

.base_urlObject (readonly)

Returns the value of attribute base_url.



29
30
31
# File 'lib/pin-payments.rb', line 29

def base_url
  @base_url
end

.js_urlObject (readonly)

Returns the value of attribute js_url.



29
30
31
# File 'lib/pin-payments.rb', line 29

def js_url
  @js_url
end

.publishable_keyObject (readonly)

Returns the value of attribute publishable_key.



29
30
31
# File 'lib/pin-payments.rb', line 29

def publishable_key
  @publishable_key
end

Class Method Details

.setup(options) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pin-payments.rb', line 31

def setup(options)
  raise ArgumentError, "Pin.setup wants an options hash" unless Hash === options
  raise ArgumentError, "no secret key configured" unless options[:secret_key]
  raise ArgumentError, "no mode configured" unless options[:mode]

  @auth = {username: options[:secret_key], password: ''}
  @publishable_key = options[:publishable_key]

  mode = options[:mode].to_sym
  uri = if mode == :live
    "https://api.pin.net.au"
  elsif mode == :test
    "https://test-api.pin.net.au"
  else
    raise ArgumentError, "Incorrect API mode! Must be :live or :test"
  end

  @js_url = "#{uri}/pin.js"
  @base_url = "#{uri}/1"
  Pin::Base.base_uri "#{uri}/1"
end