Class: RubyPayler::Payler

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_payler/payler.rb

Overview

Wrapper for payler gate api

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host:, key:, password:, debug: false) ⇒ Payler

Returns a new instance of Payler.



8
9
10
11
12
13
14
15
# File 'lib/ruby_payler/payler.rb', line 8

def initialize(host:, key:, password:, debug: false)
  @host = host
  @key = key
  @password = password
  @debug = debug

  @payler_url = "https://#{host}.payler.com/gapi/"
end

Instance Attribute Details

#debugObject (readonly)

Returns the value of attribute debug.



6
7
8
# File 'lib/ruby_payler/payler.rb', line 6

def debug
  @debug
end

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/ruby_payler/payler.rb', line 6

def host
  @host
end

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/ruby_payler/payler.rb', line 6

def key
  @key
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/ruby_payler/payler.rb', line 6

def password
  @password
end

#payler_urlObject (readonly)

Returns the value of attribute payler_url.



6
7
8
# File 'lib/ruby_payler/payler.rb', line 6

def payler_url
  @payler_url
end

Instance Method Details

#activate_template(recurrent_template_id, active) ⇒ Object



77
78
79
80
81
82
# File 'lib/ruby_payler/payler.rb', line 77

def activate_template(recurrent_template_id, active)
  call_payler_api('ActivateTemplate',
    recurrent_template_id: recurrent_template_id,
    active: active,
  )
end

#charge(order_id, amount) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/ruby_payler/payler.rb', line 47

def charge(order_id, amount)
  call_payler_api('Charge',
    password: password,
    order_id: order_id,
    amount: amount,
  )
end

#find_session(order_id) ⇒ Object



31
32
33
# File 'lib/ruby_payler/payler.rb', line 31

def find_session(order_id)
  call_payler_api('FindSession', order_id: order_id)
end

#get_advanced_status(order_id) ⇒ Object



43
44
45
# File 'lib/ruby_payler/payler.rb', line 43

def get_advanced_status(order_id)
  call_payler_api('GetAdvancedStatus', order_id: order_id)
end

#get_status(order_id) ⇒ Object



39
40
41
# File 'lib/ruby_payler/payler.rb', line 39

def get_status(order_id)
  call_payler_api('GetStatus', order_id: order_id)
end

#get_template(recurrent_template_id) ⇒ Object



71
72
73
74
75
# File 'lib/ruby_payler/payler.rb', line 71

def get_template(recurrent_template_id)
  call_payler_api('GetTemplate',
    recurrent_template_id: recurrent_template_id,
  )
end

#pay_page_url(session_id) ⇒ Object



35
36
37
# File 'lib/ruby_payler/payler.rb', line 35

def pay_page_url(session_id)
  "#{payler_url}Pay?key=#{key}&session_id=#{session_id}"
end

#refund(order_id, amount) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/ruby_payler/payler.rb', line 63

def refund(order_id, amount)
  call_payler_api('Refund',
    password: password,
    order_id: order_id,
    amount: amount,
  )
end

#repeat_pay(order_id:, amount:, recurrent_template_id:) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/ruby_payler/payler.rb', line 84

def repeat_pay(order_id:, amount:, recurrent_template_id:)
  call_payler_api('RepeatPay',
    order_id: order_id,
    amount: amount,
    recurrent_template_id: recurrent_template_id,
  )
end

#retrieve(order_id, amount) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/ruby_payler/payler.rb', line 55

def retrieve(order_id, amount)
  call_payler_api('Retrieve',
    password: password,
    order_id: order_id,
    amount: amount,
  )
end

#start_session(type:, order_id:, cents:, **other_session_params) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby_payler/payler.rb', line 17

def start_session(
  type:,
  order_id:,
  cents:,
  **other_session_params
)
  call_payler_api('StartSession',
    type: type,
    order_id: order_id,
    amount: cents,
    **other_session_params,
  )
end