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.
-
#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.
10 11 12 13 14 15 16 17 |
# File 'lib/epaybg/transaction.rb', line 10 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.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def amount @amount end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def description @description end |
#encoding ⇒ Object
Returns the value of attribute encoding.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def encoding @encoding end |
#expires_on ⇒ Object
Returns the value of attribute expires_on.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def expires_on @expires_on end |
#invoice ⇒ Object
Returns the value of attribute invoice.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def invoice @invoice end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def url @url end |
#url_cancel ⇒ Object
Returns the value of attribute url_cancel.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def url_cancel @url_cancel end |
#url_idn ⇒ Object
Returns the value of attribute url_idn.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def url_idn @url_idn end |
#url_ok ⇒ Object
Returns the value of attribute url_ok.
7 8 9 |
# File 'lib/epaybg/transaction.rb', line 7 def url_ok @url_ok end |
Instance Method Details
#checksum ⇒ Object
33 34 35 |
# File 'lib/epaybg/transaction.rb', line 33 def checksum Epaybg::hmac(encoded) end |
#credit_card_link ⇒ Object
51 52 53 |
# File 'lib/epaybg/transaction.rb', line 51 def credit_card_link base_link "credit_paydirect" end |
#encoded ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/epaybg/transaction.rb', line 19 def encoded exp_time = self.expires_on.strftime("%d.%m.%Y") data = <<-DATA MIN=#{Epaybg.config["min"]} LANG=bg INVOICE=#{self.invoice} AMOUNT=#{self.amount} EXP_TIME=#{exp_time} DATA Base64.strict_encode64(data) end |
#epay_link ⇒ Object
47 48 49 |
# File 'lib/epaybg/transaction.rb', line 47 def epay_link base_link "paylogin" end |
#register_payment ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/epaybg/transaction.rb', line 37 def register_payment uri = URI("#{self.url_idn}/?ENCODED=#{self.encoded}&CHECKSUM=#{self.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 |