Class: Paystack
- Inherits:
-
Object
- Object
- Paystack
- Defined in:
- lib/paystack.rb,
lib/paystack/version.rb
Constant Summary collapse
- VERSION =
"0.1.7"
Instance Attribute Summary collapse
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
Instance Method Summary collapse
-
#initialize(paystack_public_key = nil, paystack_private_key = nil) ⇒ Paystack
constructor
A new instance of Paystack.
- #setPrivateKey(public_key) ⇒ Object
-
#setPublicKey(public_key) ⇒ Object
TODO delete if not used.
Constructor Details
#initialize(paystack_public_key = nil, paystack_private_key = nil) ⇒ Paystack
Returns a new instance of Paystack.
20 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 |
# File 'lib/paystack.rb', line 20 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_key ⇒ Object (readonly)
Returns the value of attribute private_key.
18 19 20 |
# File 'lib/paystack.rb', line 18 def private_key @private_key end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
18 19 20 |
# File 'lib/paystack.rb', line 18 def public_key @public_key end |
Instance Method Details
#setPrivateKey(public_key) ⇒ Object
53 54 55 |
# File 'lib/paystack.rb', line 53 def setPrivateKey public_key @public_key = public_key end |
#setPublicKey(public_key) ⇒ Object
TODO delete if not used
49 50 51 |
# File 'lib/paystack.rb', line 49 def setPublicKey public_key @public_key = public_key end |