Class: Wirecard::Elastic::Request::Refund

Inherits:
Base
  • Object
show all
Defined in:
lib/wirecard/elastic/request/refund.rb

Constant Summary collapse

PAYMENT_QUERY_MAP =
{:purchase => "payments", :debit => "paymentmethods"}.freeze

Constants inherited from Base

Base::VALID_STATUS_LIST

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#safe

Constructor Details

#initialize(merchant_id, parent_transaction_id, payment_method) ⇒ Refund

Returns a new instance of Refund.



13
14
15
16
17
18
# File 'lib/wirecard/elastic/request/refund.rb', line 13

def initialize(merchant_id, parent_transaction_id, payment_method)
  @merchant_id           = merchant_id
  @parent_transaction_id = parent_transaction_id
  @request_id            = SecureRandom.uuid
  @payment_method        = payment_method
end

Instance Attribute Details

#merchant_idObject (readonly)

Returns the value of attribute merchant_id.



11
12
13
# File 'lib/wirecard/elastic/request/refund.rb', line 11

def merchant_id
  @merchant_id
end

#parent_transaction_idObject (readonly)

Returns the value of attribute parent_transaction_id.



11
12
13
# File 'lib/wirecard/elastic/request/refund.rb', line 11

def parent_transaction_id
  @parent_transaction_id
end

#payment_methodObject (readonly)

Returns the value of attribute payment_method.



11
12
13
# File 'lib/wirecard/elastic/request/refund.rb', line 11

def payment_method
  @payment_method
end

#request_idObject (readonly)

Returns the value of attribute request_id.



11
12
13
# File 'lib/wirecard/elastic/request/refund.rb', line 11

def request_id
  @request_id
end

Instance Method Details

#bodyObject

XML body we will send to the elastic API



36
37
38
# File 'lib/wirecard/elastic/request/refund.rb', line 36

def body
  @body ||= Body::Builder.new(self, :refund).to_xml
end

#parent_transactionObject

original transaction of the refund requested remotely to elastic API



42
43
44
# File 'lib/wirecard/elastic/request/refund.rb', line 42

def parent_transaction
  @parent_transaction ||= Transaction.new(merchant_id, parent_transaction_id, payment_method)
end

#queryObject

address we want to access on the API



31
32
33
# File 'lib/wirecard/elastic/request/refund.rb', line 31

def query
  @query ||= PAYMENT_QUERY_MAP[parent_transaction.response.transaction_type]
end

#requestObject

calling request



21
22
23
# File 'lib/wirecard/elastic/request/refund.rb', line 21

def request
  @request ||= Request.new(query_uri: query, payment_method: payment_method, method: :post, body: body).dispatch!
end

#responseObject

processed response



26
27
28
# File 'lib/wirecard/elastic/request/refund.rb', line 26

def response
  @response ||= Response.new(request: request, action: :refund).dispatch!
end