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 CHANGED
@@ -1,3 +1,4 @@
1
+ v0.7.6. gateway handles connection problems gracefully
1
2
  v0.7.5. fixed bug: serializer works for ItemInfo
2
3
  v0.7.4. fixed bug: account charges can now be registered
3
4
  v0.7.3. fixed bugs related to account information (address, name) not being passed through to server
@@ -67,38 +67,44 @@ module RubyPsigate
67
67
  # 5) Parameterize and ensure it is properly formatted
68
68
  # 6) Send!
69
69
 
70
- raise InvalidGatewayMode unless mode_set?
71
- raise InvalidCredentials unless sufficient_login_credentials?
70
+ begin
71
+ raise InvalidGatewayMode unless mode_set?
72
+ raise InvalidCredentials unless sufficient_login_credentials?
72
73
 
73
- if mode == :transaction
74
- raise InvalidOrder unless order.valid?
74
+ if mode == :transaction
75
+ raise InvalidOrder unless order.valid?
75
76
 
76
- @params = {}
77
- @params[:Order] = {}
78
- @params[:Order] = { :StoreID => options[:store_id], :Passphrase => options[:passphrase] }
79
- @params[:Order].merge!(order.to_hash(order.action))
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
- if mode == :account_manager
85
- # raise InvalidAccount unless account.valid?
86
-
87
- # Parameterize based on account manager
88
- @params = {}
89
- @params[:Request] = {}
90
- @params[:Request] = { :CID => options[:cid], :UserID => options[:user_id], :Password => options[:password] }
91
- @params[:Request].merge!(account.to_hash(account.action))
92
-
93
- @endpoint = "https://dev.psigate.com:8645/Messenger/AMMessenger"
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
- # Serializes the parameters to xml
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ruby_psigate}
5
- s.version = "0.7.5"
5
+ s.version = "0.7.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Simon Chiu"]
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 5
9
- version: 0.7.5
8
+ - 6
9
+ version: 0.7.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Simon Chiu