Class: VirtualMerchant::XMLGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/virtual_merchant/xml_generator.rb

Class Method Summary collapse

Class Method Details

.generate(card, amount, creds, custom_fields, transaction_type) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/virtual_merchant/xml_generator.rb', line 15

def self.generate(card, amount, creds, custom_fields, transaction_type)
  xml = "xmldata=<txn>"
    xml += credentials(creds)
    xml += basic(card, transaction_type, amount)
    xml += for_recurring(amount) if transaction_type == 'ccaddrecurring'
    if card.encrypted?
      xml += for_encrypted(card, creds)
    else
      xml += for_clear_text(card)
    end
    custom_fields.each do |key,value|
      xml += "<#{key}>#{value}</#{key}>"
    end
  xml += "</txn>"
  VirtualMerchant::Logger.xml('NORMAL OUTPUT', xml)
  xml
end

.generateVoid(transaction_id, creds) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/virtual_merchant/xml_generator.rb', line 3

def self.generateVoid(transaction_id, creds)
  xml = "xmldata=<txn>
    <ssl_transaction_type>ccvoid</ssl_transaction_type>
    <ssl_merchant_id>#{creds.account_id}</ssl_merchant_id>
    <ssl_user_id>#{creds.user_id}</ssl_user_id>
    <ssl_pin>#{creds.pin}</ssl_pin>
    <ssl_txn_id>#{transaction_id}</ssl_txn_id>
    </txn>"
  VirtualMerchant::Logger.xml('VOID OUTPUT', xml)
  return xml
end

.modify(creds, transaction_type, transaction_id, amount = 0) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/virtual_merchant/xml_generator.rb', line 33

def self.modify(creds, transaction_type, transaction_id, amount=0)
  xml =    "xmldata=<txn>"
    xml +=  credentials(creds)
    xml += "<ssl_transaction_type>#{transaction_type}</ssl_transaction_type>
            <ssl_txn_id>#{transaction_id}</ssl_txn_id>"
  if transaction_type == 'cccomplete'
    xml += "<ssl_amount>#{amount.total}</ssl_amount>"
  end
  xml +=   "</txn>"
  VirtualMerchant::Logger.xml('MODIFY TRANSACTION OUTPUT', xml)
  xml
end