Class: MaxipagoApi::TransactionRequest

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/maxipago_api/requests/transaction_request.rb

Class Method Summary collapse

Class Method Details

.create(transaction) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/maxipago_api/requests/transaction_request.rb', line 9

def create(transaction)
  xml = {
    'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key}, 
    version: '3.1.1.15',
    order: transaction.to_object
  }.to_xml(root: 'transaction-request', skip_types: true)
  response = post(MaxipagoApi.api_transaction_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
  Hash.from_xml(response.parsed_response)
end

.find(id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/maxipago_api/requests/transaction_request.rb', line 19

def find(id)
  xml = {
    'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key}, 
    command: 'transactionDetailReport',
    request: {
      filterOptions: {
        transactionId: id
      }
    }
  }.to_xml(root: 'rapi-request', skip_types: true)
  response = post(MaxipagoApi.api_reports_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
  Hash.from_xml(response.parsed_response)
end