ruby_psigate 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +1 -0
- data/lib/ruby_psigate/gateway.rb +33 -27
- data/ruby_psigate.gemspec +1 -1
- data/test/unit/gateway_test.rb +29 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/ruby_psigate/gateway.rb
CHANGED
@@ -67,38 +67,44 @@ module RubyPsigate
|
|
67
67
|
# 5) Parameterize and ensure it is properly formatted
|
68
68
|
# 6) Send!
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
begin
|
71
|
+
raise InvalidGatewayMode unless mode_set?
|
72
|
+
raise InvalidCredentials unless sufficient_login_credentials?
|
72
73
|
|
73
|
-
|
74
|
-
|
74
|
+
if mode == :transaction
|
75
|
+
raise InvalidOrder unless order.valid?
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@endpoint = "https://dev.psigate.com:7989/Messenger/XMLMessenger"
|
82
|
-
end
|
77
|
+
@params = {}
|
78
|
+
@params[:Order] = {}
|
79
|
+
@params[:Order] = { :StoreID => options[:store_id], :Passphrase => options[:passphrase] }
|
80
|
+
@params[:Order].merge!(order.to_hash(order.action))
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
82
|
+
@endpoint = "https://dev.psigate.com:7989/Messenger/XMLMessenger"
|
83
|
+
end
|
84
|
+
|
85
|
+
if mode == :account_manager
|
86
|
+
# raise InvalidAccount unless account.valid?
|
87
|
+
|
88
|
+
# Parameterize based on account manager
|
89
|
+
@params = {}
|
90
|
+
@params[:Request] = {}
|
91
|
+
@params[:Request] = { :CID => options[:cid], :UserID => options[:user_id], :Password => options[:password] }
|
92
|
+
@params[:Request].merge!(account.to_hash(account.action))
|
93
|
+
|
94
|
+
@endpoint = "https://dev.psigate.com:8645/Messenger/AMMessenger"
|
95
|
+
end
|
96
|
+
|
97
|
+
# Serializes the parameters to xml
|
98
|
+
@params = Serializer.new(@params, :header => true).to_xml
|
99
|
+
|
100
|
+
@connection = Connection.new(@endpoint)
|
101
|
+
@response = @connection.post(@params)
|
102
|
+
Response.new(@response)
|
103
|
+
rescue ConnectionError => e
|
104
|
+
@response = false
|
94
105
|
end
|
95
106
|
|
96
|
-
|
97
|
-
@params = Serializer.new(@params, :header => true).to_xml
|
98
|
-
|
99
|
-
@connection = Connection.new(@endpoint)
|
100
|
-
@response = @connection.post(@params)
|
101
|
-
Response.new(@response)
|
107
|
+
@response
|
102
108
|
end
|
103
109
|
|
104
110
|
private
|
data/ruby_psigate.gemspec
CHANGED
data/test/unit/gateway_test.rb
CHANGED
@@ -107,6 +107,35 @@ module RubyPsigate
|
|
107
107
|
assert_raises(InvalidCredentials) { @gateway.commit! }
|
108
108
|
end
|
109
109
|
end
|
110
|
+
|
111
|
+
context "connection error handling" do
|
112
|
+
should "handle connection error" do
|
113
|
+
RubyPsigate::Connection.any_instance.stubs(:post).raises(ConnectionError)
|
114
|
+
|
115
|
+
|
116
|
+
@gateway = RubyPsigate::Gateway.new(:store_id => "teststore", :passphrase => "psigate1234")
|
117
|
+
|
118
|
+
@order = RubyPsigate::Order.new
|
119
|
+
@order.amount = 10.00
|
120
|
+
@order.action = :sale
|
121
|
+
@order.email = "bob@gmail.com"
|
122
|
+
|
123
|
+
@credit_card = RubyPsigate::CreditCard.new(
|
124
|
+
:number => "4111111111111111",
|
125
|
+
:month => "12",
|
126
|
+
:year => "2011",
|
127
|
+
:verification_value => "123",
|
128
|
+
:name => "Bob John"
|
129
|
+
)
|
130
|
+
|
131
|
+
@order.cc = @credit_card
|
132
|
+
|
133
|
+
@gateway.order = @order
|
134
|
+
|
135
|
+
assert !@gateway.commit!
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
110
139
|
|
111
140
|
end
|
112
141
|
end
|