Class: Onlinepay::Payments
- Inherits:
-
APIResource
- Object
- APIResource
- Onlinepay::Payments
- Defined in:
- lib/onlinepay/payments.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#processingUrl ⇒ Object
readonly
Returns the value of attribute processingUrl.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(product, amount, currency, opts = {}) ⇒ Payments
constructor
A new instance of Payments.
- #show ⇒ Object
Methods included from Config
Constructor Details
#initialize(product, amount, currency, opts = {}) ⇒ Payments
Returns a new instance of Payments.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/onlinepay/payments.rb', line 6 def initialize(product,amount,currency,opts={}) # POST '/api/v1/payments params = { product: product, amount: amount, currency: currency }.merge(opts).to_json _response = RestClient.post(domain, params, { Authorization: , content_type: :json, accept: :json }) response = JSON.parse(_response) @token = response["token"] @processingUrl = response["processingUrl"] @amount = response["payment"]["amount"] @currency = response["payment"]["currency"] @status = response["payment"]["status"] end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
4 5 6 |
# File 'lib/onlinepay/payments.rb', line 4 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
4 5 6 |
# File 'lib/onlinepay/payments.rb', line 4 def currency @currency end |
#processingUrl ⇒ Object (readonly)
Returns the value of attribute processingUrl.
4 5 6 |
# File 'lib/onlinepay/payments.rb', line 4 def processingUrl @processingUrl end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/onlinepay/payments.rb', line 4 def status @status end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
4 5 6 |
# File 'lib/onlinepay/payments.rb', line 4 def token @token end |
Class Method Details
.lists(date_from: nil, date_to: nil, page: nil, per_page: nil, operation_type: nil) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/onlinepay/payments.rb', line 27 def lists(date_from: nil, date_to: nil, page: nil, per_page: nil, operation_type: nil) # GET '/api/v1/payments' _page = ( page.is_a? Integer ) ? page : 1 params = { params: { date_from: date_from, date_to: date_to, page: _page, per_page: per_page ||= 20, operation_type: operation_type }, Authorization: } _response = RestClient.get(domain, params) response = JSON.parse(_response) end |
Instance Method Details
#show ⇒ Object
18 19 20 21 22 23 |
# File 'lib/onlinepay/payments.rb', line 18 def show # GET '/api/v1/payments/[payment_token]' params = { params: {}, Authorization: } _response = RestClient.get("#{domain}/#{@token}", params) response = JSON.parse(_response) end |