paypal_adaptive 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -91,6 +91,9 @@ for each environment, e.g.:
91
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.
92
92
 
93
93
  ## Changelog
94
+ 0.3.2
95
+ Added support to api certificate since ssl_cert_file config is now used to set CA Authority. thanks jimbocortes
96
+
94
97
  0.3.1
95
98
  Update json dependency to use ~>1.0 so any version 1.X will work.
96
99
 
@@ -15,7 +15,7 @@ module PaypalAdaptive
15
15
  :beta_sandbox => "https://svcs.beta-sandbox.paypal.com"
16
16
  } unless defined? API_BASE_URL_MAPPING
17
17
 
18
- attr_accessor :paypal_base_url, :api_base_url, :headers, :ssl_cert_path, :ssl_cert_file
18
+ attr_accessor :paypal_base_url, :api_base_url, :headers, :ssl_cert_path, :ssl_cert_file, :api_cert_file
19
19
 
20
20
  def initialize(env=nil, config_override={})
21
21
  config = YAML.load(ERB.new(File.new(config_filepath).read).result)[env]
@@ -29,6 +29,7 @@ module PaypalAdaptive
29
29
 
30
30
  @ssl_cert_path = nil
31
31
  @ssl_cert_file = nil
32
+ @api_cert_file = nil
32
33
  @paypal_base_url = PAYPAL_BASE_URL_MAPPING[pp_env]
33
34
  @api_base_url = API_BASE_URL_MAPPING[pp_env]
34
35
 
@@ -42,8 +43,9 @@ module PaypalAdaptive
42
43
  "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON"
43
44
  }
44
45
  @headers.merge!({"X-PAYPAL-SECURITY-SIGNATURE" => config['signature']}) if config['signature']
45
-
46
+ @ssl_cert_path = config['ssl_cert_path'] unless config['ssl_cert_path'].blank?
46
47
  @ssl_cert_file = config['ssl_cert_file'] unless config['ssl_cert_file'].blank?
48
+ @api_cert_file = config['api_cert_file'] unless config['api_cert_file'].blank?
47
49
  end
48
50
  end
49
51
 
@@ -10,6 +10,7 @@ module PaypalAdaptive
10
10
  @paypal_base_url = config.paypal_base_url
11
11
  @ssl_cert_path = config.ssl_cert_path
12
12
  @ssl_cert_file = config.ssl_cert_file
13
+ @api_cert_file = config.api_cert_file
13
14
  end
14
15
 
15
16
  def send_back(data)
@@ -20,12 +21,13 @@ module PaypalAdaptive
20
21
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
21
22
  http.ca_path = @ssl_cert_path unless @ssl_cert_path.nil?
22
23
 
23
- if @ssl_cert_file
24
- # cert = File.read(@ssl_cert_file)
25
- # http.cert = OpenSSL::X509::Certificate.new(cert)
26
- # http.key = OpenSSL::PKey::RSA.new(cert)
27
- http.ca_file = @ssl_cert_file
24
+ if @api_cert_file
25
+ cert = File.read(@api_cert_file)
26
+ http.cert = OpenSSL::X509::Certificate.new(cert)
27
+ http.key = OpenSSL::PKey::RSA.new(cert)
28
28
  end
29
+ http.ca_path = @ssl_cert_path unless @ssl_cert_path.blank?
30
+ http.ca_file = @ssl_cert_file unless @ssl_cert_file.blank?
29
31
 
30
32
  path = "#{@paypal_base_url}/cgi-bin/webscr"
31
33
  response_data = http.post(path, data).body
@@ -14,6 +14,7 @@ module PaypalAdaptive
14
14
  @headers = config.headers
15
15
  @ssl_cert_path = config.ssl_cert_path
16
16
  @ssl_cert_file = config.ssl_cert_file
17
+ @api_cert_file = config.api_cert_file
17
18
  end
18
19
 
19
20
  def validate
@@ -91,13 +92,13 @@ module PaypalAdaptive
91
92
  http.use_ssl = true
92
93
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
93
94
 
94
- if @ssl_cert_file
95
- #cert = File.read(@ssl_cert_file)
96
- #http.cert = OpenSSL::X509::Certificate.new(cert)
97
- #http.key = OpenSSL::PKey::RSA.new(cert)
98
- http.ca_file = @ssl_cert_file
95
+ if @api_cert_file
96
+ cert = File.read(@api_cert_file)
97
+ http.cert = OpenSSL::X509::Certificate.new(cert)
98
+ http.key = OpenSSL::PKey::RSA.new(cert)
99
99
  end
100
- http.ca_path = @ssl_cert_path unless @ssl_cert_path.nil?
100
+ http.ca_path = @ssl_cert_path unless @ssl_cert_path.blank?
101
+ http.ca_file = @ssl_cert_file unless @ssl_cert_file.blank?
101
102
 
102
103
  begin
103
104
  response_data = http.post(path, api_request_data, @headers)
@@ -1,4 +1,4 @@
1
1
  module PaypalAdaptive
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
4
4
 
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.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70345696753460 !ruby/object:Gem::Requirement
16
+ requirement: &70212142494100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70345696753460
24
+ version_requirements: *70212142494100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jsonschema
27
- requirement: &70345696752780 !ruby/object:Gem::Requirement
27
+ requirement: &70212142493220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70345696752780
35
+ version_requirements: *70212142493220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70345696752060 !ruby/object:Gem::Requirement
38
+ requirement: &70212142492480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0.8'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70345696752060
46
+ version_requirements: *70212142492480
47
47
  description: Lightweight wrapper for Paypal's Adaptive Payments API
48
48
  email:
49
49
  - tommy.chheng@gmail.com