paypal_adaptive 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -17,7 +17,7 @@ Create paypal_adaptive.yml to your config folder:
17
17
  password: "sandbox_password"
18
18
  signature: "sandbox_signature"
19
19
  application_id: "sandbox_app_id"
20
- ssl_cert_file:
20
+ api_cert_file:
21
21
 
22
22
  test:
23
23
  environment: "sandbox"
@@ -25,7 +25,7 @@ Create paypal_adaptive.yml to your config folder:
25
25
  password: "sandbox_password"
26
26
  signature: "sandbox_signature"
27
27
  application_id: "sandbox_app_id"
28
- ssl_cert_file:
28
+ api_cert_file: "/path/to_cert"
29
29
 
30
30
  production:
31
31
  environment: "production"
@@ -33,7 +33,7 @@ Create paypal_adaptive.yml to your config folder:
33
33
  password: "my_production_password"
34
34
  signature: "my_production_signature"
35
35
  application_id: "my_production_app_id"
36
- ssl_cert_file:
36
+ api_cert_file: "/path/to_cert"
37
37
 
38
38
  You can also use ENV variables when specifying your configuration. eg.
39
39
  ```<%= ENV[''paypal.username'] %>```
@@ -76,6 +76,11 @@ Additionally, you can make calls to Paypal Adaptive's other APIs:
76
76
 
77
77
  Input is just a Hash just like the pay method. Refer to the Paypal manual for more details.
78
78
 
79
+ ### Using the embedded payment flow
80
+ Instead of redirecting to the url from ```redirect_to pay_response.approve_paypal_payment_url``` you can generate the action url for your
81
+ form by using ```pay_response.approve_paypal_payment_url 'MY TYPE' ``` The two types that are supported for embedded payment are 'light' and 'mini'
82
+ More information about these types can be found here https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APIntro
83
+
79
84
  ### Certificate validation
80
85
  You can set the location of the key file you downloaded from PayPal, in paypal_adaptive.yml
81
86
  for each environment, e.g.:
@@ -86,11 +91,14 @@ for each environment, e.g.:
86
91
  password: "sandbox_password"
87
92
  signature: "sandbox_signature"
88
93
  application_id: "sandbox_app_id"
89
- ssl_cert_file: "/path/to/your/private.key"
94
+ api_cert_file: "/path/to/your/private.key"
90
95
 
91
- The ssl_cert_file should point to your cert_key_pem.txt that is downloaded through the paypal developer interface. It will contain a section that specifies the RSA private key and another section that specifies a certificate. If this is left empty, paypal_adaptive will attempt to use the signature method of validation with PayPal, so your signature config must not be nil.
96
+ The api_cert_file should point to your cert_key_pem.txt that is downloaded through the paypal developer interface. It will contain a section that specifies the RSA private key and another section that specifies a certificate. If this is left empty, paypal_adaptive will attempt to use the signature method of validation with PayPal, so your signature config must not be nil.
92
97
 
93
98
  ## Changelog
99
+ 0.3.3
100
+ Handle JSON parsing error. Added validation for config.
101
+
94
102
  0.3.2
95
103
  Added support to api certificate since ssl_cert_file config is now used to set CA Authority. thanks jimbocortes
96
104
 
@@ -4,7 +4,7 @@ development:
4
4
  password: "signupforuseratsandboxpaypal"
5
5
  signature: "signupforuseratsandboxpaypal"
6
6
  application_id: "APP-TEST"
7
- ssl_cert_file:
7
+ api_cert_file: "/path/to_cert"
8
8
 
9
9
  test:
10
10
  environment: "sandbox"
@@ -12,7 +12,7 @@ test:
12
12
  password: "signupforuseratsandboxpaypal"
13
13
  signature: "signupforuseratsandboxpaypal"
14
14
  application_id: "APP-TEST"
15
- ssl_cert_file:
15
+ api_cert_file: "/path/to_cert"
16
16
 
17
17
  production:
18
18
  environment: "production"
@@ -20,7 +20,7 @@ production:
20
20
  password: "my_production_password"
21
21
  signature: "my_production_signature"
22
22
  application_id: "my_production_app_id"
23
- ssl_cert_file:
23
+ api_cert_file: "/path/to_cert"
24
24
 
25
25
  with_erb_tags:
26
26
  environment: "sandbox"
@@ -28,4 +28,4 @@ with_erb_tags:
28
28
  password: <%= ENV['paypal.password'] %>
29
29
  signature: "signupforuseratsandboxpaypal"
30
30
  application_id: "APP-TEST"
31
- ssl_cert_file:
31
+ api_cert_file: "/path/to_cert"
@@ -22,6 +22,8 @@ module PaypalAdaptive
22
22
  raise "Could not load settings from config file" unless config
23
23
  config.merge!(config_override) unless config_override.nil?
24
24
 
25
+ validate_config(config)
26
+
25
27
  if config["retain_requests_for_test"] == true
26
28
  @retain_requests_for_test = true
27
29
  else
@@ -49,6 +51,14 @@ module PaypalAdaptive
49
51
  end
50
52
  end
51
53
 
54
+ def validate_config(config)
55
+ raise "No username in paypal_adaptive.yml specified." unless config['username']
56
+ raise "No password in paypal_adaptive.yml specified." unless config['password']
57
+ raise "No application_id in paypal_adaptive.yml specified." unless config['application_id']
58
+
59
+ true
60
+ end
61
+
52
62
  def config_filepath
53
63
  if defined?(Rails)
54
64
  Rails.root.join("config", "paypal_adaptive.yml")
@@ -102,9 +102,11 @@ module PaypalAdaptive
102
102
 
103
103
  begin
104
104
  response_data = http.post(path, api_request_data, @headers)
105
- return JSON.parse(response_data.body)
105
+ JSON.parse(response_data.body)
106
106
  rescue Net::HTTPBadGateway => e
107
107
  rescue_error_message(e, "Error reading from remote server.")
108
+ rescue JSON::ParserError => e
109
+ rescue_error_message(e, "Response is not in JSON format.")
108
110
  rescue Exception => e
109
111
  case e
110
112
  when Errno::ECONNRESET
@@ -1,4 +1,4 @@
1
1
  module PaypalAdaptive
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
4
4
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency("json", "~>1.0")
16
16
  s.add_dependency("jsonschema", "~>2.0.0")
17
- s.add_dependency("rake", "~>0.8")
17
+ s.add_dependency("rake")
18
18
 
19
19
  s.rubyforge_project = "paypal_adaptive"
20
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal_adaptive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-14 00:00:00.000000000 Z
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70212142494100 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70212142494100
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: jsonschema
27
- requirement: &70212142493220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,18 +37,28 @@ dependencies:
32
37
  version: 2.0.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70212142493220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.0.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &70212142492480 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
- - - ~>
51
+ - - ! '>='
42
52
  - !ruby/object:Gem::Version
43
- version: '0.8'
53
+ version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70212142492480
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  description: Lightweight wrapper for Paypal's Adaptive Payments API
48
63
  email:
49
64
  - tommy.chheng@gmail.com
@@ -112,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
127
  version: '0'
113
128
  requirements: []
114
129
  rubyforge_project: paypal_adaptive
115
- rubygems_version: 1.8.15
130
+ rubygems_version: 1.8.24
116
131
  signing_key:
117
132
  specification_version: 3
118
133
  summary: Lightweight wrapper for Paypal's Adaptive Payments API