Class: RealEx::Recurring::Card

Inherits:
Transaction show all
Defined in:
lib/real_ex/recurring.rb

Constant Summary

Constants inherited from Transaction

Transaction::REQUEST_TYPES

Instance Attribute Summary

Attributes inherited from Transaction

#authcode, #comments, #pasref

Instance Method Summary collapse

Methods inherited from Transaction

#authorize!

Methods inherited from Transaction

#authorize!, #autosettle?, #initialize

Methods included from Initializer

included, #initialize

Constructor Details

This class inherits a constructor from RealEx::Transaction

Instance Method Details

#destroy!Object



123
124
125
126
# File 'lib/real_ex/recurring.rb', line 123

def destroy!
  self.cancel = true
  authorize!
end

#hashObject

20030516181127.yourmerchantid.uniqueid…smithj01.John Smith.498843******9991



104
105
106
107
108
109
110
111
112
# File 'lib/real_ex/recurring.rb', line 104

def hash
  if cancel
    RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, payer.reference, reference])
  elsif update
    RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, payer.reference, reference, card.expiry_date, card.number])
  else
    RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, order_id, '', '', payer.reference,card.cardholder_name,card.number])
  end
end

#request_typeObject



77
78
79
80
81
82
83
84
85
# File 'lib/real_ex/recurring.rb', line 77

def request_type
  if cancel
    @request_type = 'card-cancel-card'
  elsif update
    @request_type = 'card-update-card'
  else
    @request_type = 'card-new'
  end
end

#save!Object



114
115
116
# File 'lib/real_ex/recurring.rb', line 114

def save!
  authorize!
end

#to_xmlObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/real_ex/recurring.rb', line 87

def to_xml
  super do |per|
    per.card do |c|
      c.ref reference
      c.payerref payer.reference

      if !self.cancel
        c.number card.number
        c.expdate card.expiry_date
        c.chname card.cardholder_name
        c.type card.type
      end
    end
  end
end

#update!Object



118
119
120
121
# File 'lib/real_ex/recurring.rb', line 118

def update!
  self.update = true
  authorize!
end