Class: RubyPayler::Payler
- Inherits:
-
Object
- Object
- RubyPayler::Payler
- Defined in:
- lib/ruby_payler/payler.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
- #charge(order_id, amount) ⇒ Object
- #get_advanced_status(order_id) ⇒ Object
- #get_status(order_id) ⇒ Object
-
#initialize(host:, key:, password:, debug: false) ⇒ Payler
constructor
A new instance of Payler.
- #pay_page_url(session_id) ⇒ Object
- #refund(order_id, amount) ⇒ Object
- #retrieve(order_id, amount) ⇒ Object
- #start_session(order_id:, type:, cents:, currency:, lang:, product: nil, userdata: nil) ⇒ Object
Constructor Details
#initialize(host:, key:, password:, debug: false) ⇒ Payler
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby_payler/payler.rb', line 8 def initialize(host:, key:, password:, debug: false) @host = host @key = key @password = password @connection = Faraday.new( url: "https://#{host}.payler.com", params: { key: @key }, ) do |f| f.request :url_encoded # form-encode POST params f.params f.response :mashify # 3. mashify parsed JSON f.response :json # 2. parse JSON f.response :logger if debug # 1. log requests to STDOUT f.adapter Faraday.default_adapter # make requests with Net::HTTP end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/ruby_payler/payler.rb', line 6 def host @host end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/ruby_payler/payler.rb', line 6 def key @key end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/ruby_payler/payler.rb', line 6 def password @password end |
Instance Method Details
#charge(order_id, amount) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/ruby_payler/payler.rb', line 69 def charge(order_id, amount) call_payler_api('gapi/Charge', { key: key, password: password, order_id: order_id, amount: amount, }) end |
#get_advanced_status(order_id) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/ruby_payler/payler.rb', line 62 def get_advanced_status(order_id) call_payler_api('gapi/GetAdvancedStatus', { key: key, order_id: order_id, }) end |
#get_status(order_id) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/ruby_payler/payler.rb', line 55 def get_status(order_id) call_payler_api('gapi/GetStatus', { key: key, order_id: order_id, }) end |
#pay_page_url(session_id) ⇒ Object
51 52 53 |
# File 'lib/ruby_payler/payler.rb', line 51 def pay_page_url(session_id) "#{connection.url_prefix.to_s}gapi/Pay?key=#{key}&session_id=#{session_id}" end |
#refund(order_id, amount) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/ruby_payler/payler.rb', line 87 def refund(order_id, amount) call_payler_api('gapi/Refund', { key: key, password: password, order_id: order_id, amount: amount, }) end |
#retrieve(order_id, amount) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/ruby_payler/payler.rb', line 78 def retrieve(order_id, amount) call_payler_api('gapi/Retrieve', { key: key, password: password, order_id: order_id, amount: amount, }) end |
#start_session(order_id:, type:, cents:, currency:, lang:, product: nil, userdata: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ruby_payler/payler.rb', line 29 def start_session( order_id:, type:, cents:, currency:, lang:, product: nil, userdata: nil ) params = call_payler_api('gapi/StartSession', { key: key, type: type, order_id: order_id, currency: currency, amount: cents, lang: lang, product: product, userdata: userdata, }) end |