Class: Onlinepay::Payments

Inherits:
APIResource show all
Defined in:
lib/onlinepay/payments.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config

included

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: bearer_authorize, 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

#amountObject (readonly)

Returns the value of attribute amount.



4
5
6
# File 'lib/onlinepay/payments.rb', line 4

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



4
5
6
# File 'lib/onlinepay/payments.rb', line 4

def currency
  @currency
end

#processingUrlObject (readonly)

Returns the value of attribute processingUrl.



4
5
6
# File 'lib/onlinepay/payments.rb', line 4

def processingUrl
  @processingUrl
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/onlinepay/payments.rb', line 4

def status
  @status
end

#tokenObject (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: bearer_authorize }
  _response = RestClient.get(domain, params)
  response = JSON.parse(_response)
end

Instance Method Details

#showObject



18
19
20
21
22
23
# File 'lib/onlinepay/payments.rb', line 18

def show
  # GET '/api/v1/payments/[payment_token]'
  params = { params: {}, Authorization: bearer_authorize }
  _response = RestClient.get("#{domain}/#{@token}", params)
  response = JSON.parse(_response)       
end