Class: Paystack

Inherits:
Object
  • Object
show all
Defined in:
lib/paystack.rb,
lib/paystack/version.rb

Constant Summary collapse

VERSION =
"0.1.10"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paystack_public_key = nil, paystack_private_key = nil) ⇒ Paystack

Returns a new instance of Paystack.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/paystack.rb', line 21

def initialize paystack_public_key=nil, paystack_private_key=nil
  if (paystack_public_key.nil?)
    @public_key = ENV['PAYSTACK_PUBLIC_KEY']
  else
    @public_key = paystack_public_key
  end

  if (paystack_private_key.nil?)
    @private_key = ENV['PAYSTACK_PRIVATE_KEY']
  else
    @private_key = paystack_private_key
  end

  unless !@public_key.nil?
    raise PaystackBadKeyError, "No public key supplied and couldn't find any in environment variables. Make sure to set public key as an environment variable PAYSTACK_PUBLIC_KEY"
  end
  unless @public_key[0..2] == 'pk_'
    raise PaystackBadKeyError, "Invalid public key #{@public_key}"
  end

  unless !@private_key.nil?
    raise PaystackBadKeyError, "No private key supplied and couldn't find any in environment variables. Make sure to set private key as an environment variable PAYSTACK_PRIVATE_KEY"
  end
  unless @private_key[0..2] == 'sk_'
    raise PaystackBadKeyError, "Invalid private key #{@private_key}"
  end
end

Instance Attribute Details

#private_keyObject (readonly)

Returns the value of attribute private_key.



19
20
21
# File 'lib/paystack.rb', line 19

def private_key
  @private_key
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



19
20
21
# File 'lib/paystack.rb', line 19

def public_key
  @public_key
end

Instance Method Details

#setPrivateKey(public_key) ⇒ Object



54
55
56
# File 'lib/paystack.rb', line 54

def setPrivateKey public_key
  @public_key = public_key
end

#setPublicKey(public_key) ⇒ Object

TODO delete if not used



50
51
52
# File 'lib/paystack.rb', line 50

def setPublicKey public_key
  @public_key = public_key
end