nimbleshop_paypalwp 0.0.5 → 0.0.7
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/app/controllers/nimbleshop_paypalwp/paypalwps_controller.rb +5 -1
- data/app/helpers/nimbleshop_paypalwp/exposed_helper.rb +3 -3
- data/lib/nimbleshop_paypalwp.rb +2 -0
- data/test/test_helper.rb +32 -0
- data/test/unit/payment_method_test.rb +17 -0
- data/test/unit/processor_test.rb +40 -0
- metadata +20 -23
@@ -1,5 +1,9 @@
|
|
1
1
|
module NimbleshopPaypalwp
|
2
|
-
|
2
|
+
|
3
|
+
# this line makes it possible to use this gem without nimbleshop_core
|
4
|
+
klass = defined?(::Admin::PaymentMethodsController) ? ::Admin::PaymentMethodsController : ActionController::Base
|
5
|
+
|
6
|
+
class PaypalwpsController < klass
|
3
7
|
|
4
8
|
protect_from_forgery except: :notify
|
5
9
|
|
@@ -53,15 +53,15 @@ module NimbleshopPaypalwp
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def nimbleshop_paypalwp_notify_url
|
56
|
-
Util.localhost2public_url( '/nimbleshop_paypalwp/paypalwp/notify', nimbleshop_paypalwp_protocol )
|
56
|
+
Nimbleshop::Util.localhost2public_url( '/nimbleshop_paypalwp/paypalwp/notify', nimbleshop_paypalwp_protocol )
|
57
57
|
end
|
58
58
|
|
59
59
|
def nimbleshop_paypalwp_return_url(order)
|
60
|
-
Util.localhost2public_url( order_path(id: order.number), nimbleshop_paypalwp_protocol )
|
60
|
+
Nimbleshop::Util.localhost2public_url( order_path(id: order.number), nimbleshop_paypalwp_protocol )
|
61
61
|
end
|
62
62
|
|
63
63
|
def nimbleshop_paypalwp_cancel_url(order)
|
64
|
-
Util.localhost2public_url( new_checkout_payment_path, nimbleshop_paypalwp_protocol )
|
64
|
+
Nimbleshop::Util.localhost2public_url( new_checkout_payment_path, nimbleshop_paypalwp_protocol )
|
65
65
|
end
|
66
66
|
|
67
67
|
def nimbleshop_paypalwp_protocol
|
data/lib/nimbleshop_paypalwp.rb
CHANGED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup(:test)
|
3
|
+
|
4
|
+
ENV["RAILS_ENV"] = "test"
|
5
|
+
require File.expand_path("../../../../nimbleshop_core/test/myshop/config/environment.rb", __FILE__)
|
6
|
+
require 'rails/test_help'
|
7
|
+
require 'active_record/fixtures'
|
8
|
+
|
9
|
+
require 'factory_girl'
|
10
|
+
Dir["#{File.dirname(__FILE__)}/../../../nimbleshop_core/test/factories/**"].each { |f| require File.expand_path(f) }
|
11
|
+
|
12
|
+
VCR.configure do | c |
|
13
|
+
c.ignore_hosts '127.0.0.1', 'localhost'
|
14
|
+
c.cassette_library_dir = 'test/vcr_cassettes'
|
15
|
+
c.hook_into :webmock # or :fakeweb
|
16
|
+
end
|
17
|
+
|
18
|
+
class ActiveSupport::TestCase
|
19
|
+
include FactoryGirl::Syntax::Methods
|
20
|
+
self.use_transactional_fixtures = false
|
21
|
+
setup do
|
22
|
+
DatabaseCleaner.start
|
23
|
+
ActiveRecord::Fixtures.create_fixtures("#{File.dirname(__FILE__)}/../../../nimbleshop_core/test/fixtures", ['shops', 'link_groups', 'payment_methods'])
|
24
|
+
end
|
25
|
+
teardown do
|
26
|
+
DatabaseCleaner.clean
|
27
|
+
end
|
28
|
+
|
29
|
+
def playcasette(casette)
|
30
|
+
VCR.use_cassette(casette) { yield }
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PaymentMethodPaypalwpTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "validations" do
|
6
|
+
pm = NimbleshopPaypalwp::Paypalwp.new(name: 'Paypalwp', description: 'this is description')
|
7
|
+
refute pm.valid?
|
8
|
+
assert_equal ["Merchant email can't be blank", "Merchant email is invalid"], pm.errors.full_messages.sort
|
9
|
+
end
|
10
|
+
|
11
|
+
test "should save the record" do
|
12
|
+
pm = NimbleshopPaypalwp::Paypalwp.new(name: 'Paypalwp', merchant_email: 'merchant@example.com', description: 'this is description')
|
13
|
+
assert pm.save
|
14
|
+
assert_match /paypalwp/, pm.permalink
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Processor
|
4
|
+
class PaypalAuthorizeTest < ActiveRecord::TestCase
|
5
|
+
def raw1
|
6
|
+
"mc_gross=152.73&invoice=54145619&protection_eligibility=Ineligible&item_number1=&payer_id=Q96HQCW3NMN8A&tax=1.73&payment_date=19%3A48%3A59+Apr+22%2C+2012+PDT&payment_status=Completed&charset=windows-1252&mc_shipping=0.00&mc_handling=10.00&first_name=buyer&mc_fee=4.73¬ify_version=3.4&custom=&payer_status=verified&business=seller_1323037155_biz%40bigbinary.com&num_cart_items=1&mc_handling1=0.00&verify_sign=AAmQuqWvZCTtQW5vSunjl6MYb9xfACAPVvn0EpIPnon.Cyn5sYgI-bZB&payer_email=nimble_1333550340_per%40hotmail.com&mc_shipping1=0.00&tax1=0.00&txn_id=2LY704674J0179216&payment_type=instant&last_name=again&item_name1=Colorful+shoes&receiver_email=seller_1323037155_biz%40bigbinary.com&payment_fee=4.73&quantity1=1&receiver_id=EULE94DW3YTH4&txn_type=cart&mc_gross_1=141.00&mc_currency=USD&residence_country=US&test_ipn=1&transaction_subject=Shopping+CartColorful+shoes&payment_gross=152.73&ipn_track_id=72a7efbc940b7"
|
7
|
+
end
|
8
|
+
|
9
|
+
def raw_post(order_id, total)
|
10
|
+
"mc_gross=#{total}&invoice=#{order_id}&protection_eligibility=Ineligible&item_number1=&payer_id=UU9QTKRET6CCA&tax=0.23&payment_date=13%3A46%3A50+Apr+01%2C+2012+PDT&payment_status=Completed&charset=windows-1252&mc_shipping=0.00&mc_handling=0.00&first_name=venkata&mc_fee=0.63¬ify_version=3.4&custom=&payer_status=verified&business=pvdsub_1332777111_biz%40hotmail.com&num_cart_items=1&mc_handling1=0.00&verify_sign=A97HaEBl1Z9n6y3FnK2ES7ntmCFAA42qVBV1tGxSqeM5XnO3fijruk.r&payer_email=pvdsub_1332813592_per%40hotmail.com&mc_shipping1=0.00&tax1=0.00&txn_id=48D08257JB6543456&payment_type=instant&last_name=pasupuleti&item_name1=Handmade+vibrant+bangles&receiver_email=pvdsub_1332777111_biz%40hotmail.com&payment_fee=0.63&quantity1=1&receiver_id=DT54LCN8WQM8S&txn_type=cart&mc_gross_1=11.00&mc_currency=USD&residence_country=US&test_ipn=1&transaction_subject=Shopping+CartHandmade+vibrant+bangles&payment_gross=11.23&ipn_track_id=b1f9dd1a56ae8"
|
11
|
+
end
|
12
|
+
|
13
|
+
setup do
|
14
|
+
@order = create(:order)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "when authorization succeeds" do
|
18
|
+
processor = NimbleshopPaypalwp::Processor.new(raw_post: raw_post(@order.number, @order.total_amount))
|
19
|
+
playcasette('paypal/authorize-success') do
|
20
|
+
assert_equal true, processor.authorize
|
21
|
+
end
|
22
|
+
|
23
|
+
@order.reload
|
24
|
+
|
25
|
+
transaction = @order.payment_transactions.last
|
26
|
+
assert_equal 'authorized', transaction.operation
|
27
|
+
assert_equal true, transaction.success
|
28
|
+
assert_equal true, @order.authorized?
|
29
|
+
assert_equal "April 01, 2012 at 08:46 pm", @order.purchased_at.to_s(:long)
|
30
|
+
assert_equal NimbleshopPaypalwp::Paypalwp.first, @order.payment_method
|
31
|
+
assert_equal transaction.amount, @order.total_amount_in_cents
|
32
|
+
end
|
33
|
+
|
34
|
+
test "when authorization fails" do
|
35
|
+
processor = NimbleshopPaypalwp::Processor.new(raw_post: raw_post(@order.number, 10.48))
|
36
|
+
assert_equal false, processor.authorize
|
37
|
+
assert_nil @order.payment_method
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,32 +1,33 @@
|
|
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.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Neeraj Singh
|
9
|
+
- megpha
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
+
date: 2012-08-10 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: activemerchant
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
|
-
- -
|
20
|
+
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
+
version: 1.26.0
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
27
|
requirements:
|
27
|
-
- -
|
28
|
+
- - ~>
|
28
29
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
+
version: 1.26.0
|
30
31
|
- !ruby/object:Gem::Dependency
|
31
32
|
name: valid_email
|
32
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,22 +60,6 @@ dependencies:
|
|
59
60
|
- - ! '>='
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: nimbleshop_core
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - '='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.0.5
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - '='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.0.5
|
78
63
|
description: Provides Paypal web payments standard support to nimbleshop
|
79
64
|
email:
|
80
65
|
- neeraj@bigbinary.com
|
@@ -99,6 +84,9 @@ files:
|
|
99
84
|
- lib/tasks/nimbleshop_paypalwp_mock_ipn_callback.rake
|
100
85
|
- lib/tasks/nimbleshop_paypalwp_tasks.rake
|
101
86
|
- README.md
|
87
|
+
- test/test_helper.rb
|
88
|
+
- test/unit/payment_method_test.rb
|
89
|
+
- test/unit/processor_test.rb
|
102
90
|
homepage: http://nimbleShop.org
|
103
91
|
licenses: []
|
104
92
|
post_install_message:
|
@@ -111,16 +99,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
99
|
- - ! '>='
|
112
100
|
- !ruby/object:Gem::Version
|
113
101
|
version: '0'
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
hash: -1607684565895269224
|
114
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
106
|
none: false
|
116
107
|
requirements:
|
117
108
|
- - ! '>='
|
118
109
|
- !ruby/object:Gem::Version
|
119
110
|
version: '0'
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
hash: -1607684565895269224
|
120
114
|
requirements: []
|
121
115
|
rubyforge_project:
|
122
116
|
rubygems_version: 1.8.24
|
123
117
|
signing_key:
|
124
118
|
specification_version: 3
|
125
119
|
summary: Paypal WPS extension for nimbleshop
|
126
|
-
test_files:
|
120
|
+
test_files:
|
121
|
+
- test/test_helper.rb
|
122
|
+
- test/unit/payment_method_test.rb
|
123
|
+
- test/unit/processor_test.rb
|