Class: PaySimple::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/paysimple/paysimple.rb

Class Method Summary collapse

Class Method Details

.create(options) ⇒ Object

# Bill Jennifer $12.00 begin

transaction = PaySimple::Transaction.create(
  :CustomerID => 12345,
  :AccountHolder => "Jennifer Smith",
  :CreditCardData => {
    :CardNumber => "4444555566667779",
    :CardExpiration => "0908"
  },
  :Details => {
    :Amount => 12.00
  }
)

puts "Sale transaction created with Reference Number: #{transaction["RefNum"]}"

rescue Exception => e

puts "An error occurred: #{e.message}"

end

# Credit Jennifer $12.00 begin

transaction = PaySimple::Transaction.create(
  :CustomerID => 12345,
  :AccountHolder => "Jennifer Smith",
  :CreditCardData => {
    :CardNumber => "4444555566667779",
    :CardExpiration => "0908"
  },
  :Details => {
    :Amount => -12.00
  }
)

puts "Credit transaction created with Reference Number: #{transaction["RefNum"]}"

rescue Exception => e

puts "An error occurred: #{e.message}"

end



269
270
271
272
273
274
# File 'lib/active_merchant/billing/gateways/paysimple/paysimple.rb', line 269

def create(options)
  options = PaySimple.symbolize_hash(options)
  options[:Command] ||= (options[:Details][:Amount] > 0.0 ? :sale : :credit)
  options[:Details][:Amount] = options[:Details][:Amount].abs
  PaySimple.send_request(:runTransaction, { :Source => PaySimple.source }.merge(options))
end

.find(reference_number) ⇒ Object

# Find an existing transaction begin

reference_number = 12345
transaction = PaySimple::Transaction.find(reference_number)

puts "Found transaction"

rescue Exception => e

puts "An error occurred: #{e.message}"

end



302
303
304
# File 'lib/active_merchant/billing/gateways/paysimple/paysimple.rb', line 302

def find(reference_number)
  PaySimple.send_request(:getTransaction, reference_number)
end

.void(reference_number) ⇒ Object

# Void an unsettled transaction begin

reference_number = 12345
result = PaySimple::Transaction.void(reference_number)

if result
  puts "Transaction was voided"
else
  puts "Unable to void transaction"
end

rescue Exception => e

puts "An error occurred: #{e.message}"

end



289
290
291
# File 'lib/active_merchant/billing/gateways/paysimple/paysimple.rb', line 289

def void(reference_number)
  PaySimple.send_request(:voidTransaction, reference_number)
end