paypal_adaptive 0.3.2 → 0.3.3
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/README.markdown +13 -5
- data/config/paypal_adaptive.yml +4 -4
- data/lib/paypal_adaptive/config.rb +10 -0
- data/lib/paypal_adaptive/request.rb +3 -1
- data/lib/paypal_adaptive/version.rb +1 -1
- data/paypal_adaptive.gemspec +1 -1
- metadata +26 -11
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
94
|
+
api_cert_file: "/path/to/your/private.key"
|
90
95
|
|
91
|
-
The
|
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
|
|
data/config/paypal_adaptive.yml
CHANGED
@@ -4,7 +4,7 @@ development:
|
|
4
4
|
password: "signupforuseratsandboxpaypal"
|
5
5
|
signature: "signupforuseratsandboxpaypal"
|
6
6
|
application_id: "APP-TEST"
|
7
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/paypal_adaptive.gemspec
CHANGED
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.
|
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-
|
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:
|
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:
|
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:
|
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:
|
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:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
|
-
- -
|
51
|
+
- - ! '>='
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0
|
53
|
+
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
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.
|
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
|