paypal-brazil 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIICXgIBAAKBgQDGh5R2Ro3HDe6dsVeq6Pk1nN+BJ0VoV0XtYPc/2MMYSgNyLvXr
3
+ a1PJvAW3YRKQUE7/yDqexBu5IlFnHcmaeYBEJ+r1//lSMryCRAyIslm8ZNkwa+qH
4
+ 29DfHcHm4TNU+Ge0b6akgEFo26hZzd9iFkfEs5p2eR5f6JnzrCCNeK1pgwIDAQAB
5
+ AoGBAKI289K0kXHc62TEG/rVQ5NP67vPB8Ja1RNB0KTFi5uUFj69KklCuAK09ALD
6
+ eXSbegE7bNJ/MJvT86mKyEjFEEyvpupEy7uzqZtWJUWHkDZTN2nyiz+kyRvhzldi
7
+ DlMOA0S3sNF6il94Chjb+F6/b+8d6cd8zi86tN5NJ0RLBiJ5AkEA6RrJxclKjPIb
8
+ GEtQ7W/hvhne2fx+F/mXdUg4TXBzupk9G5fgFpB05NDrLVs8gIJisBf7h/9OQ69B
9
+ Qvps9V4GxwJBANoHbtGQDBZDka1RSOsRubSqRMDWOYiE0KJcGmEdwoOz/zH0YcWI
10
+ iYQRv0k/sGITDAUQW+cqMEd82zME/XR0W2UCQQCgc98FdNwLDq+V1mn7NfMGPpqG
11
+ I+XLrPMTOMYAj/IpNEe60ZzfC0pbIm9vRgjsUFOL8MYjw5nkvyLF7sjHUJSLAkEA
12
+ k0IB7zjDcSYh9lW4UkyeiQ+XcEdAhJxv7bkXeBCJmDqyWiMdBjW566Gw+OAzWYpT
13
+ y/fImtE72ozR4Bu2tDkCoQJAHWVaDrzDANnUP8/xGoPxbWI8lYE+kKpyZtyTOgWm
14
+ mXbXCGjqKRA5HcDMoNmd0+pY/3pXx5VjHOiL2UsKrSnTaQ==
15
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,68 @@
1
+ require "spec_helper"
2
+
3
+ describe Paypal::Helpers::Common do
4
+ include Paypal::Helpers::Common
5
+
6
+ describe ".paypal_setup(item_number, amount, business, options = {})" do
7
+ describe "with default options" do
8
+ before do
9
+ @result = paypal_setup(1, "10.00", "trash@openhood.com")
10
+ end
11
+
12
+ {
13
+ "item_number" => "1",
14
+ "amount" => "10.00",
15
+ "currency_code" => "USD",
16
+ "business" => "trash@openhood.com",
17
+ "cmd" => "_xclick",
18
+ "quantity" => "1",
19
+ "item_number" => "1",
20
+ "item_name" => "Store purchase",
21
+ "no_shipping" => "1",
22
+ "no_note" => "1",
23
+ "charset" => "utf-8"
24
+ }.each do |key, value|
25
+ it "should include #{key} with #{value}" do
26
+ @result.should have_css("input[type=hidden][name=\"#{key}\"][value=\"#{value}\"]")
27
+ end
28
+ end
29
+ end
30
+
31
+ describe "with :enable_encryption set to true" do
32
+ context "with Paypal::Config.business_cert business_key and business_cert_id not set" do
33
+ it "should raise an error" do
34
+ lambda {
35
+ paypal_setup(1, "10.00", "trash@openhood.com", {:enable_encryption => true})
36
+ }.should raise_error ArgumentError, "Paypal::Config.business_key, Paypal::Config.business_cert and Paypal::Config.business_cert_id should be set if you use :enable_encryption"
37
+ end
38
+ end
39
+
40
+ context "with Paypal::Config.business_cert business_key and business_cert_id set" do
41
+ before do
42
+ Paypal::Config.business_cert = File.read(File.expand_path("../../fixtures/business_cert.pem", __FILE__))
43
+ Paypal::Config.business_key = File.read(File.expand_path("../../fixtures/business_key.pem", __FILE__))
44
+ Paypal::Config.business_cert_id = "CERTID"
45
+ @result = paypal_setup(1, "10.00", "trash@openhood.com", {
46
+ :enable_encryption => true
47
+ })
48
+ end
49
+
50
+ it "should include cmd with _s-xclick" do
51
+ @result.should have_css("input[type=hidden][name=cmd][value=_s-xclick]")
52
+ end
53
+ it "should include cmd with encrypted datas" do
54
+ @result.should have_css("input[type=hidden][name=encrypted][value*=PKCS7]")
55
+ @result.should_not have_css("input[type=hidden][name=encrypted][value*='\n']")
56
+ end
57
+ end
58
+ end
59
+
60
+ describe "with unknown options" do
61
+ it "should raise an error" do
62
+ lambda do
63
+ paypal_setup(1, "10.00", "trash@openhood.com", :unknown_option => "unknown")
64
+ end.should raise_error(ArgumentError, "Unknown option #{[:unknown_option].inspect}")
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,148 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Paypal::Notification do
4
+ before do
5
+ Paypal::Config.mode = :sandbox
6
+ end
7
+
8
+ def valid_http_raw_data
9
+ "mc_gross=500.00&address_status=confirmed&payer_id=EVMXCLDZJV77Q&tax=0.00&address_street=164+Waverley+Street&payment_date=15%3A23%3A54+Apr+15%2C+2005+PDT&payment_status=Completed&address_zip=K2P0V6&first_name=Tobias&mc_fee=15.05&address_country_code=CA&address_name=Tobias+Luetke&notify_version=1.7&custom=cusdata&payer_status=unverified&business=tobi%40leetsoft.com&address_country=Canada&address_city=Ottawa&quantity=1&payer_email=tobi%40snowdevil.ca&verify_sign=AEt48rmhLYtkZ9VzOGAtwL7rTGxUAoLNsuf7UewmX7UGvcyC3wfUmzJP&txn_id=6G996328CK404320L&payment_type=instant&last_name=Luetke&address_state=Ontario&receiver_email=tobi%40leetsoft.com&payment_fee=&receiver_id=UQ8PDYXJZQD9Y&txn_type=web_accept&item_name=Store+Purchase&mc_currency=CAD&item_number=&test_ipn=1&payment_gross=&shipping=0.00&invoice=myinvoice&pending_reason=mypending_reason&reason_code=myreason_code&memo=mymemo&payment_type=mypayment_type&exchange_rate=myexchange_rate"
10
+ end
11
+
12
+ def self.valid_parsed_raw_data
13
+ {"payment_gross"=>"", "receiver_id"=>"UQ8PDYXJZQD9Y", "payer_email"=>"tobi@snowdevil.ca", "address_city"=>"Ottawa", "address_country"=>"Canada", "business"=>"tobi@leetsoft.com", "address_name"=>"Tobias Luetke", "payment_status"=>"Completed", "tax"=>"0.00", "reason_code"=>"myreason_code", "receiver_email"=>"tobi@leetsoft.com", "invoice"=>"myinvoice", "verify_sign"=>"AEt48rmhLYtkZ9VzOGAtwL7rTGxUAoLNsuf7UewmX7UGvcyC3wfUmzJP", "address_street"=>"164 Waverley Street", "memo"=>"mymemo", "mc_currency"=>"CAD", "txn_type"=>"web_accept", "quantity"=>"1", "address_zip"=>"K2P0V6", "pending_reason"=>"mypending_reason", "item_name"=>"Store Purchase", "txn_id"=>"6G996328CK404320L", "address_country_code"=>"CA", "payment_fee"=>"", "address_state"=>"Ontario", "payer_status"=>"unverified", "notify_version"=>"1.7", "shipping"=>"0.00", "mc_fee"=>"15.05", "payment_date"=>"15:23:54 Apr 15, 2005 PDT", "address_status"=>"confirmed", "test_ipn"=>"1", "payment_type"=>"mypayment_type", "first_name"=>"Tobias", "last_name"=>"Luetke", "payer_id"=>"EVMXCLDZJV77Q", "mc_gross"=>"500.00", "exchange_rate"=>"myexchange_rate", "item_number"=>"", "custom"=>"cusdata"}
14
+ end
15
+
16
+ describe "without data" do
17
+ it "should raise Paypal::NoDataError" do
18
+ lambda {
19
+ Paypal::Notification.new(nil)
20
+ }.should raise_error(Paypal::NoDataError)
21
+ end
22
+ end
23
+
24
+ describe "with valid raw data" do
25
+ before do
26
+ @notification = Paypal::Notification.new(valid_http_raw_data)
27
+ end
28
+
29
+ it "should store raw data" do
30
+ @notification.raw.should eql(valid_http_raw_data)
31
+ end
32
+
33
+ describe "#params" do
34
+ it "should not be empty" do
35
+ @notification.params.should_not be_empty
36
+ end
37
+
38
+ valid_parsed_raw_data.each do |key, value|
39
+ it "should have #{key}=#{value}" do
40
+ @notification.params[key].should eql(value)
41
+ end
42
+ end
43
+
44
+ it "should have unescaped values" do
45
+ @notification.params["payment_date"].should eql("15:23:54 Apr 15, 2005 PDT")
46
+ end
47
+
48
+ it "should include only the last value for duplicate key" do
49
+ @notification.params["payment_type"].should eql("mypayment_type")
50
+ end
51
+ end
52
+
53
+ it "should define method to access each query params" do
54
+ self.class.valid_parsed_raw_data.each do |key, _|
55
+ lambda {
56
+ @notification.send(key.to_sym)
57
+ }.should_not raise_error
58
+ end
59
+ end
60
+
61
+ ["Canceled_Reversal",
62
+ "Completed",
63
+ "Denied",
64
+ "Expired",
65
+ "Failed",
66
+ "Pending",
67
+ "Processed",
68
+ "Refunded",
69
+ "Reversed",
70
+ "Voided"].each do |status|
71
+ describe "when transaction payment_status = '#{status}'" do
72
+ it "should be #{status.downcase}" do
73
+ old_status, @notification.params["payment_status"] = @notification.params["payment_status"], status
74
+
75
+ @notification.send(:"#{status.downcase}?").should be_true
76
+
77
+ @notification.params["payment_status"] = old_status
78
+ end
79
+ end
80
+ end
81
+
82
+ describe "#acknowledge" do
83
+ before do
84
+ @paypal_validation_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate"
85
+ end
86
+
87
+ it "should send a post request to Paypal at #{@paypal_validation_url}" do
88
+ FakeWeb.register_uri(:post, @paypal_validation_url, :body => 'VERIFIED')
89
+
90
+ lambda { @notification.acknowledge }.should_not raise_error(FakeWeb::NetConnectNotAllowedError)
91
+
92
+ FakeWeb.clean_registry
93
+ end
94
+
95
+ describe "when Paypal response is VERIFIED" do
96
+ before do
97
+ FakeWeb.register_uri(:post, @paypal_validation_url, :body => 'VERIFIED')
98
+ end
99
+
100
+ it "should return true" do
101
+ @notification.acknowledge.should be(true)
102
+ end
103
+
104
+ after do
105
+ FakeWeb.clean_registry
106
+ end
107
+ end
108
+
109
+ describe "when Paypal response is INVALID" do
110
+ before do
111
+ FakeWeb.register_uri(:post, @paypal_validation_url, :body => 'INVALID')
112
+ end
113
+
114
+ it "should return false" do
115
+ @notification.acknowledge.should be(false)
116
+ end
117
+
118
+ after do
119
+ FakeWeb.clean_registry
120
+ end
121
+ end
122
+
123
+ describe "when Paypal response is not a recognize value" do
124
+ before do
125
+ FakeWeb.register_uri(:post, @paypal_validation_url, :body => 'BAD_VALUE')
126
+ end
127
+
128
+ it "should raise StandardError" do
129
+ lambda {
130
+ @notification.acknowledge
131
+ }.should raise_error(StandardError)
132
+ end
133
+
134
+ it "should include body response in StandardError" do
135
+ begin
136
+ @notification.acknowledge
137
+ rescue StandardError => e
138
+ e.message.should =~ /BAD_VALUE/
139
+ end
140
+ end
141
+
142
+ after do
143
+ FakeWeb.clean_registry
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,35 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ require "paypal"
6
+ require "fakeweb"
7
+ require "nokogiri"
8
+ require "rspec"
9
+
10
+ # Do not allow connection to non registered URLs, so we can catch if specifics were called
11
+ FakeWeb.allow_net_connect = false
12
+
13
+ RSpec::Matchers.define :have_css do |css|
14
+ match do |text|
15
+ html = Nokogiri::HTML(text)
16
+ !html.css(css).empty?
17
+ end
18
+
19
+ failure_message_for_should do |text|
20
+ "expected to find css expression #{css} in:\n#{text}"
21
+ end
22
+
23
+ failure_message_for_should_not do |text|
24
+ "expected not to find css expression #{css} in:\n#{text}"
25
+ end
26
+
27
+ description do
28
+ "have css in #{expected}"
29
+ end
30
+ end
31
+
32
+ RSpec.configure do |c|
33
+ c.mock_framework = :rspec
34
+ c.color_enabled = true
35
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paypal-brazil
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
+ prerelease:
6
+ segments:
7
+ - 3
8
+ - 0
9
+ - 2
10
+ version: 3.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Lairton Borges
14
+ - Jonathan TRON
15
+ - Joseph HALTER
16
+ - Tobias LUETKE
17
+ autorequire:
18
+ bindir: bin
19
+ cert_chain: []
20
+
21
+ date: 2012-03-08 00:00:00 Z
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: rack
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 23
32
+ segments:
33
+ - 1
34
+ - 0
35
+ - 0
36
+ version: 1.0.0
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: rspec
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ hash: 23
48
+ segments:
49
+ - 2
50
+ - 6
51
+ - 0
52
+ version: 2.6.0
53
+ type: :development
54
+ version_requirements: *id002
55
+ - !ruby/object:Gem::Dependency
56
+ name: rcov
57
+ prerelease: false
58
+ requirement: &id003 !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 43
64
+ segments:
65
+ - 0
66
+ - 9
67
+ - 8
68
+ version: 0.9.8
69
+ type: :development
70
+ version_requirements: *id003
71
+ - !ruby/object:Gem::Dependency
72
+ name: nokogiri
73
+ prerelease: false
74
+ requirement: &id004 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: bluecloth
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ type: :development
98
+ version_requirements: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ name: yard
101
+ prerelease: false
102
+ requirement: &id006 !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ type: :development
112
+ version_requirements: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ name: fakeweb
115
+ prerelease: false
116
+ requirement: &id007 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ type: :development
126
+ version_requirements: *id007
127
+ description: Paypal Express Integration
128
+ email: ljoseppi@gmail.com
129
+ executables: []
130
+
131
+ extensions: []
132
+
133
+ extra_rdoc_files:
134
+ - LICENSE
135
+ - README.md
136
+ files:
137
+ - .document
138
+ - .gitignore
139
+ - CHANGELOG.md
140
+ - Gemfile
141
+ - Gemfile.lock
142
+ - LICENSE
143
+ - README.md
144
+ - Rakefile
145
+ - lib/paypal.rb
146
+ - lib/paypal/certs/paypal_sandbox.pem
147
+ - lib/paypal/config.rb
148
+ - lib/paypal/helpers/common.rb
149
+ - lib/paypal/helpers/rails.rb
150
+ - lib/paypal/notification.rb
151
+ - lib/paypal/rails.rb
152
+ - lib/paypal/version.rb
153
+ - misc/PayPal - Instant Payment Notification - Technical Overview.pdf
154
+ - misc/multiruby.sh
155
+ - misc/paypal.psd
156
+ - paypal.gemspec
157
+ - spec/config_spec.rb
158
+ - spec/fixtures/business_cert.pem
159
+ - spec/fixtures/business_key.pem
160
+ - spec/helpers/common_spec.rb
161
+ - spec/notification_spec.rb
162
+ - spec/spec_helper.rb
163
+ homepage: https://github.com/ljoseppi/paypal
164
+ licenses: []
165
+
166
+ post_install_message:
167
+ rdoc_options:
168
+ - --charset=UTF-8
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ hash: 3
177
+ segments:
178
+ - 0
179
+ version: "0"
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ hash: 3
186
+ segments:
187
+ - 0
188
+ version: "0"
189
+ requirements: []
190
+
191
+ rubyforge_project:
192
+ rubygems_version: 1.8.10
193
+ signing_key:
194
+ specification_version: 3
195
+ summary: Integrate Paypal Express
196
+ test_files: []
197
+