tonyla-paypal_adaptive 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Tommy Chheng
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,127 @@
1
+ # paypal_adaptive
2
+ This gem is a lightweight wrapper for the paypal adaptive payments API.
3
+
4
+ This is very much a work in progress! Use at your own risk or submit bug fixes :)
5
+
6
+ Before you need start, read the API manual https://www.x.com/docs/DOC-1531 and check out the forums on http://x.com
7
+ It'll be invaluable for parameters and error messages. The gem keeps the request/response as hashes so you will have to
8
+ read the manual to make the proper calls. I made a few test cases for further examples at http://github.com/tc/paypal_adaptive/tree/master/test/
9
+
10
+
11
+ ## HOWTO
12
+ Create paypal_adaptive.yml to your config folder:
13
+
14
+ development:
15
+ environment: "sandbox"
16
+ username: "sandbox_username"
17
+ password: "sandbox_password"
18
+ signature: "sandbox_signature"
19
+ application_id: "sandbox_app_id"
20
+ ssl_cert_file:
21
+
22
+ test:
23
+ environment: "sandbox"
24
+ username: "sandbox_username"
25
+ password: "sandbox_password"
26
+ signature: "sandbox_signature"
27
+ application_id: "sandbox_app_id"
28
+ ssl_cert_file:
29
+
30
+ production:
31
+ environment: "production"
32
+ username: "my_production_username"
33
+ password: "my_production_password"
34
+ signature: "my_production_signature"
35
+ application_id: "my_production_app_id"
36
+ ssl_cert_file:
37
+
38
+ You can also use ENV variables when specifying your configuration. eg.
39
+ ```<%= ENV[''paypal.username'] %>```
40
+
41
+ Make the payment request:
42
+
43
+ pay_request = PaypalAdaptive::Request.new
44
+
45
+ data = {
46
+ "returnUrl" => "http://testserver.com/payments/completed_payment_request",
47
+ "requestEnvelope" => {"errorLanguage" => "en_US"},
48
+ "currencyCode"=>"USD",
49
+ "receiverList"=>{"receiver"=>[{"email"=>"testpp_1261697850_per@nextsprocket.com", "amount"=>"10.00"}]},
50
+ "cancelUrl"=>"http://testserver.com/payments/canceled_payment_request",
51
+ "actionType"=>"PAY",
52
+ "ipnNotificationUrl"=>"http://testserver.com/payments/ipn_notification"
53
+ }
54
+
55
+ pay_response = pay_request.pay(data)
56
+
57
+ if pay_response.success?
58
+ redirect_to pay_response.approve_paypal_payment_url
59
+ else
60
+ puts pay_response.errors.first['message']
61
+ redirect_to failed_payment_url
62
+ end
63
+
64
+ ---
65
+ Once the user goes to pay_response.approve_paypal_payment_url, they will be prompted to login to Paypal for payment.
66
+
67
+ Upon payment completion page, they will be redirected to http://testserver.com/payments/completed_payment_request.
68
+
69
+ They can also click cancel to go to http://testserver.com/payments/canceled_payment_request
70
+
71
+ The actual payment details will be sent to your server via "ipnNotificationUrl"
72
+ You have to create a listener to receive POST messages from paypal. I added a Rails metal template in the templates folder which handles the callback.
73
+
74
+ Additionally, you can make calls to Paypal Adaptive's other APIs:
75
+ payment_details, preapproval, preapproval_details, cancel_preapproval, convert_currency, refund
76
+
77
+ Input is just a Hash just like the pay method. Refer to the Paypal manual for more details.
78
+
79
+ ### Certificate validation
80
+ You can set the location of the .pem file you wish to use for SSL certificate validation in paypal_adaptive.yml
81
+ for each environment, e.g.:
82
+
83
+ development:
84
+ environment: "sandbox"
85
+ username: "sandbox_username"
86
+ password: "sandbox_password"
87
+ signature: "sandbox_signature"
88
+ application_id: "sandbox_app_id"
89
+ ssl_cert_file: "/path/to/your/cacert.pem"
90
+
91
+ If you don't set ssl_cert_file then paypal_adaptive will check for certificates in /etc/ssl/certs if
92
+ this location exists, otherwise falling back to the cacert.pem file included with paypal_adaptive.
93
+
94
+ ## Changelog
95
+ 0.2.2
96
+ Added support for ERB in the config file. Thanks DanielVartanov.
97
+
98
+ 0.2.1
99
+ Fixed SSL bug. Thanks gaelian.
100
+
101
+ 0.2.0
102
+ Thanks to seangaffney for set payment option support.
103
+ Thanks to gaelian for ssl cert support.
104
+ Changed tests to use relative paths.
105
+
106
+ 0.1.0
107
+ Fixed IPN rails metal template by sending the correct params back: ipn.send_back(env['rack.request.form_vars'])
108
+ Thanks to github.com/JoN1oP for fixing this.
109
+
110
+ 0.0.5
111
+ Added Preapproval preapproval_paypal_payment_url along with test case.
112
+
113
+ 0.0.4
114
+ Preapproval now returns a PaypalAdaptive::Response class. Added preapproval test cases.
115
+
116
+ 0.0.3
117
+ Renamed PayRequest, PayResponse into Request, Response since other api calls use the class as well.
118
+
119
+ 0.0.2
120
+ Fixed initialized constant warning.
121
+
122
+ 0.0.1
123
+ First release.
124
+
125
+ ## Copyright
126
+
127
+ Copyright (c) 2009 Tommy Chheng. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'psych'
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+
6
+ begin
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = "paypal_adaptive"
10
+ gem.summary = %Q{initial import}
11
+ gem.description = %Q{Lightweight wrapper for Paypal's Adaptive Payments API.}
12
+ gem.email = "tommy.chheng@gmail.com"
13
+ gem.homepage = "http://github.com/tc/paypal_adaptive"
14
+ gem.authors = ["Tommy Chheng"]
15
+ gem.add_development_dependency "json", ">= 0"
16
+ gem.add_development_dependency "jsonschema", ">= 0"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ begin
25
+ require 'rcov/rcovtask'
26
+ Rcov::RcovTask.new do |test|
27
+ test.libs << 'test'
28
+ test.pattern = 'test/**/test_*.rb'
29
+ test.verbose = true
30
+ end
31
+ rescue LoadError
32
+ task :rcov do
33
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
34
+ end
35
+ end
36
+
37
+ task :default => :test
38
+
39
+ task :test => %w(test:units)
40
+ namespace :test do
41
+ desc "run unit tests"
42
+ Rake::TestTask.new(:units) do |test|
43
+ test.libs << 'lib' << 'test'
44
+ test.test_files = FileList["test/unit/*_test.rb", "test/unit/*/*_test.rb"]
45
+ end
46
+ end
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "paypal_adaptive #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2