class OffsitePayments::Integrations::Migs::TransactionBuilder
Attributes
post[R]
Public Class Methods
new(options)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 189 def initialize(options) @options = options @post = {} end
Public Instance Methods
add_advanced_user()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 213 def add_advanced_user post[:User] = @options[:advanced_login] post[:Password] = @options[:advanced_password] end
add_amount(cents)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 198 def add_amount(cents) post[:Amount] = cents.to_s end
add_creditcard(creditcard)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 202 def add_creditcard(creditcard) post[:CardNum] = creditcard.number post[:CardSecurityCode] = creditcard.verification_value if creditcard.verification_value? post[:CardExp] = format(creditcard.year) + format(creditcard.month) end
add_creditcard_type(card_type)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 208 def add_creditcard_type(card_type) post[:Gateway] = 'ssl' post[:card] = CARD_TYPES.detect{|ct| ct.am_code == card_type}.migs_long_code end
add_invoice(options)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 194 def add_invoice(options) post[:OrderInfo] = options.fetch(:order_id) end
add_standard_parameters(action, unique_id = nil)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 218 def add_standard_parameters(action, unique_id = nil) post.merge!( :Version => API_VERSION, :Merchant => @options[:login], :AccessCode => @options[:password], :Command => action, :MerchTxnRef => unique_id || SecureRandom.hex(16).slice(0, 40) ) end
Private Instance Methods
format(number)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 230 def format(number) sprintf("%.2i", number.to_i)[-2..-1] end