erp_commerce 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/accepted_credit_card.rb +3 -0
- data/app/models/credit_card_account.rb +30 -7
- data/app/models/extensions/organization.rb +21 -0
- data/app/models/payment.rb +6 -0
- data/db/migrate/20120618144337_create_accepted_credit_cards.rb +11 -0
- data/lib/erp_commerce/extensions/active_record/acts_as_fee.rb +30 -30
- data/lib/erp_commerce/version.rb +1 -1
- metadata +16 -13
@@ -1,6 +1,6 @@
|
|
1
1
|
class CreditCardAccount < ActiveRecord::Base
|
2
2
|
acts_as_biz_txn_account
|
3
|
-
|
3
|
+
|
4
4
|
belongs_to :credit_card_account_purpose
|
5
5
|
has_one :credit_card_account_party_role, :dependent => :destroy
|
6
6
|
has_one :credit_card, :through => :credit_card_account_party_role
|
@@ -31,7 +31,7 @@ class CreditCardAccount < ActiveRecord::Base
|
|
31
31
|
#credit_card_to_use
|
32
32
|
def authorize(financial_txn, cvv, gateway_wrapper, gateway_options={}, credit_card_to_use=nil)
|
33
33
|
credit_card_to_use = self.credit_card unless credit_card_to_use
|
34
|
-
|
34
|
+
|
35
35
|
gateway_options[:debug] = true
|
36
36
|
result = gateway_wrapper.authorize(credit_card_to_use, financial_txn.money.amount, cvv, gateway_options)
|
37
37
|
|
@@ -55,7 +55,7 @@ class CreditCardAccount < ActiveRecord::Base
|
|
55
55
|
#credit_card_to_use
|
56
56
|
def purchase(financial_txn, cvv, gateway_wrapper, gateway_options={}, credit_card_to_use=nil)
|
57
57
|
credit_card_to_use = self.credit_card unless credit_card_to_use
|
58
|
-
|
58
|
+
|
59
59
|
gateway_options[:debug] = true
|
60
60
|
result = gateway_wrapper.purchase(credit_card_to_use, financial_txn.money.amount, cvv, gateway_options)
|
61
61
|
|
@@ -85,11 +85,11 @@ class CreditCardAccount < ActiveRecord::Base
|
|
85
85
|
#only capture this payment if it was authorized
|
86
86
|
if !payment.nil? && payment.current_state.to_sym == :authorized
|
87
87
|
gateway_options[:debug] = true
|
88
|
-
result = gateway_wrapper.capture(credit_card_to_use, payment, cvv,gateway_options)
|
88
|
+
result = gateway_wrapper.capture(credit_card_to_use, payment, cvv, gateway_options)
|
89
89
|
end
|
90
90
|
result
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
#params
|
94
94
|
#financial_txn
|
95
95
|
#cvv
|
@@ -106,7 +106,7 @@ class CreditCardAccount < ActiveRecord::Base
|
|
106
106
|
#only reverse this payment if it was authorized
|
107
107
|
if !payment.nil? && payment.current_state.to_sym == :authorized
|
108
108
|
gateway_options[:debug] = true
|
109
|
-
|
109
|
+
gateway_options[:amount] = financial_txn.money.amount
|
110
110
|
result = gateway_wrapper.full_reverse_of_authorization(credit_card_to_use, payment, cvv, gateway_options)
|
111
111
|
end
|
112
112
|
result
|
@@ -115,9 +115,32 @@ class CreditCardAccount < ActiveRecord::Base
|
|
115
115
|
def void
|
116
116
|
# implement a void transaction of a transaction
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
def refund
|
120
120
|
# implement a refund on a card
|
121
121
|
end
|
122
122
|
|
123
|
+
#params
|
124
|
+
#financial_txn
|
125
|
+
#gateway_wrapper
|
126
|
+
#
|
127
|
+
#Optional
|
128
|
+
#money_amount: amount to refund may be less than amount originally charged, so money_amount param is optional
|
129
|
+
#gateway_options
|
130
|
+
#credit_card_to_use
|
131
|
+
def void_or_return(financial_txn, gateway_wrapper, money_amount = nil, gateway_options={}, credit_card_to_use=nil)
|
132
|
+
credit_card_to_use = self.credit_card unless credit_card_to_use
|
133
|
+
result = {:success => true}
|
134
|
+
|
135
|
+
gateway_options[:debug] = true
|
136
|
+
if money_amount == nil
|
137
|
+
money_amount = financial_txn.money.amount
|
138
|
+
end
|
139
|
+
payment = Payment.where("reference_number = ? and financial_txn_id = ?",gateway_options[:ReferenceNumber], financial_txn.id).order('created_at desc').first
|
140
|
+
gateway_options[:debug] = true
|
141
|
+
result = gateway_wrapper.void_or_return(credit_card_to_use, payment, money_amount, gateway_options)
|
142
|
+
|
143
|
+
result
|
144
|
+
end
|
145
|
+
|
123
146
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Organization.class_eval do
|
2
|
+
has_many :accepted_credit_cards, :dependent => :destroy
|
3
|
+
|
4
|
+
def accepted_ccs_for_select
|
5
|
+
#TODO fix model so the case statement below is no longer necessary
|
6
|
+
accepted_credit_cards = self.accepted_credit_cards
|
7
|
+
accepted_credit_cards_for_select = accepted_credit_cards.collect do |accepted_type|
|
8
|
+
case accepted_type.card_type
|
9
|
+
when "MC"
|
10
|
+
["Mastercard", accepted_type.card_type]
|
11
|
+
when "VS"
|
12
|
+
["Visa", accepted_type.card_type]
|
13
|
+
when "AM"
|
14
|
+
["American Express", accepted_type.card_type]
|
15
|
+
when "DC"
|
16
|
+
["Discover", accepted_type.card_type]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
data/app/models/payment.rb
CHANGED
@@ -14,6 +14,7 @@ class Payment < ActiveRecord::Base
|
|
14
14
|
aasm_state :captured
|
15
15
|
aasm_state :authorization_reversed
|
16
16
|
aasm_state :canceled
|
17
|
+
aasm_state :returned
|
17
18
|
|
18
19
|
aasm_event :cancel do
|
19
20
|
transitions :to => :canceled, :from => [:pending]
|
@@ -38,4 +39,9 @@ class Payment < ActiveRecord::Base
|
|
38
39
|
aasm_event :reverse_authorization do
|
39
40
|
transitions :to => :authorization_reversed, :from => [:authorized]
|
40
41
|
end
|
42
|
+
|
43
|
+
aasm_event :return do
|
44
|
+
transitions :to => :returned, :from => [:captured]
|
45
|
+
end
|
46
|
+
|
41
47
|
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module ErpCommerce
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
base.extend(ClassMethods)
|
2
|
+
module Extensions
|
3
|
+
module ActiveRecord
|
4
|
+
module ActsAsFee
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
module ClassMethods
|
10
|
+
def acts_as_fee
|
11
11
|
extend ActsAsFee::SingletonMethods
|
12
|
-
|
13
|
-
|
12
|
+
include ActsAsFee::InstanceMethods
|
13
|
+
|
14
14
|
after_initialize :new_fee
|
15
15
|
after_update :save_fee
|
16
16
|
after_save :save_fee
|
17
|
-
|
18
|
-
|
17
|
+
after_destroy :destroy_fee
|
18
|
+
|
19
19
|
has_one :fee, :as => :fee_record
|
20
|
-
|
20
|
+
|
21
21
|
#from Fee
|
22
22
|
[ :money, :money=,
|
23
23
|
:fee_type, :fee_type=,
|
@@ -27,21 +27,21 @@ module ErpCommerce
|
|
27
27
|
:external_identifier, :external_identifier=,
|
28
28
|
:external_id_source, :external_id_source=,
|
29
29
|
:created_at,
|
30
|
-
:updated_at
|
30
|
+
:updated_at
|
31
31
|
].each { |m| delegate m, :to => :fee }
|
32
|
-
|
33
|
-
end
|
34
32
|
|
35
|
-
end
|
36
|
-
|
37
|
-
module SingletonMethods
|
38
|
-
end
|
39
|
-
|
40
|
-
module InstanceMethods
|
41
|
-
def fee
|
42
|
-
self.fee
|
43
33
|
end
|
44
34
|
|
35
|
+
end
|
36
|
+
|
37
|
+
module SingletonMethods
|
38
|
+
end
|
39
|
+
|
40
|
+
module InstanceMethods
|
41
|
+
# def fee
|
42
|
+
# self.fee
|
43
|
+
# end
|
44
|
+
|
45
45
|
def new_fee
|
46
46
|
if self.new_record? && self.fee == nil
|
47
47
|
self.fee = Fee.new
|
@@ -49,16 +49,16 @@ module ErpCommerce
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def save_fee
|
52
|
-
|
52
|
+
self.fee.save!
|
53
53
|
end
|
54
54
|
|
55
55
|
def destroy_fee
|
56
56
|
if self.fee && !self.fee.frozen?
|
57
57
|
self.fee.destroy
|
58
58
|
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
59
|
+
end
|
60
|
+
end #End ClassMethods module
|
61
|
+
end #End ActsAsFee module
|
62
|
+
end #End ActiveRecord module
|
63
|
+
end #End Extensions module
|
64
|
+
end #End ErpCommerce module
|
data/lib/erp_commerce/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erp_commerce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
16
|
-
requirement: &
|
16
|
+
requirement: &70240524474380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70240524474380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemerchant
|
27
|
-
requirement: &
|
27
|
+
requirement: &70240524487240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.20.4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70240524487240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: erp_orders
|
38
|
-
requirement: &
|
38
|
+
requirement: &70240524483060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70240524483060
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: prismpay
|
49
|
-
requirement: &
|
49
|
+
requirement: &70240524537320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70240524537320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: erp_dev_svcs
|
60
|
-
requirement: &
|
60
|
+
requirement: &70240524534900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '3.0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70240524534900
|
69
69
|
description: The CompassAE Commerce Engine uses the engines that implement Parties,
|
70
70
|
Products and Orders, and adds the ability to conduct commerce. It implements a pricing
|
71
71
|
engine, fees, payment gateways.
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- app/controllers/erp_commerce/application_controller.rb
|
81
81
|
- app/helpers/erp_commerce/application_helper.rb
|
82
82
|
- app/mailers/checkout_mailer.rb
|
83
|
+
- app/models/accepted_credit_card.rb
|
83
84
|
- app/models/bank_account.rb
|
84
85
|
- app/models/bank_account_type.rb
|
85
86
|
- app/models/credit_card.rb
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- app/models/extensions/currency.rb
|
92
93
|
- app/models/extensions/financial_txn.rb
|
93
94
|
- app/models/extensions/order_txn.rb
|
95
|
+
- app/models/extensions/organization.rb
|
94
96
|
- app/models/extensions/party.rb
|
95
97
|
- app/models/extensions/product_instance.rb
|
96
98
|
- app/models/extensions/product_type.rb
|
@@ -131,6 +133,7 @@ files:
|
|
131
133
|
- db/migrate/20101103132342_pricing_migrations.rb
|
132
134
|
- db/migrate/20110921150854_create_fees.rb
|
133
135
|
- db/migrate/20120308220606_add_external_identifier_to_payments.rb
|
136
|
+
- db/migrate/20120618144337_create_accepted_credit_cards.rb
|
134
137
|
- db/migrate/upgrade/20120117170037_add_bank_account.rb
|
135
138
|
- db/migrate/upgrade/20120117190924_add_credit_card_to_account_roles.rb
|
136
139
|
- lib/erp_commerce/active_merchant_wrappers/bank_wrapper.rb
|
@@ -214,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
217
|
version: '0'
|
215
218
|
requirements: []
|
216
219
|
rubyforge_project:
|
217
|
-
rubygems_version: 1.8.
|
220
|
+
rubygems_version: 1.8.11
|
218
221
|
signing_key:
|
219
222
|
specification_version: 3
|
220
223
|
summary: The CompassAE Commerce Engine uses the engines that implement Parties, Products
|