Class: RubyPsigate::Gateway
- Inherits:
-
Object
- Object
- RubyPsigate::Gateway
- Includes:
- TransactionMethods
- Defined in:
- lib/ruby_psigate/gateway.rb
Constant Summary collapse
- TRANSACTION_LOOKUP =
{ :sale => "0", :preauth => "1", :postauth => "2", :credit => "3", :force_postauth => "4", :void => "9" }
Constants included from TransactionMethods
TransactionMethods::TRANSACTION_TEST_URL
Instance Attribute Summary collapse
-
#account ⇒ Object
include RubyPsigate::AccountManagerMethods.
-
#mode ⇒ Object
include RubyPsigate::AccountManagerMethods.
-
#options ⇒ Object
readonly
include RubyPsigate::AccountManagerMethods.
-
#order ⇒ Object
include RubyPsigate::AccountManagerMethods.
Class Method Summary collapse
Instance Method Summary collapse
- #commit! ⇒ Object
-
#initialize(options = {}) ⇒ Gateway
constructor
A new instance of Gateway.
Methods included from TransactionMethods
Constructor Details
#initialize(options = {}) ⇒ Gateway
Returns a new instance of Gateway.
32 33 34 35 |
# File 'lib/ruby_psigate/gateway.rb', line 32 def initialize(={}) @options = set_mode(@options) end |
Instance Attribute Details
#account ⇒ Object
include RubyPsigate::AccountManagerMethods
30 31 32 |
# File 'lib/ruby_psigate/gateway.rb', line 30 def account @account end |
#mode ⇒ Object
include RubyPsigate::AccountManagerMethods
30 31 32 |
# File 'lib/ruby_psigate/gateway.rb', line 30 def mode @mode end |
#options ⇒ Object (readonly)
include RubyPsigate::AccountManagerMethods
30 31 32 |
# File 'lib/ruby_psigate/gateway.rb', line 30 def @options end |
#order ⇒ Object
include RubyPsigate::AccountManagerMethods
30 31 32 |
# File 'lib/ruby_psigate/gateway.rb', line 30 def order @order end |
Class Method Details
.env ⇒ Object
15 16 17 |
# File 'lib/ruby_psigate/gateway.rb', line 15 def self.env @env end |
.live! ⇒ Object
19 20 21 |
# File 'lib/ruby_psigate/gateway.rb', line 19 def self.live! @env = :live end |
.test! ⇒ Object
23 24 25 |
# File 'lib/ruby_psigate/gateway.rb', line 23 def self.test! @env = :test end |
Instance Method Details
#commit! ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ruby_psigate/gateway.rb', line 62 def commit! # 1) Check the mode # 2) Ensure credentials are set # 3) Check which action user is wanting to take # 4) Ensure adequate minimum parameters for the given action # 5) Parameterize and ensure it is properly formatted # 6) Send! begin raise InvalidGatewayMode unless mode_set? raise InvalidCredentials unless sufficient_login_credentials? if mode == :transaction raise InvalidOrder unless order.valid? @params = {} @params[:Order] = {} @params[:Order] = { :StoreID => [:store_id], :Passphrase => [:passphrase] } @params[:Order].merge!(order.to_hash(order.action)) @endpoint = "https://dev.psigate.com:7989/Messenger/XMLMessenger" end if mode == :account_manager # raise InvalidAccount unless account.valid? # Parameterize based on account manager @params = {} @params[:Request] = {} @params[:Request] = { :CID => [:cid], :UserID => [:user_id], :Password => [:password] } @params[:Request].merge!(account.to_hash(account.action)) @endpoint = "https://dev.psigate.com:8645/Messenger/AMMessenger" end # Serializes the parameters to xml @params = Serializer.new(@params, :header => true).to_xml @connection = Connection.new(@endpoint) @response = @connection.post(@params) @response = Response.new(@response) rescue ConnectionError => e @response = false end @response end |