paypkg 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8af42bba52af920b74d5f2643e3f8689f5d893e0
4
- data.tar.gz: 10e1c7dd26eb17d6d568c379ffe614190e13f278
3
+ metadata.gz: 04971f9b28415697d2b097efbd0d33fa26e1cba8
4
+ data.tar.gz: f569dacfcd0f7e0fa5a869779cf689505c8ab8de
5
5
  SHA512:
6
- metadata.gz: eb1498285a83bde51951541cb1f7a005682ca8b88e7712bccb62a78782e4e72848a8df4b8d4a90564fcc9b0bbaf10c4b9a6f3f5b39b7d38eaf774782d4ae9ee8
7
- data.tar.gz: b7b5d96cbaeb9dee35515acbf592b5496fa38270e3810c241618697a6d683fce5c1009b4d171b9e3fec220a51c1a0ea977aa493418a553012bedc4ff91a03a36
6
+ metadata.gz: 9941a82ddbdaa08ba00955680394614b5f0cb39cf29187be894aadb77d29093cd78a4dd50572f9269e27860a83f0b0c958c756527a6e8acf4a19a7714a686a0f
7
+ data.tar.gz: e00e4f1c0b547d006551df380876e7b8a5a18581ec8450a7bb04719dec24aef8c29e03fb349746968db01fac4b3950fdc2bc8f00b18dd94616297e18aba33d81
@@ -1,3 +1,11 @@
1
+ 0.1.5
2
+ * Moved the release date into the same file as the version so as not to forget to change it along with the version number.
3
+
4
+ 0.1.4
5
+ -----
6
+ * Added a new method 'error_data' which returns a standardized error response.
7
+ This method should only be called when 'call_paypal' returns false.
8
+
1
9
  0.1.3
2
10
  -----
3
11
  * Removed unused parameter from accept_pp_payment.
@@ -152,6 +152,84 @@ public
152
152
  def response
153
153
  if hash.last then PaypkgResponse.new(hash.last) else nil end
154
154
  end
155
+
156
+ # This method collects the response data in such a way as to guarantee
157
+ # valid Ruby stuctures will be generated, i.e., you won't get a
158
+ # runtime error because of nil, etc.
159
+ #
160
+ # It produces 3 outputs:
161
+ # (1) A non-nil error hash
162
+ # {
163
+ # :name => "VALIDATION_ERROR",
164
+ # :details => [
165
+ # {
166
+ # :field => "payer.funding_instruments[0].credit_card.number",
167
+ # :issue => "Value is invalid"
168
+ # },
169
+ # {
170
+ # :field => "payer.funding_instruments[0].credit_card.number",
171
+ # :issue => "Number is crap"
172
+ # }
173
+ # ],
174
+ # :message => "Invalid request - see details",
175
+ # :information_link => "https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR",
176
+ # :debug_id => "88dcf0c1730bb"
177
+ # }
178
+ # (2) A non-nil response object
179
+ # <PaypkgResponse:0x00000001e60040 @name="VALIDATION_ERROR",
180
+ # @details=[
181
+ # <PaypkgResponse:0x00000001e73e10 @field="payer.funding_instruments[0].credit_card.number", @issue="Value is invalid">, \
182
+ # <PaypkgResponse:0x00000001e73988 @field="payer.funding_instruments[0].credit_card.number", @issue="Invalid card type"> \
183
+ # ],
184
+ # @message="Invalid request - see details", \
185
+ # @information_link="https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR", \
186
+ # @debug_id="88dcf0c1730bb"
187
+ # >
188
+ # (3) A non-nil details array
189
+ # [
190
+ # {
191
+ # :field => "payer.funding_instruments[0].credit_card.number",
192
+ # :issue => "Value is invalid"
193
+ # },
194
+ # {
195
+ # :field => "payer.funding_instruments[0].credit_card.number",
196
+ # :issue => "Number is crap"
197
+ # }
198
+ # ]
199
+ def error_data
200
+ conditioned_details = []
201
+ if @hash.last
202
+ conditioned_hash = @hash.last
203
+ # sometimes there's details, sometimes not
204
+ if conditioned_hash.has_key?(:details)
205
+ # process errors
206
+ conditioned_hash[:details].each do |detail|
207
+ conditioned_details << detail
208
+ end
209
+ end
210
+ else
211
+ status = @status.last
212
+ case status[0]
213
+ when '4'
214
+ name = "CLIENT ERROR"
215
+ message = "The request sent to PayPal was invalid"
216
+ when '5'
217
+ name = "SERVER ERROR"
218
+ message = "PayPay's servers had a problem"
219
+ else
220
+ name = "UNKNOWN ERROR"
221
+ message = ""
222
+ end
223
+ conditioned_hash = {
224
+ :name => name,
225
+ :message => "%s. PayPal returned status code %s"%[message,status],
226
+ :information_link => "https://developer.paypal.com/webapps/developer/docs/api",
227
+ :debug_id => "0000000000000"
228
+ }
229
+ end
230
+ conditioned_response = PaypkgResponse.new(conditioned_hash)
231
+ return conditioned_hash, conditioned_response, conditioned_details
232
+ end
155
233
  end
156
234
 
157
235
  # This require loop has to be after the Paypkg class.
@@ -1,3 +1,4 @@
1
1
  module Version
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
+ MODIFIED = "2014-07-22"
3
4
  end
@@ -2,11 +2,10 @@ require_relative File.dirname(__FILE__) + '/lib/paypkg/version'
2
2
  include Version
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'paypkg'
5
- # when changing version, also change the lib/paypkg.rb
6
5
  s.version = VERSION
7
- s.date = '2014-04-22'
6
+ s.date = MODIFIED
8
7
  s.summary = 'Simple PayPal Connection for Ruby'
9
- s.description = "This gem uses Net::HTTP to communicate with the PayPal servers. It has calls for the most common PayPal functions to simplify using PayPal in a Ruby application."
8
+ s.description = "This gem uses Net::HTTP to communicate with the PayPal servers. It has calls for the most common PayPal functions to simplify using PayPal in a Ruby application. I developed this package as a way to call PayPal's REST API with greater transparancy than the paypal-sdk-rest gem has, making development easier. This package can be easily extended by simply adding additional methods (as files) to the lib/paypkg folder. Contributions welcome."
10
9
  s.authors = ["Michael J. Welch, Ph.D."]
11
10
  s.email = 'rubygems@czarmail.com'
12
11
  s.files = Dir.glob(["paypkg.gemspec", "config/paypkg.yml", "CHANGELOG.md", "README.md", "README.html", "lib/paypkg.rb", "lib/paypkg/*", "test/*", "test/paypkg_test/*" ])
metadata CHANGED
@@ -1,17 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypkg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Welch, Ph.D.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem uses Net::HTTP to communicate with the PayPal servers. It has
14
14
  calls for the most common PayPal functions to simplify using PayPal in a Ruby application.
15
+ I developed this package as a way to call PayPal's REST API with greater transparancy
16
+ than the paypal-sdk-rest gem has, making development easier. This package can be
17
+ easily extended by simply adding additional methods (as files) to the lib/paypkg
18
+ folder. Contributions welcome.
15
19
  email: rubygems@czarmail.com
16
20
  executables: []
17
21
  extensions: []