Class: Nihaopay::Transactions::Authorize
- Inherits:
-
Base
- Object
- Base
- Nihaopay::Transactions::Authorize
show all
- Defined in:
- lib/nihaopay/transactions/authorize.rb
Constant Summary
Constants included
from Queryable
Queryable::TIME_FORMAT
Constants included
from Api
Api::LIVE_HOST, Api::TEST_HOST, Api::VERSION
Instance Attribute Summary
Attributes inherited from Base
#amount, #captured, #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, response_keys_map, valid_attributes
Methods included from Queryable
included
Methods included from Api
included
Class Method Details
.capture_param ⇒ Object
32
33
34
|
# File 'lib/nihaopay/transactions/authorize.rb', line 32
def capture_param
false
end
|
.request_params(amount, credit_card, options) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/nihaopay/transactions/authorize.rb', line 17
def request_params(amount, credit_card, options)
params = {}
params.merge! credit_card.to_params_hash
params.merge! Nihaopay::HashUtil.slice(options, *valid_options)
params[:capture] = capture_param
params[:amount] = amount
params[:reserved] = { 'sub_mid' => options[:sub_mid].to_s }.to_json if options.key?(:sub_mid)
params[:currency] ||= Nihaopay.currency
params
end
|
.request_url ⇒ Object
13
14
15
|
# File 'lib/nihaopay/transactions/authorize.rb', line 13
def request_url
"#{base_url}/transactions/expresspay"
end
|
.start(amount, credit_card, options = {}) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/nihaopay/transactions/authorize.rb', line 5
def start(amount, credit_card, options = {})
@token = options.delete(:token)
params = request_params(amount, credit_card, options)
body = request_body(params)
response = HTTParty.post(request_url, headers: , body: body)
build_from_response!(response)
end
|
.valid_options ⇒ Object
28
29
30
|
# File 'lib/nihaopay/transactions/authorize.rb', line 28
def valid_options
%i[currency description note reference client_ip].freeze
end
|