Class: Epaybg::Transaction
- Inherits:
-
Object
- Object
- Epaybg::Transaction
- Defined in:
- lib/epaybg/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#description ⇒ Object
Returns the value of attribute description.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#expires_on ⇒ Object
Returns the value of attribute expires_on.
-
#invoice ⇒ Object
Returns the value of attribute invoice.
-
#min ⇒ Object
Returns the value of attribute min.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#url ⇒ Object
Returns the value of attribute url.
-
#url_cancel ⇒ Object
Returns the value of attribute url_cancel.
-
#url_idn ⇒ Object
Returns the value of attribute url_idn.
-
#url_ok ⇒ Object
Returns the value of attribute url_ok.
Instance Method Summary collapse
- #checksum ⇒ Object
- #credit_card_link ⇒ Object
- #encoded ⇒ Object
- #epay_link ⇒ Object
-
#initialize(args = {}) {|_self| ... } ⇒ Transaction
constructor
A new instance of Transaction.
- #register_payment ⇒ Object
Constructor Details
#initialize(args = {}) {|_self| ... } ⇒ Transaction
Returns a new instance of Transaction.
8 9 10 11 12 13 14 15 |
# File 'lib/epaybg/transaction.rb', line 8 def initialize(args = {}) set_defaults! args.each do |k, v| instance_variable_set("@#{k}", v) unless v.nil? end yield self if block_given? validate! end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def amount @amount end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def description @description end |
#encoding ⇒ Object
Returns the value of attribute encoding.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def encoding @encoding end |
#expires_on ⇒ Object
Returns the value of attribute expires_on.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def expires_on @expires_on end |
#invoice ⇒ Object
Returns the value of attribute invoice.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def invoice @invoice end |
#min ⇒ Object
Returns the value of attribute min.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def min @min end |
#secret ⇒ Object
Returns the value of attribute secret.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def secret @secret end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def url @url end |
#url_cancel ⇒ Object
Returns the value of attribute url_cancel.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def url_cancel @url_cancel end |
#url_idn ⇒ Object
Returns the value of attribute url_idn.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def url_idn @url_idn end |
#url_ok ⇒ Object
Returns the value of attribute url_ok.
5 6 7 |
# File 'lib/epaybg/transaction.rb', line 5 def url_ok @url_ok end |
Instance Method Details
#checksum ⇒ Object
31 32 33 |
# File 'lib/epaybg/transaction.rb', line 31 def checksum Epaybg.hmac(encoded, secret) end |
#credit_card_link ⇒ Object
49 50 51 |
# File 'lib/epaybg/transaction.rb', line 49 def credit_card_link base_link 'credit_paydirect' end |
#encoded ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/epaybg/transaction.rb', line 17 def encoded exp_time = expires_on.strftime('%d.%m.%Y') data = <<-DATA MIN=#{min} LANG=bg INVOICE=#{invoice} AMOUNT=#{amount} EXP_TIME=#{exp_time} DATA Base64.strict_encode64(data) end |
#epay_link ⇒ Object
45 46 47 |
# File 'lib/epaybg/transaction.rb', line 45 def epay_link base_link 'paylogin' end |
#register_payment ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/epaybg/transaction.rb', line 35 def register_payment uri = URI("#{url_idn}/?ENCODED=#{encoded}&CHECKSUM=#{checksum}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE res = http.get(uri.request_uri) res.body end |