Class: Payu::Pos
- Inherits:
-
Object
- Object
- Payu::Pos
- Defined in:
- lib/payu/pos.rb
Constant Summary collapse
- TYPES =
['default', 'sms']
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
-
#gateway_url ⇒ Object
readonly
Returns the value of attribute gateway_url.
-
#key1 ⇒ Object
readonly
Returns the value of attribute key1.
-
#key2 ⇒ Object
readonly
Returns the value of attribute key2.
-
#pos_auth_key ⇒ Object
readonly
Returns the value of attribute pos_auth_key.
-
#pos_id ⇒ Object
readonly
Returns the value of attribute pos_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Instance Method Summary collapse
- #add_signature? ⇒ Boolean
- #cancel(session_id) ⇒ Object
- #confirm(session_id) ⇒ Object
- #get(session_id) ⇒ Object
-
#initialize(options) ⇒ Object
constructor
Creates new Pos instance.
-
#new_transaction(options = {}) ⇒ Object
Creates new transaction.
- #validate_options! ⇒ Object
Constructor Details
#initialize(options) ⇒ Object
Creates new Pos instance
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/payu/pos.rb', line 16 def initialize() @pos_id = [:pos_id].to_i @pos_auth_key = [:pos_auth_key] @key1 = [:key1] @key2 = [:key2] @gateway_url = [:gateway_url] || 'www.platnosci.pl' @variant = [:variant] || 'default' @encoding = [:encoding] || 'UTF' @test_payment = .fetch(:test_payment, false) @add_signature = .fetch(:add_signature, true) end |
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def encoding @encoding end |
#gateway_url ⇒ Object (readonly)
Returns the value of attribute gateway_url.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def gateway_url @gateway_url end |
#key1 ⇒ Object (readonly)
Returns the value of attribute key1.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def key1 @key1 end |
#key2 ⇒ Object (readonly)
Returns the value of attribute key2.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def key2 @key2 end |
#pos_auth_key ⇒ Object (readonly)
Returns the value of attribute pos_auth_key.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def pos_auth_key @pos_auth_key end |
#pos_id ⇒ Object (readonly)
Returns the value of attribute pos_id.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def pos_id @pos_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def type @type end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
10 11 12 |
# File 'lib/payu/pos.rb', line 10 def variant @variant end |
Instance Method Details
#add_signature? ⇒ Boolean
77 78 79 |
# File 'lib/payu/pos.rb', line 77 def add_signature? @add_signature end |
#cancel(session_id) ⇒ Object
73 74 75 |
# File 'lib/payu/pos.rb', line 73 def cancel(session_id) get_gateway.cancel(session_id) end |
#confirm(session_id) ⇒ Object
69 70 71 |
# File 'lib/payu/pos.rb', line 69 def confirm(session_id) get_gateway.confirm(session_id) end |
#get(session_id) ⇒ Object
65 66 67 |
# File 'lib/payu/pos.rb', line 65 def get(session_id) get_gateway.get(session_id) end |
#new_transaction(options = {}) ⇒ Object
Creates new transaction
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/payu/pos.rb', line 42 def new_transaction( = {}) = .dup .merge!({ :pos_id => @pos_id, :pos_auth_key => @pos_auth_key, :gateway_url => [:gateway_url] || @gateway_url, :key1 => @key1, :encoding => encoding, :variant => variant }) if !.has_key?(:add_signature) [:add_signature] = add_signature? end if !.has_key?(:pay_type) [:pay_type] = test_payment? ? 't' : nil end Transaction.new() end |
#validate_options! ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/payu/pos.rb', line 30 def raise PosInvalid.new('Missing pos_id parameter') if pos_id.nil? || pos_id == 0 raise PosInvalid.new('Missing pos_auth_key parameter') if pos_auth_key.nil? || pos_auth_key == '' raise PosInvalid.new('Missing key1 parameter') if key1.nil? || key1 == '' raise PosInvalid.new('Missing key2 parameter') if key2.nil? || key2 == '' raise PosInvalid.new("Invalid variant parameter, expected one of these: #{TYPES.join(', ')}") unless TYPES.include?(variant) raise PosInvalid.new("Invalid encoding parameter, expected one of these: #{ENCODINGS.join(', ')}") unless ENCODINGS.include?(encoding) end |