Class: Gateway
- Inherits:
-
Object
- Object
- Gateway
- Defined in:
- lib/virtual_merchant/gateway.rb
Instance Attribute Summary collapse
-
#creds ⇒ Object
readonly
Returns the value of attribute creds.
Instance Method Summary collapse
- #ccaddrecurring(card, amount, custom_fields) ⇒ Object
- #ccauth(card, amount, custom_fields) ⇒ Object
- #cccomplete(amount, transaction_id) ⇒ Object
- #cccredit(card, amount, custom_fields) ⇒ Object
- #ccdelete(transaction_id) ⇒ Object
- #ccsale(card, amount, custom_fields) ⇒ Object
- #ccvoid(transaction_id) ⇒ Object
-
#initialize(creds) ⇒ Gateway
constructor
A new instance of Gateway.
- #process(xml, amount = 0) ⇒ Object
Constructor Details
#initialize(creds) ⇒ Gateway
Returns a new instance of Gateway.
4 5 6 |
# File 'lib/virtual_merchant/gateway.rb', line 4 def initialize(creds) @creds = creds end |
Instance Attribute Details
#creds ⇒ Object (readonly)
Returns the value of attribute creds.
2 3 4 |
# File 'lib/virtual_merchant/gateway.rb', line 2 def creds @creds end |
Instance Method Details
#ccaddrecurring(card, amount, custom_fields) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/virtual_merchant/gateway.rb', line 37 def ccaddrecurring(card, amount, custom_fields) if card.valid? xml = VirtualMerchant::XMLGenerator.generate(card, amount, creds, custom_fields, "ccaddrecurring") process(xml, amount) else gen_cc_errors(card) end end |
#ccauth(card, amount, custom_fields) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/virtual_merchant/gateway.rb', line 17 def ccauth(card, amount, custom_fields) if card.valid? xml = VirtualMerchant::XMLGenerator.generate(card, amount, creds, custom_fields, "ccauthonly") process(xml, amount) else gen_cc_errors(card) end end |
#cccomplete(amount, transaction_id) ⇒ Object
26 27 28 29 30 |
# File 'lib/virtual_merchant/gateway.rb', line 26 def cccomplete(amount, transaction_id) xml = VirtualMerchant::XMLGenerator.modify(creds, "cccomplete", transaction_id, amount) process(xml, amount) end |
#cccredit(card, amount, custom_fields) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/virtual_merchant/gateway.rb', line 46 def cccredit(card, amount, custom_fields) if card.valid? xml = VirtualMerchant::XMLGenerator.generate(card, amount, creds, custom_fields, 'cccredit') process(xml, amount) else gen_cc_errors(card) end end |
#ccdelete(transaction_id) ⇒ Object
32 33 34 35 |
# File 'lib/virtual_merchant/gateway.rb', line 32 def ccdelete(transaction_id) xml = VirtualMerchant::XMLGenerator.modify(creds, "ccdelete", transaction_id) process(xml) end |
#ccsale(card, amount, custom_fields) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/virtual_merchant/gateway.rb', line 8 def ccsale(card, amount, custom_fields) if card.valid? xml = VirtualMerchant::XMLGenerator.generate(card, amount, creds, custom_fields, "ccsale") process(xml, amount) else gen_cc_errors(card) end end |
#ccvoid(transaction_id) ⇒ Object
55 56 57 58 |
# File 'lib/virtual_merchant/gateway.rb', line 55 def ccvoid(transaction_id) xml = VirtualMerchant::XMLGenerator.generateVoid(transaction_id, creds) process(xml) end |
#process(xml, amount = 0) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/virtual_merchant/gateway.rb', line 60 def process(xml, amount=0) communication = VirtualMerchant::Communication.new( {xml: xml, url: url(creds.demo), referer: creds.referer}) vm_response = communication.send response = VirtualMerchant::Response.new(xml_string: vm_response) VirtualMerchant::Logger.log_response(response) response end |