Class: PaySimple::Transaction
- Inherits:
-
Object
- Object
- PaySimple::Transaction
- Defined in:
- lib/active_merchant/billing/gateways/paysimple/paysimple.rb
Class Method Summary collapse
-
.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 } ).
-
.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: #ee.message” 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: #ee.message” end.
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.}"
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.}"
end
269 270 271 272 273 274 |
# File 'lib/active_merchant/billing/gateways/paysimple/paysimple.rb', line 269 def create() = PaySimple.symbolize_hash() [:Command] ||= ([:Details][:Amount] > 0.0 ? :sale : :credit) [:Details][:Amount] = [:Details][:Amount].abs PaySimple.send_request(:runTransaction, { :Source => PaySimple.source }.merge()) 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.}"
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.}"
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 |