nimbleshop_paypalwp 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
@@ -71,7 +71,18 @@ module NimbleshopPaypalwp
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def notify_acknowledge
|
74
|
-
|
74
|
+
return true if Rails.env.test?
|
75
|
+
|
76
|
+
# we can mock inpn callback using rake nimbleshop_paypalwp:mock_ipn_callback .
|
77
|
+
# In this case a fixed txn_id is sent all the time and this value is used to determine
|
78
|
+
# that it is indeed a mocked ipn callback. Also for safety this rule is applied only
|
79
|
+
# in development mode
|
80
|
+
if Rails.env.development? && notify.transaction_id == '50L283347C020742B'
|
81
|
+
result = true
|
82
|
+
else
|
83
|
+
result = notify.acknowledge
|
84
|
+
end
|
85
|
+
|
75
86
|
Rails.logger.debug "notify_acknowledge : #{result}"
|
76
87
|
result
|
77
88
|
end
|
@@ -14,14 +14,24 @@ namespace :nimbleshop_paypalwp do
|
|
14
14
|
task mock_ipn_callback: :environment do
|
15
15
|
|
16
16
|
unless order_number = ENV['order_number']
|
17
|
-
|
18
|
-
|
17
|
+
abort %Q{
|
18
|
+
You have not passed order_number. Please pass order_number like this.
|
19
|
+
Usage: rake ipn_callcak order_number=xxxxxxx
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
unless order = Order.find_by_number(order_number)
|
24
|
+
abort %Q{
|
25
|
+
No order was found matching order number #{order_number} . Please try again.
|
26
|
+
}
|
19
27
|
end
|
20
28
|
|
21
29
|
base_url = 'http://localhost:3000'
|
22
30
|
endpoint = base_url + '/nimbleshop_paypalwp/paypalwp/notify'
|
23
31
|
|
24
|
-
|
32
|
+
puts "ipn callback is being sent to #{endpoint}"
|
33
|
+
|
34
|
+
amt = (order.total_amount_in_cents.to_i)/100.00
|
25
35
|
params = {
|
26
36
|
'invoice' => "#{order_number}",
|
27
37
|
'mc_gross' => "#{amt}",
|
@@ -73,5 +83,7 @@ namespace :nimbleshop_paypalwp do
|
|
73
83
|
uri = URI.parse(endpoint)
|
74
84
|
response = Net::HTTP.post_form(uri, params)
|
75
85
|
|
86
|
+
puts response.inspect
|
87
|
+
|
76
88
|
end
|
77
89
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,12 +2,12 @@ require 'bundler'
|
|
2
2
|
Bundler.setup(:test)
|
3
3
|
|
4
4
|
ENV["RAILS_ENV"] = "test"
|
5
|
-
require File.expand_path("
|
5
|
+
require File.expand_path("../../../nimbleshop_core/test/myshop/config/environment.rb", __FILE__)
|
6
6
|
require 'rails/test_help'
|
7
7
|
require 'active_record/fixtures'
|
8
8
|
|
9
9
|
require 'factory_girl'
|
10
|
-
Dir["#{File.dirname(__FILE__)}
|
10
|
+
Dir["#{File.dirname(__FILE__)}/../../nimbleshop_core/test/factories/**"].each { |f| require File.expand_path(f) }
|
11
11
|
|
12
12
|
VCR.configure do | c |
|
13
13
|
c.ignore_hosts '127.0.0.1', 'localhost'
|
@@ -20,7 +20,7 @@ class ActiveSupport::TestCase
|
|
20
20
|
self.use_transactional_fixtures = false
|
21
21
|
setup do
|
22
22
|
DatabaseCleaner.start
|
23
|
-
ActiveRecord::Fixtures.create_fixtures("#{File.dirname(__FILE__)}
|
23
|
+
ActiveRecord::Fixtures.create_fixtures("#{File.dirname(__FILE__)}/../../nimbleshop_core/test/fixtures", ['shops', 'link_groups', 'payment_methods'])
|
24
24
|
end
|
25
25
|
teardown do
|
26
26
|
DatabaseCleaner.clean
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nimbleshop_paypalwp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: valid_email
|
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: -1173890059190686149
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
none: false
|
91
91
|
requirements:
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash:
|
97
|
+
hash: -1173890059190686149
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
100
|
rubygems_version: 1.8.24
|