Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rromanchuk/paypal_adaptive
base: a3853ca163
...
head fork: rromanchuk/paypal_adaptive
compare: c92dbc5cde
  • 6 commits
  • 4 files changed
  • 0 commit comments
  • 3 contributors
Commits on Nov 28, 2011
@nbibler nbibler Add error message collection to preapproval payment failures f3af0de
@nbibler nbibler Collect preapproval payment failure messages 1ace37c
Commits on Dec 05, 2011
@rromanchuk fix fatal in http.rb because of the call to strip on a Fixnum from pa…
…ypal_adaptive.yml having an integer as the password
50ea782
@rromanchuk remove extra param cf5eaef
Commits on Dec 07, 2011
@tc tc Merge pull request #31 from rromanchuk/fixnum-fatal
fix fatal in http.rb because of the call to strip on a Fixnum
3e94637
@tc tc Merge pull request #30 from nbibler/payment_errors
Collect and return Preapproval payment errors
c92dbc5
View
3  lib/paypal_adaptive/config.rb
@@ -42,6 +42,9 @@ def load(environment, config_override)
@ssl_cert_file = nil
@paypal_base_url = PAYPAL_BASE_URL_MAPPING[pp_env]
@api_base_url = API_BASE_URL_MAPPING[pp_env]
+
+ # http.rb requires headers to be strings. Protect against ints in paypal_adaptive.yml
+ config.update(config){ |key,v| v.to_s }
@headers = {
"X-PAYPAL-SECURITY-USERID" => config['username'],
"X-PAYPAL-SECURITY-PASSWORD" => config['password'],
View
10 lib/paypal_adaptive/response.rb
@@ -16,16 +16,14 @@ def errors
if success?
return []
else
- self['error']
+ errors = self['error']
+ errors ||= self['payErrorList']['payError'].collect { |e| e['error'] } rescue nil
+ errors
end
end
def error_message
- if success?
- return nil
- else
- self['error'].first['message'] rescue nil
- end
+ message = errors.first['message'] rescue nil
end
def approve_paypal_payment_url(type=nil)
View
22 test/data/invalid_preapproval_payment.json
@@ -0,0 +1,22 @@
+{
+ "responseEnvelope":{
+ "timestamp":"2011-11-28T08:02:09.070-08:00",
+ "ack":"Success",
+ "correlationId":"XXXXXXXXXXXXX",
+ "build":"2279004"},
+ "payKey":"XX-XXXXXXXXXXXXXXXXX",
+ "paymentExecStatus":"ERROR",
+ "payErrorList":{
+ "payError":[{
+ "receiver":{
+ "amount":"25.0",
+ "email":"test@test.test"},
+ "error":{
+ "errorId":"580036",
+ "domain":"PLATFORM",
+ "severity":"Error",
+ "category":"Application",
+ "message":"This transaction cannot be processed. Please enter a valid credit card number and type"}
+ }]
+ }
+}
View
12 test/unit/preapproval_test.rb
@@ -48,6 +48,18 @@ def test_invalid_preapproval_with_bad_credit_information
assert pp_response.success? == false
end
+ def test_erred_preapproval_payment_message
+ puts "-------"
+ puts "invalid"
+ data_filepath = File.join(File.dirname(__FILE__),"..", "data","invalid_preapproval_payment.json")
+
+ data = read_json_file(data_filepath)
+ pp_response = @preapproval_request.preapproval(data)
+ puts "error message is #{pp_response.error_message}"
+
+ assert pp_response.error_message == "This transaction cannot be processed. Please enter a valid credit card number and type"
+ end
+
def read_json_file(filepath)
File.open(filepath, "rb"){|f| JSON.parse(f.read)}
end

No commit comments for this range

Something went wrong with that request. Please try again.