Class: Nihaopay::Transactions::Capture

Inherits:
Base
  • Object
show all
Defined in:
lib/nihaopay/transactions/capture.rb

Constant Summary

Constants included from Api

Api::LIVE_HOST, Api::TEST_HOST, Api::VERSION

Instance Attribute Summary collapse

Attributes inherited from Base

#amount, #currency, #note, #reference, #status, #time, #token, #transaction_id, #type

Class Method Summary collapse

Methods inherited from Base

build, build_from_response!, #cancel, #capture, #initialize, #partial_capture, #partial_refund, #refund, #release, request_body, request_headers

Methods included from Queryable

included

Methods included from Api

included

Constructor Details

This class inherits a constructor from Nihaopay::Transactions::Base

Instance Attribute Details

#capture_transaction_idObject

Returns the value of attribute capture_transaction_id.



4
5
6
# File 'lib/nihaopay/transactions/capture.rb', line 4

def capture_transaction_id
  @capture_transaction_id
end

#capturedObject

Returns the value of attribute captured.



4
5
6
# File 'lib/nihaopay/transactions/capture.rb', line 4

def captured
  @captured
end

Class Method Details

.request_url(transaction_id) ⇒ Object



15
16
17
# File 'lib/nihaopay/transactions/capture.rb', line 15

def request_url(transaction_id)
  "#{base_url}/transactions/#{transaction_id}/capture"
end

.response_keys_mapObject



23
24
25
# File 'lib/nihaopay/transactions/capture.rb', line 23

def response_keys_map
  { id: :transaction_id, transaction_id: :capture_transaction_id }
end

.start(transaction_id, amount, currency, options = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/nihaopay/transactions/capture.rb', line 7

def start(transaction_id, amount, currency, options = {})
  @token = options.delete(:token)
  url = request_url(transaction_id)
  params = request_body(amount: amount, currency: currency)
  response = HTTParty.post(url, headers: request_headers, body: params)
  build_from_response!(response)
end

.valid_attributesObject



19
20
21
# File 'lib/nihaopay/transactions/capture.rb', line 19

def valid_attributes
  %i(transaction_id status captured capture_transaction_id)
end