Class: Rma::Payment::Gateway::DebitRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/rma/payment/gateway/debit_request.rb

Overview

Authorization class for RMA Payment Gateway. Handles authentication and authorization for the RMA Payment Gateway client.

Examples:

auth = Rma::Payment::Gateway::Authorization.new(client)
auth.call(order_no, amount, email)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ DebitRequest

Returns a new instance of DebitRequest.



20
21
22
# File 'lib/rma/payment/gateway/debit_request.rb', line 20

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



18
19
20
# File 'lib/rma/payment/gateway/debit_request.rb', line 18

def client
  @client
end

#otpObject (readonly)

Returns the value of attribute otp.



18
19
20
# File 'lib/rma/payment/gateway/debit_request.rb', line 18

def otp
  @otp
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



18
19
20
# File 'lib/rma/payment/gateway/debit_request.rb', line 18

def transaction_id
  @transaction_id
end

Instance Method Details

#call(transaction_id, otp) ⇒ Object

Fetch debit request Returns the debit request string



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rma/payment/gateway/debit_request.rb', line 26

def call(transaction_id, otp)
  @transaction_id = transaction_id
  @otp = otp
  response = client.post(body: debit_request_body)

  validate_debit_request_response!(response)

  response["result"]
rescue StandardError => e
  raise AuthenticationError, "Failed to fetch debit request: #{e.message}"
end