erp_commerce 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/GPL-3-LICENSE +0 -0
- data/README.md +13 -0
- data/app/mailers/checkout_mailer.rb +9 -0
- data/app/models/bank_account.rb +87 -0
- data/app/models/bank_account_type.rb +3 -0
- data/app/models/credit_card.rb +21 -6
- data/app/models/credit_card_account.rb +119 -0
- data/app/models/credit_card_account_party_role.rb +2 -4
- data/app/models/credit_card_account_purpose.rb +0 -0
- data/app/models/credit_card_token.rb +0 -0
- data/app/models/extensions/charge_line.rb +0 -0
- data/app/models/extensions/currency.rb +0 -0
- data/app/models/extensions/financial_txn.rb +2 -1
- data/app/models/extensions/order_txn.rb +0 -0
- data/app/models/extensions/party.rb +37 -3
- data/app/models/extensions/product_instance.rb +0 -0
- data/app/models/extensions/product_type.rb +0 -0
- data/app/models/fee.rb +0 -0
- data/app/models/fee_type.rb +0 -0
- data/app/models/payment.rb +8 -5
- data/app/models/payment_gateway.rb +0 -0
- data/app/models/payment_gateway_action.rb +0 -0
- data/app/models/price.rb +0 -0
- data/app/models/price_component.rb +0 -0
- data/app/models/price_component_type.rb +0 -0
- data/app/models/pricing_plan.rb +0 -0
- data/app/models/pricing_plan_assignment.rb +0 -0
- data/app/models/pricing_plan_component.rb +0 -0
- data/app/models/valid_price_plan_component.rb +0 -0
- data/app/views/checkout_mailer/email_confirmation.html.erb +15 -0
- data/app/widgets/orders/base.rb +2 -6
- data/app/widgets/orders/javascript/orders.js +0 -0
- data/app/widgets/orders/views/index.html.erb +0 -0
- data/app/widgets/product_catalog/base.rb +0 -4
- data/app/widgets/product_catalog/javascript/product_catalog.js +0 -0
- data/app/widgets/product_catalog/views/add_to_cart.html.erb +0 -0
- data/app/widgets/product_catalog/views/index.html.erb +0 -0
- data/app/widgets/product_catalog/views/show.html.erb +0 -0
- data/app/widgets/shopping_cart/base.rb +2 -5
- data/app/widgets/shopping_cart/javascript/shopping_cart.js +0 -0
- data/app/widgets/shopping_cart/views/cart_items.html.erb +0 -0
- data/app/widgets/shopping_cart/views/confirmation.html.erb +1 -0
- data/app/widgets/shopping_cart/views/demographics.html.erb +0 -0
- data/app/widgets/shopping_cart/views/login.html.erb +0 -0
- data/app/widgets/shopping_cart/views/payment.html.erb +0 -0
- data/app/widgets/shopping_cart/views/price_summary.html.erb +0 -0
- data/db/data_migrations/20101011152441_payment_gateway_actions.rb +0 -0
- data/db/migrate/20100823174238_erp_commerce_base.rb +50 -25
- data/db/migrate/20100913154134_setup_payments.rb +0 -0
- data/db/migrate/20101103132342_pricing_migrations.rb +0 -0
- data/db/migrate/20120308220606_add_external_identifier_to_payments.rb +5 -0
- data/db/migrate/upgrade/20120117170037_add_bank_account.rb +34 -0
- data/db/migrate/upgrade/20120117190924_add_credit_card_to_account_roles.rb +7 -0
- data/lib/erp_commerce/active_merchant_wrappers/bank_wrapper.rb +17 -0
- data/lib/erp_commerce/active_merchant_wrappers/brain_tree_gateway_wrapper.rb +20 -18
- data/lib/erp_commerce/active_merchant_wrappers/credit_card_validation.rb +0 -0
- data/lib/erp_commerce/active_merchant_wrappers/prismpay_wrapper.rb +108 -0
- data/lib/erp_commerce/active_merchant_wrappers.rb +3 -2
- data/lib/erp_commerce/config.rb +30 -0
- data/lib/erp_commerce/engine.rb +10 -0
- data/lib/erp_commerce/extensions/active_record/acts_as_fee.rb +0 -0
- data/lib/erp_commerce/extensions/active_record/acts_as_priceable.rb +0 -0
- data/lib/erp_commerce/order_helper.rb +10 -19
- data/lib/erp_commerce/version.rb +7 -1
- data/lib/erp_commerce.rb +2 -0
- data/spec/dummy/Rakefile +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -0
- data/spec/dummy/config/application.rb +0 -0
- data/spec/dummy/config/boot.rb +0 -0
- data/spec/dummy/config/database.yml +0 -0
- data/spec/dummy/config/environment.rb +0 -0
- data/spec/dummy/config/environments/spec.rb +0 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/inflections.rb +0 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -0
- data/spec/dummy/config/initializers/secret_token.rb +0 -0
- data/spec/dummy/config/initializers/session_store.rb +0 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/spec/dummy/config/locales/en.yml +0 -0
- data/spec/dummy/config/routes.rb +0 -0
- data/spec/dummy/config.ru +0 -0
- data/spec/dummy/public/404.html +0 -0
- data/spec/dummy/public/422.html +0 -0
- data/spec/dummy/public/500.html +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -0
- data/spec/factories/basic.rb +5 -0
- data/spec/models/credit_card_account_party_role_spec.rb +0 -0
- data/spec/models/credit_card_account_purpose_spec.rb +0 -0
- data/spec/models/credit_card_account_spec.rb +0 -0
- data/spec/models/credit_card_spec.rb +0 -0
- data/spec/models/fee_spec.rb +0 -0
- data/spec/models/fee_type_spec.rb +0 -0
- data/spec/models/payment_gateway_action_spec.rb +0 -0
- data/spec/models/payment_gateway_spec.rb +0 -0
- data/spec/models/payment_spec.rb +0 -0
- data/spec/models/price_component_spec.rb +0 -0
- data/spec/models/price_component_type_spec.rb +0 -0
- data/spec/models/price_spec.rb +0 -0
- data/spec/models/pricing_plan_assignment_spec.rb +0 -0
- data/spec/models/pricing_plan_component_spec.rb +0 -0
- data/spec/models/pricing_plan_spec.rb +0 -0
- data/spec/models/valid_price_plan_component_spec.rb +0 -0
- metadata +164 -141
- data/README.rdoc +0 -2
@@ -2,7 +2,7 @@ class ErpCommerceBase < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
3
3
|
#tables
|
4
4
|
unless table_exists?(:credit_cards)
|
5
|
-
|
5
|
+
create_table :credit_cards do |t|
|
6
6
|
|
7
7
|
t.column :crypted_private_card_number, :string
|
8
8
|
t.column :expiration_month, :integer
|
@@ -14,7 +14,6 @@ class ErpCommerceBase < ActiveRecord::Migration
|
|
14
14
|
t.column :card_type, :string
|
15
15
|
|
16
16
|
t.column :postal_address_id, :integer
|
17
|
-
t.column :credit_card_account_party_role_id, :integer
|
18
17
|
t.column :credit_card_account_purpose_id, :integer
|
19
18
|
t.column :credit_card_token, :string
|
20
19
|
|
@@ -30,47 +29,71 @@ class ErpCommerceBase < ActiveRecord::Migration
|
|
30
29
|
end
|
31
30
|
|
32
31
|
unless table_exists?(:credit_card_account_party_roles)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
create_table :credit_card_account_party_roles do |t|
|
33
|
+
t.column :credit_card_account_id, :integer
|
34
|
+
t.column :role_type_id, :integer
|
35
|
+
t.column :party_id, :integer
|
36
|
+
t.column :credit_card_id, :integer
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
t.timestamps
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
add_index :credit_card_account_party_roles, :credit_card_account_id
|
42
|
+
add_index :credit_card_account_party_roles, :role_type_id
|
43
|
+
add_index :credit_card_account_party_roles, :party_id
|
44
|
+
add_index :credit_card_account_party_roles, :credit_card_id
|
44
45
|
end
|
45
46
|
|
46
47
|
unless table_exists?(:credit_card_account_purposes)
|
47
|
-
|
48
|
+
create_table :credit_card_account_purposes do |t|
|
49
|
+
|
50
|
+
t.column :parent_id, :integer
|
51
|
+
t.column :lft, :integer
|
52
|
+
t.column :rgt, :integer
|
53
|
+
|
54
|
+
#custom columns go here
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
t.column :rgt, :integer
|
56
|
+
t.column :description, :string
|
57
|
+
t.column :comments, :string
|
52
58
|
|
53
|
-
|
59
|
+
t.column :internal_identifier, :string
|
60
|
+
t.column :external_identifier, :string
|
61
|
+
t.column :external_id_source, :string
|
62
|
+
|
63
|
+
t.timestamps
|
64
|
+
end
|
65
|
+
end
|
54
66
|
|
55
|
-
|
56
|
-
|
67
|
+
unless table_exists?(:bank_account_types)
|
68
|
+
create_table :bank_account_types do |t|
|
69
|
+
t.string :description
|
70
|
+
t.string :internal_identifier
|
57
71
|
|
58
|
-
|
59
|
-
|
60
|
-
|
72
|
+
t.timestamps
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
unless table_exists?(:bank_accounts)
|
77
|
+
create_table :bank_accounts do |t|
|
78
|
+
t.string :routing_number
|
79
|
+
t.string :crypted_private_account_number
|
80
|
+
t.string :name_on_account
|
81
|
+
t.references :bank_account_type
|
82
|
+
|
83
|
+
t.timestamps
|
84
|
+
end
|
61
85
|
|
62
|
-
|
63
|
-
end
|
86
|
+
add_index :bank_accounts, :bank_account_type_id, :name => 'bank_accounts_account_type_idx'
|
64
87
|
end
|
65
88
|
#end tables
|
66
89
|
|
67
90
|
#columns
|
68
91
|
unless columns(:order_txns).collect {|c| c.name}.include?('payment_gateway_txn_id')
|
69
|
-
|
92
|
+
add_column :order_txns, :payment_gateway_txn_id, :string
|
70
93
|
end
|
71
94
|
|
72
95
|
unless columns(:order_txns).collect {|c| c.name}.include?('credit_card_id')
|
73
|
-
|
96
|
+
add_column :order_txns, :credit_card_id, :integer
|
74
97
|
end
|
75
98
|
|
76
99
|
unless columns(:order_txns).collect {|c| c.name}.include?('bill_to_first_name')
|
@@ -159,6 +182,8 @@ class ErpCommerceBase < ActiveRecord::Migration
|
|
159
182
|
|
160
183
|
#tables
|
161
184
|
drop_tables = [
|
185
|
+
:bank_account_types,
|
186
|
+
:bank_accounts,
|
162
187
|
:credit_cards,
|
163
188
|
:credit_card_accounts,
|
164
189
|
:credit_card_account_party_roles,
|
File without changes
|
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class AddBankAccount < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?(:bank_account_types)
|
4
|
+
create_table :bank_account_types do |t|
|
5
|
+
t.string :description
|
6
|
+
t.string :internal_identifier
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
unless table_exists?(:bank_accounts)
|
13
|
+
create_table :bank_accounts do |t|
|
14
|
+
t.string :routing_number
|
15
|
+
t.string :crypted_private_account_number
|
16
|
+
t.string :name_on_account
|
17
|
+
t.references :bank_account_type
|
18
|
+
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
|
22
|
+
add_index :bank_accounts, :bank_account_type_id, :name => 'bank_accounts_account_type_idx'
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def down
|
28
|
+
[:bank_account_types, :bank_accounts].each do |tbl|
|
29
|
+
if table_exists?(tbl)
|
30
|
+
drop_table tbl
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ErpCommerce
|
2
|
+
module ActiveMerchantWrappers
|
3
|
+
class BankWrapper
|
4
|
+
def self.purchase(account_number, routing_number, amount)
|
5
|
+
result = {}
|
6
|
+
|
7
|
+
result[:message] = "Payment applied"
|
8
|
+
result[:payment] = Payment.create
|
9
|
+
result[:payment].authorization_code = '123456789'
|
10
|
+
result[:payment].success = true
|
11
|
+
#result[:payment].purchase
|
12
|
+
|
13
|
+
result
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -4,29 +4,31 @@ module ErpCommerce
|
|
4
4
|
module ActiveMerchantWrappers
|
5
5
|
class BrainTreeGatewayWrapper
|
6
6
|
|
7
|
-
def self.purchase(
|
7
|
+
def self.purchase(credit_card, amount, cvv, gateway_options={})
|
8
8
|
result = {}
|
9
|
-
|
10
|
-
#
|
9
|
+
|
10
|
+
#this needs config options
|
11
|
+
gateway_options.merge!({:login => 'demo', :password => 'password'})
|
12
|
+
|
11
13
|
ActiveMerchant::Billing::Base.mode = :test
|
12
14
|
|
13
15
|
#setup gateway
|
14
16
|
gateway = ActiveMerchant::Billing::BraintreeGateway.new(gateway_options)
|
15
17
|
|
16
18
|
#set credit card info
|
17
|
-
|
18
|
-
:first_name =>
|
19
|
-
:last_name =>
|
20
|
-
:number =>
|
21
|
-
:month =>
|
22
|
-
:year =>
|
23
|
-
:verification_value =>
|
24
|
-
:type => ErpCommerce::ActiveMerchantWrappers::CreditCardValidation.get_card_type(
|
19
|
+
credit_card_result = ActiveMerchant::Billing::CreditCard.new({
|
20
|
+
:first_name => credit_card.first_name_on_card,
|
21
|
+
:last_name => credit_card.last_name_on_card,
|
22
|
+
:number => credit_card.private_card_number,
|
23
|
+
:month => credit_card.expiration_month,
|
24
|
+
:year => credit_card.expiration_year,
|
25
|
+
:verification_value => cvv,
|
26
|
+
:type => ErpCommerce::ActiveMerchantWrappers::CreditCardValidation.get_card_type(credit_card.private_card_number)
|
25
27
|
})
|
26
28
|
|
27
|
-
if
|
28
|
-
cents = (
|
29
|
-
response = gateway.purchase(cents,
|
29
|
+
if credit_card_result.valid?
|
30
|
+
cents = (amount.to_f * 100)
|
31
|
+
response = gateway.purchase(cents, credit_card_result)
|
30
32
|
|
31
33
|
if response.success?
|
32
34
|
result[:message] = response.message
|
@@ -50,7 +52,7 @@ module ErpCommerce
|
|
50
52
|
result[:payment].save
|
51
53
|
else
|
52
54
|
result[:message] = "<ul>"
|
53
|
-
|
55
|
+
credit_card_result.errors.full_messages.each do |current_notice_msg|
|
54
56
|
result[:message] << "<li>"
|
55
57
|
result[:message] << current_notice_msg
|
56
58
|
result[:message] << "</li>"
|
@@ -61,6 +63,6 @@ module ErpCommerce
|
|
61
63
|
result
|
62
64
|
end
|
63
65
|
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
66
|
+
end#BrainTreeGatewayWrapper
|
67
|
+
end#ActiveMerchantWrappers
|
68
|
+
end#ErpCommerce
|
File without changes
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'prismpay'
|
2
|
+
require 'prismpay_am'
|
3
|
+
require 'active_merchant'
|
4
|
+
|
5
|
+
module ErpCommerce
|
6
|
+
module ActiveMerchantWrappers
|
7
|
+
class PrismPayWrapper
|
8
|
+
|
9
|
+
def self.authorize(credit_card, amount, cvv, gateway_options ={})
|
10
|
+
# same as purchase
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.capture(credit_card, payment, cvv, gw_options ={})
|
14
|
+
# payment.external_identifier
|
15
|
+
# payment.financial_txn.money.amount
|
16
|
+
# payment.authorization_code
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.void()
|
20
|
+
# payment.external_identifier
|
21
|
+
# payment.financial_txn.money.amount
|
22
|
+
# payment.authorization_code
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.refund()
|
26
|
+
# payment.external_identifier
|
27
|
+
# payment.financial_txn.money.amount
|
28
|
+
# payment.authorization_code
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.profile_sale(profile_id, amount, last_four, gw_options = {})
|
32
|
+
# conducts a profile_sale transaction
|
33
|
+
|
34
|
+
result = {}
|
35
|
+
|
36
|
+
gw_options.merge!({:login => 'TEST0'}) unless gw_options[:login]
|
37
|
+
|
38
|
+
# ActiveMerchant::Billing:Base.mode = :test
|
39
|
+
|
40
|
+
gatway = ActiveMerchant::Billing::PrismPayAM.new(gw_options)
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.purchase(credit_card, amount, cvv, gateway_options={})
|
46
|
+
# returns a hash with the possible parameters of :message and
|
47
|
+
# :payment ... if a credit card error occurs it returns with
|
48
|
+
# just :message set
|
49
|
+
result = {}
|
50
|
+
|
51
|
+
#this needs config options
|
52
|
+
gateway_options.merge!({:login => 'TEST0'}) unless gateway_options
|
53
|
+
|
54
|
+
# ActiveMerchant::Billing::Base.mode = :test
|
55
|
+
|
56
|
+
#setup gateway
|
57
|
+
gateway = ActiveMerchant::Billing::PrismPayAM.new(gateway_options)
|
58
|
+
|
59
|
+
#set credit card info
|
60
|
+
credit_card_result = ActiveMerchant::Billing::CreditCard.new({
|
61
|
+
:first_name => credit_card.first_name_on_card,
|
62
|
+
:last_name => credit_card.last_name_on_card,
|
63
|
+
:number => credit_card.private_card_number,
|
64
|
+
:month => credit_card.expiration_month,
|
65
|
+
:year => credit_card.expiration_year,
|
66
|
+
:verification_value => cvv,
|
67
|
+
:type => ErpCommerce::ActiveMerchantWrappers::CreditCardValidation.get_card_type(credit_card.private_card_number)
|
68
|
+
})
|
69
|
+
|
70
|
+
if credit_card_result.valid?
|
71
|
+
response = gateway.purchase(amount, credit_card_result)
|
72
|
+
|
73
|
+
if response.success?
|
74
|
+
result[:message] = response.message
|
75
|
+
result[:payment] = Payment.new
|
76
|
+
result[:payment].authorization_code = response.authorization
|
77
|
+
result[:payment].success = true
|
78
|
+
result[:payment].purchase
|
79
|
+
else
|
80
|
+
result[:message] = response.message
|
81
|
+
result[:payment] = Payment.new
|
82
|
+
result[:payment].success = false
|
83
|
+
result[:payment].decline
|
84
|
+
end
|
85
|
+
|
86
|
+
gateway = PaymentGateway.create(
|
87
|
+
:response => response.message,
|
88
|
+
:payment_gateway_action => PaymentGatewayAction.find_by_internal_identifier('authorize')
|
89
|
+
)
|
90
|
+
|
91
|
+
result[:payment].payment_gateways << gateway
|
92
|
+
result[:payment].save
|
93
|
+
else
|
94
|
+
result[:message] = "<ul>"
|
95
|
+
credit_card_result.errors.full_messages.each do |current_notice_msg|
|
96
|
+
result[:message] << "<li>"
|
97
|
+
result[:message] << current_notice_msg
|
98
|
+
result[:message] << "</li>"
|
99
|
+
end
|
100
|
+
result[:message] << "<ul>"
|
101
|
+
end
|
102
|
+
|
103
|
+
result
|
104
|
+
end
|
105
|
+
|
106
|
+
end#PrismPayWrapper
|
107
|
+
end#ActiveMerchantWrappers
|
108
|
+
end#ErpCommerce
|
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
Dir.glob("#{File.dirname(__FILE__)}/active_merchant_wrappers/**/*.rb").each do |file|
|
2
|
+
require "erp_commerce/active_merchant_wrappers/#{File.basename(file)}"
|
3
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ErpCommerce
|
2
|
+
module Config
|
3
|
+
class << self
|
4
|
+
attr_accessor :encryption_key, :active_merchant_gateway_wrapper
|
5
|
+
|
6
|
+
def init!
|
7
|
+
@defaults = {
|
8
|
+
:@encryption_key => 'my_secret_code',
|
9
|
+
:@active_merchant_gateway_wrapper => ErpCommerce::ActiveMerchantWrappers::BrainTreeGatewayWrapper
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def reset!
|
14
|
+
@defaults.each do |k,v|
|
15
|
+
instance_variable_set(k,v)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure(&blk)
|
20
|
+
@configure_blk = blk
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure!
|
24
|
+
@configure_blk.call(self) if @configure_blk
|
25
|
+
end
|
26
|
+
end
|
27
|
+
init!
|
28
|
+
reset!
|
29
|
+
end
|
30
|
+
end
|
data/lib/erp_commerce/engine.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module ErpCommerce
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
isolate_namespace ErpCommerce
|
4
|
+
|
5
|
+
config.erp_commerce = ErpCommerce::Config
|
4
6
|
|
5
7
|
initializer "erp_commerce.merge_public" do |app|
|
6
8
|
app.middleware.insert_before Rack::Lock, ::ActionDispatch::Static, "#{root}/public"
|
@@ -10,6 +12,14 @@ module ErpCommerce
|
|
10
12
|
include ErpCommerce::Extensions::ActiveRecord::ActsAsFee
|
11
13
|
include ErpCommerce::Extensions::ActiveRecord::ActsAsPriceable
|
12
14
|
end
|
15
|
+
|
16
|
+
#TODO
|
17
|
+
#this will be removed once rails 3.2 adds the ability to set the order of engine loading
|
18
|
+
engine = self
|
19
|
+
config.to_prepare do
|
20
|
+
ErpBaseErpSvcs.register_compass_ae_engine(engine)
|
21
|
+
::ErpApp::Widgets::Loader.load_compass_ae_widgets(engine)
|
22
|
+
end
|
13
23
|
|
14
24
|
end#Engine
|
15
25
|
end#ErpCommerce
|
File without changes
|
File without changes
|
@@ -141,12 +141,16 @@ module ErpCommerce
|
|
141
141
|
#make credit financial txns and payment txns
|
142
142
|
#create financial txn for order
|
143
143
|
financial_txn = create_financial_txns(order)
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
|
145
|
+
credit_card = CreditCard.new(
|
146
|
+
:first_name_on_card => params[:first_name],
|
147
|
+
:last_name_on_card => params[:last_name],
|
148
|
+
:expiration_month => params[:exp_month],
|
149
|
+
:expiration_year => params[:exp_year]
|
149
150
|
)
|
151
|
+
credit_card.card_number = params[:card_number]
|
152
|
+
result = CreditCardAccount.new.purchase(financial_txn, params[:cvvs], ErpCommerce::Config.active_merchant_gateway_wrapper, {}, credit_card)
|
153
|
+
|
150
154
|
#make sure cedit card payment was successful
|
151
155
|
if result[:payment].nil? or !result[:payment].success
|
152
156
|
success = false
|
@@ -170,7 +174,7 @@ module ErpCommerce
|
|
170
174
|
end
|
171
175
|
|
172
176
|
order.save
|
173
|
-
return success, message, order
|
177
|
+
return success, message, order, result[:payment]
|
174
178
|
end
|
175
179
|
|
176
180
|
#remove line item
|
@@ -237,18 +241,5 @@ module ErpCommerce
|
|
237
241
|
financial_txn
|
238
242
|
end
|
239
243
|
|
240
|
-
def build_credit_card_hash(params)
|
241
|
-
credit_card = {}
|
242
|
-
|
243
|
-
credit_card[:number] = params[:card_number]
|
244
|
-
credit_card[:exp_month] = params[:exp_month]
|
245
|
-
credit_card[:exp_year] = params[:exp_year]
|
246
|
-
credit_card[:cvvs] = params[:cvvs]
|
247
|
-
credit_card[:first_name] = params[:first_name]
|
248
|
-
credit_card[:last_name] = params[:last_name]
|
249
|
-
|
250
|
-
credit_card
|
251
|
-
end
|
252
|
-
|
253
244
|
end#ErpCommerce
|
254
245
|
end#OrderHelper
|
data/lib/erp_commerce/version.rb
CHANGED
data/lib/erp_commerce.rb
CHANGED
data/spec/dummy/Rakefile
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/dummy/config/boot.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/dummy/config/routes.rb
CHANGED
File without changes
|
data/spec/dummy/config.ru
CHANGED
File without changes
|
data/spec/dummy/public/404.html
CHANGED
File without changes
|
data/spec/dummy/public/422.html
CHANGED
File without changes
|
data/spec/dummy/public/500.html
CHANGED
File without changes
|
File without changes
|
data/spec/dummy/script/rails
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/models/fee_spec.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/models/payment_spec.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/spec/models/price_spec.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|