Class: Datatrans::JSON::Transaction::MerchantAuthorize
- Inherits:
-
Object
- Object
- Datatrans::JSON::Transaction::MerchantAuthorize
- Defined in:
- lib/datatrans/json/transaction/merchant_authorize.rb
Instance Attribute Summary collapse
-
#datatrans ⇒ Object
class to authorize a transaction without user interaction api-reference.datatrans.ch/#tag/v1transactions/operation/authorize.
-
#params ⇒ Object
class to authorize a transaction without user interaction api-reference.datatrans.ch/#tag/v1transactions/operation/authorize.
Instance Method Summary collapse
-
#initialize(datatrans, params) ⇒ MerchantAuthorize
constructor
A new instance of MerchantAuthorize.
- #post(url, options = {}) ⇒ Object
- #process ⇒ Object
- #request_body ⇒ Object
Constructor Details
#initialize(datatrans, params) ⇒ MerchantAuthorize
Returns a new instance of MerchantAuthorize.
9 10 11 12 |
# File 'lib/datatrans/json/transaction/merchant_authorize.rb', line 9 def initialize(datatrans, params) @datatrans = datatrans @params = params end |
Instance Attribute Details
#datatrans ⇒ Object
class to authorize a transaction without user interaction api-reference.datatrans.ch/#tag/v1transactions/operation/authorize
7 8 9 |
# File 'lib/datatrans/json/transaction/merchant_authorize.rb', line 7 def datatrans @datatrans end |
#params ⇒ Object
class to authorize a transaction without user interaction api-reference.datatrans.ch/#tag/v1transactions/operation/authorize
7 8 9 |
# File 'lib/datatrans/json/transaction/merchant_authorize.rb', line 7 def params @params end |
Instance Method Details
#post(url, options = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/datatrans/json/transaction/merchant_authorize.rb', line 14 def post(url, = {}) = .merge(datatrans.proxy) .merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password}) HTTParty.post(url, **) end |
#process ⇒ Object
21 22 23 24 25 |
# File 'lib/datatrans/json/transaction/merchant_authorize.rb', line 21 def process post(datatrans.url(:authorize_transaction), headers: {"Content-Type" => "application/json"}, body: request_body.to_json).parsed_response end |
#request_body ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/datatrans/json/transaction/merchant_authorize.rb', line 27 def request_body auto_settle = params[:auto_settle].nil? ? true : params[:auto_settle] { currency: params[:currency], refno: params[:refno], amount: params[:amount], card: params[:card], autoSettle: auto_settle } end |