nimbleshop_authorizedotnet 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/app/helpers/nimbleshop_authorizedotnet/exposed_helper.rb +2 -2
- data/app/models/nimbleshop_authorizedotnet/authorizedotnet.rb +3 -2
- data/app/views/nimbleshop_authorizedotnet/authorizedotnets/_edit.html.erb +3 -4
- data/lib/nimbleshop_authorizedotnet.rb +0 -1
- data/lib/nimbleshop_authorizedotnet/processor.rb +5 -2
- data/test/unit/payment_method_test.rb +16 -0
- data/test/unit/processor_test.rb +2 -0
- metadata +4 -5
- data/lib/nimbleshop_authorizedotnet/util.rb +0 -31
data/README.md
CHANGED
@@ -34,4 +34,4 @@ Documentation is available at [http://nimbleshop.org/authorizedotnet.html](http:
|
|
34
34
|
|
35
35
|
# License
|
36
36
|
|
37
|
-
|
37
|
+
This gem uses [MIT license](http://www.opensource.org/licenses/mit-license.php) .
|
@@ -11,7 +11,7 @@ module NimbleshopAuthorizedotnet
|
|
11
11
|
image_tag 'engines/nimbleshop_authorizedotnet/authorizedotnet_small.png', alt: 'authorizedotnet icon'
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def nimbleshop_authorizedotnet_picture_on_admin_payment_methods
|
15
15
|
image_tag 'engines/nimbleshop_authorizedotnet/authorizedotnet_big.png', alt: 'authorizedotnet logo'
|
16
16
|
end
|
17
17
|
|
@@ -38,7 +38,7 @@ module NimbleshopAuthorizedotnet
|
|
38
38
|
|
39
39
|
def nimbleshop_authorizedotnet_payment_form(order)
|
40
40
|
return unless NimbleshopAuthorizedotnet::Authorizedotnet.first
|
41
|
-
render partial: '/nimbleshop_authorizedotnet/payments/new', locals: {order: order}
|
41
|
+
render partial: '/nimbleshop_authorizedotnet/payments/new', locals: { order: order }
|
42
42
|
end
|
43
43
|
|
44
44
|
def nimbleshop_authorizedotnet_crud_form
|
@@ -15,8 +15,9 @@ module NimbleshopAuthorizedotnet
|
|
15
15
|
self.ssl == 'enabled'
|
16
16
|
end
|
17
17
|
|
18
|
-
def kapture!(order)
|
19
|
-
|
18
|
+
def kapture!(order, processor_klass = nil)
|
19
|
+
processor_klass ||= NimbleshopAuthorizedotnet::Processor
|
20
|
+
processor = processor_klass.new(order: order, payment_method: self)
|
20
21
|
processor.kapture
|
21
22
|
order.kapture!
|
22
23
|
end
|
@@ -10,12 +10,11 @@
|
|
10
10
|
<% end %>
|
11
11
|
</div>
|
12
12
|
|
13
|
-
<%=
|
13
|
+
<%= nimbleshop_authorizedotnet_picture_on_admin_payment_methods %>
|
14
14
|
|
15
15
|
<div class='clear'></div>
|
16
16
|
</div>
|
17
17
|
|
18
|
-
|
19
18
|
<%= render partial: '/nimbleshop_authorizedotnet/authorizedotnets/form' %>
|
20
19
|
</div>
|
21
20
|
|
@@ -23,9 +22,9 @@
|
|
23
22
|
$(function(){
|
24
23
|
|
25
24
|
$('#nimbleshop-authorizedotnet-payment-method-edit').toggle(function(){
|
26
|
-
$('#nimbleshop-authorizedotnet-form-well').show();
|
25
|
+
$('#nimbleshop-authorizedotnet-form-well').show();
|
27
26
|
}, function(){
|
28
|
-
$('#nimbleshop-authorizedotnet-form-well').hide();
|
27
|
+
$('#nimbleshop-authorizedotnet-form-well').hide();
|
29
28
|
});
|
30
29
|
|
31
30
|
})
|
@@ -36,7 +36,7 @@ module NimbleshopAuthorizedotnet
|
|
36
36
|
return false
|
37
37
|
end
|
38
38
|
|
39
|
-
response = gateway.authorize(order.total_amount_in_cents, creditcard,
|
39
|
+
response = gateway.authorize(order.total_amount_in_cents, creditcard, ::Nimbleshop::PaymentUtil.activemerchant_options(order))
|
40
40
|
record_transaction(response, 'authorized', card_number: creditcard.display_number, cardtype: creditcard.cardtype)
|
41
41
|
|
42
42
|
if response.success?
|
@@ -95,7 +95,10 @@ module NimbleshopAuthorizedotnet
|
|
95
95
|
tsx_id = options[:transaction_gid]
|
96
96
|
|
97
97
|
response = gateway.capture(order.total_amount_in_cents, tsx_id, {})
|
98
|
-
|
98
|
+
|
99
|
+
pt = PaymentTransaction.find_by_transaction_gid! tsx_id
|
100
|
+
#record_transaction(response, 'captured')
|
101
|
+
record_transaction(response, 'captured', card_number: pt.metadata[:card_number], cardtype: pt.metadata[:cardtype])
|
99
102
|
|
100
103
|
if response.success?
|
101
104
|
order.kapture
|
@@ -19,3 +19,19 @@ class PaymentMethodAuthorizeNetTest < ActiveSupport::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
22
|
+
|
23
|
+
|
24
|
+
class PaymentMethodAuthorizeNetKaptureTest < ActiveSupport::TestCase
|
25
|
+
setup do
|
26
|
+
class HackedProcessor < NimbleshopAuthorizedotnet::Processor
|
27
|
+
def kapture(*args); end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
test '#kapture!' do
|
32
|
+
order = create :order_paid_using_authorizedotnet
|
33
|
+
adnt = NimbleshopAuthorizedotnet::Authorizedotnet.new(name: 'Authorize.net', description: 'this is description')
|
34
|
+
adnt.kapture!(order, HackedProcessor)
|
35
|
+
assert_equal 'purchased', order.payment_status
|
36
|
+
end
|
37
|
+
end
|
data/test/unit/processor_test.rb
CHANGED
@@ -77,6 +77,8 @@ module Processor
|
|
77
77
|
transaction = @order.payment_transactions.last
|
78
78
|
assert_equal 'captured', transaction.operation
|
79
79
|
assert_equal true, transaction.success
|
80
|
+
assert_equal "XXXX-XXXX-XXXX-0027", transaction.metadata[:card_number]
|
81
|
+
assert_equal 'visa', transaction.metadata[:cardtype]
|
80
82
|
assert @order.purchased?
|
81
83
|
end
|
82
84
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nimbleshop_authorizedotnet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
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-08-
|
13
|
+
date: 2012-08-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemerchant
|
@@ -56,7 +56,6 @@ files:
|
|
56
56
|
- lib/nimbleshop_authorizedotnet/engine.rb
|
57
57
|
- lib/nimbleshop_authorizedotnet/gateway.rb
|
58
58
|
- lib/nimbleshop_authorizedotnet/processor.rb
|
59
|
-
- lib/nimbleshop_authorizedotnet/util.rb
|
60
59
|
- lib/nimbleshop_authorizedotnet.rb
|
61
60
|
- lib/tasks/nimbleshop_authorizedotnet_tasks.rake
|
62
61
|
- README.md
|
@@ -88,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
87
|
version: '0'
|
89
88
|
segments:
|
90
89
|
- 0
|
91
|
-
hash:
|
90
|
+
hash: 4574169439669715898
|
92
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
92
|
none: false
|
94
93
|
requirements:
|
@@ -97,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
96
|
version: '0'
|
98
97
|
segments:
|
99
98
|
- 0
|
100
|
-
hash:
|
99
|
+
hash: 4574169439669715898
|
101
100
|
requirements: []
|
102
101
|
rubyforge_project:
|
103
102
|
rubygems_version: 1.8.24
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module NimbleshopAuthorizedotnet
|
2
|
-
module Util
|
3
|
-
extend self
|
4
|
-
|
5
|
-
def billing_address(order)
|
6
|
-
{ address1: order.real_billing_address.address1,
|
7
|
-
city: order.real_billing_address.city,
|
8
|
-
state: order.real_billing_address.state_name,
|
9
|
-
country: order.real_billing_address.country_name,
|
10
|
-
zip: order.real_billing_address.zipcode }
|
11
|
-
end
|
12
|
-
|
13
|
-
def shipping_address(order)
|
14
|
-
{ first_name: order.shipping_address.first_name,
|
15
|
-
last_name: order.shipping_address.last_name,
|
16
|
-
address1: order.shipping_address.address1,
|
17
|
-
city: order.shipping_address.city,
|
18
|
-
state: order.shipping_address.state_name,
|
19
|
-
country: order.shipping_address.country_name,
|
20
|
-
zip: order.shipping_address.zipcode }
|
21
|
-
end
|
22
|
-
|
23
|
-
# In this method am stands for activemerchant
|
24
|
-
def am_options(order)
|
25
|
-
billing_address = { billing_address: billing_address(order) }
|
26
|
-
shipping_address = { shipping_address: shipping_address(order) }
|
27
|
-
misc = { order_id: order.number, email: order.email }
|
28
|
-
billing_address.merge(shipping_address).merge(misc)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|