workarea-forter 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +20 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +63 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +25 -0
- data/LICENSE +52 -0
- data/LICENSE.md +3 -0
- data/README.md +113 -0
- data/Rakefile +60 -0
- data/app/controllers/workarea/admin/orders_controller.decorator +6 -0
- data/app/controllers/workarea/storefront/application_controller.decorator +10 -0
- data/app/models/search/admin/order.decorator +7 -0
- data/app/models/workarea/checkout/collect_payment.decorator +75 -0
- data/app/models/workarea/forter/decision.rb +18 -0
- data/app/models/workarea/forter/response.rb +15 -0
- data/app/models/workarea/fulfillment.decorator +77 -0
- data/app/models/workarea/order/status/suspected_fraud.rb +13 -0
- data/app/models/workarea/order.decorator +14 -0
- data/app/models/workarea/payment/saved_credit_card.decorator +14 -0
- data/app/models/workarea/payment/status/suspected_fraud.rb +13 -0
- data/app/models/workarea/payment/tender/credit_card.decorator +25 -0
- data/app/models/workarea/payment.decorator +13 -0
- data/app/services/workarea/forter/account.rb +42 -0
- data/app/services/workarea/forter/order.rb +145 -0
- data/app/services/workarea/forter/payment.rb +80 -0
- data/app/services/workarea/forter/tender/credit_card.rb +73 -0
- data/app/services/workarea/forter/tender/general.rb +29 -0
- data/app/services/workarea/forter/tender/gift_card.rb +23 -0
- data/app/services/workarea/forter/tender/paypal.rb +38 -0
- data/app/services/workarea/forter/tender/store_credit.rb +23 -0
- data/app/view_models/workarea/admin/order_view_model.decorator +7 -0
- data/app/views/workarea/admin/orders/_forter.html.haml +18 -0
- data/app/views/workarea/admin/orders/forter.html.haml +57 -0
- data/app/views/workarea/storefront/_forter_tracking.html.haml +4 -0
- data/app/workers/forter/update_status.rb +21 -0
- data/app/workers/workarea/save_user_order_details.decorator +34 -0
- data/bin/rails +20 -0
- data/config/initializers/appends.rb +9 -0
- data/config/initializers/workarea.rb +22 -0
- data/config/locales/en.yml +26 -0
- data/config/routes.rb +7 -0
- data/lib/workarea/forter/bogus_gateway.rb +62 -0
- data/lib/workarea/forter/decision_response.rb +60 -0
- data/lib/workarea/forter/engine.rb +8 -0
- data/lib/workarea/forter/gateway.rb +66 -0
- data/lib/workarea/forter/version.rb +5 -0
- data/lib/workarea/forter.rb +50 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +30 -0
- data/test/dummy/bin/update +26 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config/application.rb +30 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +51 -0
- data/test/dummy/config/environments/production.rb +88 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +56 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +32 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/factories/forter.rb +132 -0
- data/test/integration/workarea/admin/forter_order_integration_test.rb +36 -0
- data/test/integration/workarea/forter_authorize_cim_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_braintree_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_checkoutdotcom_integration_test.rb +71 -0
- data/test/integration/workarea/forter_cybersource_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_moneris_response_code_integration_test.rb +69 -0
- data/test/integration/workarea/forter_payflow_pro_response_code_test.rb +69 -0
- data/test/integration/workarea/storefront/forter_integration_test.rb +138 -0
- data/test/lib/workarea/forter/gateway_test.rb +47 -0
- data/test/models/workarea/checkout/forter_collect_payment_test.rb +60 -0
- data/test/models/workarea/forter_payment_test.rb +58 -0
- data/test/models/workarea/payment/forter_credit_card_test.rb +19 -0
- data/test/models/workarea/payment/forter_saved_credit_card_test.rb +32 -0
- data/test/services/workarea/forter/order_test.rb +82 -0
- data/test/support/workarea/forter_api_config.rb +27 -0
- data/test/system/workarea/admin/forter_system_test.rb +31 -0
- data/test/system/workarea/storefront/forter_braintree_checkout_system_test.rb +79 -0
- data/test/system/workarea/storefront/forter_tracking_system_test.rb +20 -0
- data/test/system/workarea/storefront/guest_checkout_system_test.decorator +43 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +11 -0
- data/test/vcr_cassettes/forter/get_decision.yml +66 -0
- data/test/vcr_cassettes/forter/integration/authorize_net_response_code.yml +410 -0
- data/test/vcr_cassettes/forter/integration/braintree_response_code.yml +231 -0
- data/test/vcr_cassettes/forter/integration/checkoutdotcom_response_code.yml +129 -0
- data/test/vcr_cassettes/forter/integration/cyber_response_code.yml +199 -0
- data/test/vcr_cassettes/forter/integration/moneris_response_code.yml +84 -0
- data/test/vcr_cassettes/forter/integration/payflow_pro_response_code.yml +60 -0
- data/test/vcr_cassettes/forter/system/braintree_approved.yml +293 -0
- data/test/vcr_cassettes/forter/system/braintree_declined.yml +485 -0
- data/test/vcr_cassettes/forter/system/braintree_not_reviewed.yml +293 -0
- data/test/vcr_cassettes/forter/update_status.yml +182 -0
- data/test/view_models/workarea/storefront/order_view_model_test.decorator +10 -0
- data/test/workers/forter/update_status_test.rb +22 -0
- data/workarea-forter.gemspec +18 -0
- metadata +195 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure public file server for tests with Cache-Control for performance.
|
16
|
+
config.public_file_server.enabled = true
|
17
|
+
config.public_file_server.headers = {
|
18
|
+
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
|
19
|
+
}
|
20
|
+
|
21
|
+
# Show full error reports and disable caching.
|
22
|
+
config.consider_all_requests_local = true
|
23
|
+
config.action_controller.perform_caching = false
|
24
|
+
|
25
|
+
# Raise exceptions instead of rendering exception templates.
|
26
|
+
config.action_dispatch.show_exceptions = false
|
27
|
+
|
28
|
+
# Disable request forgery protection in test environment.
|
29
|
+
config.action_controller.allow_forgery_protection = false
|
30
|
+
config.action_mailer.perform_caching = false
|
31
|
+
|
32
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
33
|
+
# The :test delivery method accumulates sent emails in the
|
34
|
+
# ActionMailer::Base.deliveries array.
|
35
|
+
config.action_mailer.delivery_method = :test
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr.
|
38
|
+
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Raises error for missing translations
|
41
|
+
# config.action_view.raise_on_missing_translations = true
|
42
|
+
|
43
|
+
config.cache_store = :null_store
|
44
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path.
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
# Add Yarn node_modules folder to the asset load path.
|
9
|
+
Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
10
|
+
|
11
|
+
# Precompile additional assets.
|
12
|
+
# application.js, application.css, and all non-JS/CSS in the app/assets
|
13
|
+
# folder are already added.
|
14
|
+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# The following keys must be escaped otherwise they will not be retrieved by
|
20
|
+
# the default I18n backend:
|
21
|
+
#
|
22
|
+
# true, false, on, off, yes, no
|
23
|
+
#
|
24
|
+
# Instead, surround them with single quotes.
|
25
|
+
#
|
26
|
+
# en:
|
27
|
+
# 'true': 'foo'
|
28
|
+
#
|
29
|
+
# To learn more, please read the Rails Internationalization guide
|
30
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
31
|
+
|
32
|
+
en:
|
33
|
+
hello: "Hello world"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
+
# Any libraries that use thread pools should be configured to match
|
4
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
+
# and maximum; this matches the default thread size of Active Record.
|
6
|
+
#
|
7
|
+
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
+
threads threads_count, threads_count
|
9
|
+
|
10
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
11
|
+
#
|
12
|
+
port ENV.fetch("PORT") { 3000 }
|
13
|
+
|
14
|
+
# Specifies the `environment` that Puma will run in.
|
15
|
+
#
|
16
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
17
|
+
|
18
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
19
|
+
# Workers are forked webserver processes. If using threads and workers together
|
20
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
21
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
22
|
+
# processes).
|
23
|
+
#
|
24
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
25
|
+
|
26
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
27
|
+
# This directive tells Puma to first boot the application and load code
|
28
|
+
# before forking the application. This takes advantage of Copy On Write
|
29
|
+
# process behavior so workers use less memory. If you use this option
|
30
|
+
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
31
|
+
# block.
|
32
|
+
#
|
33
|
+
# preload_app!
|
34
|
+
|
35
|
+
# If you are preloading your application and using Active Record, it's
|
36
|
+
# recommended that you close any connections to the database before workers
|
37
|
+
# are forked to prevent connection leakage.
|
38
|
+
#
|
39
|
+
# before_fork do
|
40
|
+
# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
|
41
|
+
# end
|
42
|
+
|
43
|
+
# The code in the `on_worker_boot` will be called if you are using
|
44
|
+
# clustered mode by specifying a number of `workers`. After each worker
|
45
|
+
# process is booted, this block will be run. If you are using the `preload_app!`
|
46
|
+
# option, you will want to use this block to reconnect to any threads
|
47
|
+
# or connections that may have been created at application boot, as Ruby
|
48
|
+
# cannot share connections between processes.
|
49
|
+
#
|
50
|
+
# on_worker_boot do
|
51
|
+
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
|
55
|
+
# Allow puma to be restarted by `rails restart` command.
|
56
|
+
plugin :tmp_restart
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rails secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
# Shared secrets are available across all environments.
|
14
|
+
|
15
|
+
# shared:
|
16
|
+
# api_key: a1B2c3D4e5F6
|
17
|
+
|
18
|
+
# Environmental secrets are only available for that specific environment.
|
19
|
+
|
20
|
+
development:
|
21
|
+
secret_key_base: 522a431b87f004adc4daa64a17a2f5a9214ba294d79c1e0805f178408a20c66b30724e84ca94a46061109ee60fa11c11488dac589ee4cfde9a89b08a58719f8d
|
22
|
+
|
23
|
+
test:
|
24
|
+
secret_key_base: 0a152f9ec05b13dc3f0f20a86ccfe37e06aab1b20f5a3cd7d290c75d65618c64530b2c4089d1dbdab2467593dbde0386c6dcaf6c90092049a69bf42f33926ada
|
25
|
+
|
26
|
+
# Do not keep production secrets in the unencrypted secrets file.
|
27
|
+
# Instead, either read values from the environment.
|
28
|
+
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
|
29
|
+
# and move the `production:` environment over there.
|
30
|
+
|
31
|
+
production:
|
32
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
File without changes
|
@@ -0,0 +1,132 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Factories
|
3
|
+
module Forter
|
4
|
+
Factories.add self
|
5
|
+
|
6
|
+
def create_placed_forter_order(overrides = {}, options = {})
|
7
|
+
attributes = {
|
8
|
+
id: '1234',
|
9
|
+
email: 'tester@workarea.com',
|
10
|
+
placed_at: Time.current,
|
11
|
+
ip_address: '127.0.0.1',
|
12
|
+
user_agent: 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0 Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0.',
|
13
|
+
forter_tracking_code: '123ABC'
|
14
|
+
}.merge(overrides)
|
15
|
+
|
16
|
+
shipping_service = create_shipping_service
|
17
|
+
sku = 'SKU'
|
18
|
+
create_product(variants: [{ sku: sku, regular: 5.to_m }])
|
19
|
+
details = OrderItemDetails.find(sku)
|
20
|
+
order = Workarea::Order.new(attributes)
|
21
|
+
item = { sku: sku, quantity: 2 }.merge(details.to_h)
|
22
|
+
|
23
|
+
order.add_item(item)
|
24
|
+
|
25
|
+
checkout = Checkout.new(order)
|
26
|
+
checkout.update(
|
27
|
+
shipping_address: {
|
28
|
+
first_name: 'Ben',
|
29
|
+
last_name: 'Crouse',
|
30
|
+
street: '22 S. 3rd St.',
|
31
|
+
street_2: 'Second Floor',
|
32
|
+
city: 'Philadelphia',
|
33
|
+
region: 'PA',
|
34
|
+
postal_code: '19106',
|
35
|
+
country: 'US'
|
36
|
+
},
|
37
|
+
billing_address: {
|
38
|
+
first_name: 'Ben',
|
39
|
+
last_name: 'Crouse',
|
40
|
+
street: '12 N. 3rd St.',
|
41
|
+
street_2: 'thrid floor',
|
42
|
+
city: 'Philadelphia',
|
43
|
+
region: 'PA',
|
44
|
+
postal_code: '19106',
|
45
|
+
country: 'US'
|
46
|
+
},
|
47
|
+
shipping_service: shipping_service.name,
|
48
|
+
)
|
49
|
+
|
50
|
+
if options[:store_credit_amount].present?
|
51
|
+
checkout.payment_profile.store_credit = options[:store_credit_amount]
|
52
|
+
checkout.payment.build_store_credit
|
53
|
+
end
|
54
|
+
|
55
|
+
checkout.update(
|
56
|
+
payment: 'new_card',
|
57
|
+
credit_card: {
|
58
|
+
number: '4111111111111111',
|
59
|
+
month: '1',
|
60
|
+
year: Time.current.year + 1,
|
61
|
+
cvv: '999'
|
62
|
+
}
|
63
|
+
)
|
64
|
+
|
65
|
+
checkout.place_order
|
66
|
+
|
67
|
+
forced_attrs = overrides.slice(:placed_at, :update_at, :total_price)
|
68
|
+
order.update_attributes!(forced_attrs)
|
69
|
+
order
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_purchasable_checkout(options = {})
|
73
|
+
product = create_product(variants: [{ sku: 'SKU', regular: 5.to_m }])
|
74
|
+
|
75
|
+
order_attributes = {
|
76
|
+
email: 'bcrouse-new@workarea.com'
|
77
|
+
}.merge(options[:order] || {})
|
78
|
+
|
79
|
+
order = Workarea::Order.new(order_attributes).tap do |o|
|
80
|
+
o.add_item(product_id: product.id, sku: 'SKU', quantity: 2)
|
81
|
+
end
|
82
|
+
|
83
|
+
shipping_address = {
|
84
|
+
first_name: 'Ben',
|
85
|
+
last_name: 'Crouse',
|
86
|
+
street: '22 S. 3rd St.',
|
87
|
+
street_2: 'Second Floor',
|
88
|
+
city: 'Philadelphia',
|
89
|
+
region: 'PA',
|
90
|
+
postal_code: '19106',
|
91
|
+
country: 'US'
|
92
|
+
}.merge(options[:shipping_address] || {})
|
93
|
+
|
94
|
+
billing_address = {
|
95
|
+
first_name: 'Ben',
|
96
|
+
last_name: 'Crouse',
|
97
|
+
street: '22 S. 3rd St.',
|
98
|
+
street_2: 'Second Floor',
|
99
|
+
city: 'Philadelphia',
|
100
|
+
region: 'PA',
|
101
|
+
postal_code: '19106',
|
102
|
+
country: 'US'
|
103
|
+
}.merge(options[:billing_address] || {})
|
104
|
+
|
105
|
+
credit_card = {
|
106
|
+
number: '4111_1111_1111_1111',
|
107
|
+
month: '01',
|
108
|
+
year: Time.current.year + 1,
|
109
|
+
cvv: '999'
|
110
|
+
}.merge(options[:credit_card] || {})
|
111
|
+
|
112
|
+
shipping_service = options[:shipping_service].presence ||
|
113
|
+
create_shipping_service.name
|
114
|
+
|
115
|
+
order.items.each do |item|
|
116
|
+
item.update_attributes!(OrderItemDetails.find!(item.sku).to_h)
|
117
|
+
end
|
118
|
+
|
119
|
+
checkout = Checkout.new(order)
|
120
|
+
checkout.update(
|
121
|
+
shipping_address: shipping_address,
|
122
|
+
billing_address: billing_address,
|
123
|
+
shipping_service: shipping_service,
|
124
|
+
payment: 'new_card',
|
125
|
+
credit_card: credit_card
|
126
|
+
)
|
127
|
+
|
128
|
+
checkout
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Admin
|
5
|
+
class ForterOrderIntegrationTest < Workarea::IntegrationTest
|
6
|
+
include Admin::IntegrationTest
|
7
|
+
|
8
|
+
def test_shows_decision
|
9
|
+
order = create_placed_forter_order(email: 'approve@workarea.com')
|
10
|
+
|
11
|
+
get admin.order_path(order)
|
12
|
+
assert(response.body.include?("approve"))
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_shows_error_decision
|
16
|
+
order = create_placed_forter_order(email: 'error@workarea.com')
|
17
|
+
|
18
|
+
get admin.forter_order_path(order)
|
19
|
+
message = Workarea::Forter::Decision.first.response.errors.first["message"]
|
20
|
+
assert(response.body.include?(message))
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_returns_flow_order_details
|
24
|
+
order = create_placed_forter_order(email: 'approve@workarea.com')
|
25
|
+
decision = Workarea::Forter::Decision.find(order.id)
|
26
|
+
get admin.forter_order_path(order)
|
27
|
+
|
28
|
+
assert(response.body.include?(decision.response.body_message))
|
29
|
+
assert(response.body.include?(decision.response.action))
|
30
|
+
assert(response.body.include?(decision.response.reason_code.to_s))
|
31
|
+
assert(response.body.include?(decision.external_order_status))
|
32
|
+
assert(response.body.include?(t('workarea.admin.orders.forter.console')))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class ForterAuthorizeCimResponseCodeIntegrationTest < Workarea::IntegrationTest
|
5
|
+
if Workarea::Plugin.installed?(:AuthorizeCim)
|
6
|
+
include ForterApiConfig
|
7
|
+
include AuthorizeCimGatewayVCRConfig
|
8
|
+
|
9
|
+
def test_response_code
|
10
|
+
VCR.use_cassette 'forter/integration/authorize_net_response_code' do
|
11
|
+
|
12
|
+
tender.amount = 5.to_m
|
13
|
+
transaction = tender.build_transaction(action: 'authorize')
|
14
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
15
|
+
operation.complete!
|
16
|
+
transaction.save!
|
17
|
+
|
18
|
+
response_code = Workarea.config.forter.response_code[gateway_class].call(transaction)
|
19
|
+
assert_equal('1', response_code)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def gateway_class
|
26
|
+
gateway.class.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def gateway
|
30
|
+
Workarea.config.gateways.credit_card
|
31
|
+
end
|
32
|
+
|
33
|
+
def payment
|
34
|
+
@payment ||=
|
35
|
+
begin
|
36
|
+
profile = create_payment_profile
|
37
|
+
create_payment(
|
38
|
+
profile_id: profile.id,
|
39
|
+
address: {
|
40
|
+
first_name: 'Ben',
|
41
|
+
last_name: 'Crouse',
|
42
|
+
street: '22 s. 3rd st.',
|
43
|
+
city: 'Philadelphia',
|
44
|
+
region: 'PA',
|
45
|
+
postal_code: '19106',
|
46
|
+
country: Country['US']
|
47
|
+
}
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def tender
|
53
|
+
@tender ||=
|
54
|
+
begin
|
55
|
+
payment.set_address(first_name: 'Ben', last_name: 'Crouse')
|
56
|
+
|
57
|
+
payment.build_credit_card(
|
58
|
+
number: 4111111111111111,
|
59
|
+
month: 1,
|
60
|
+
year: Time.current.year + 1,
|
61
|
+
cvv: 999
|
62
|
+
)
|
63
|
+
|
64
|
+
payment.credit_card
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class ForterBraintreeResponseCodeIntegrationTest < Workarea::IntegrationTest
|
5
|
+
if Workarea::Plugin.installed?(:braintree)
|
6
|
+
include ForterApiConfig
|
7
|
+
include BraintreeGatewayVCRConfig
|
8
|
+
|
9
|
+
def test_response_code
|
10
|
+
VCR.use_cassette 'forter/integration/braintree_response_code' do
|
11
|
+
|
12
|
+
tender.amount = 5.to_m
|
13
|
+
transaction = tender.build_transaction(action: 'authorize')
|
14
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
15
|
+
operation.complete!
|
16
|
+
transaction.save!
|
17
|
+
|
18
|
+
response_code = Workarea.config.forter.response_code[gateway_class].call(transaction)
|
19
|
+
assert_equal('1000', response_code)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def gateway_class
|
26
|
+
gateway.class.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def gateway
|
30
|
+
Workarea.config.gateways.credit_card
|
31
|
+
end
|
32
|
+
|
33
|
+
def payment
|
34
|
+
@payment ||=
|
35
|
+
begin
|
36
|
+
profile = create_payment_profile
|
37
|
+
create_payment(
|
38
|
+
profile_id: profile.id,
|
39
|
+
address: {
|
40
|
+
first_name: 'Ben',
|
41
|
+
last_name: 'Crouse',
|
42
|
+
street: '22 s. 3rd st.',
|
43
|
+
city: 'Philadelphia',
|
44
|
+
region: 'PA',
|
45
|
+
postal_code: '19106',
|
46
|
+
country: Country['US']
|
47
|
+
}
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def tender
|
53
|
+
@tender ||=
|
54
|
+
begin
|
55
|
+
payment.set_address(first_name: 'Ben', last_name: 'Crouse')
|
56
|
+
|
57
|
+
payment.build_credit_card(
|
58
|
+
number: 4111111111111111,
|
59
|
+
month: 1,
|
60
|
+
year: Time.current.year + 1,
|
61
|
+
cvv: 999
|
62
|
+
)
|
63
|
+
|
64
|
+
payment.credit_card
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class ForterAuthorizeCimResponseCodeIntegrationTest < Workarea::IntegrationTest
|
5
|
+
if Workarea::Plugin.installed?(:Checkoutdotcom)
|
6
|
+
include ForterApiConfig
|
7
|
+
include CheckoutdotcomGatewayVCRConfig
|
8
|
+
|
9
|
+
def test_response_code
|
10
|
+
VCR.use_cassette 'forter/integration/checkoutdotcom_response_code' do
|
11
|
+
|
12
|
+
tender.amount = 5.to_m
|
13
|
+
transaction = tender.build_transaction(action: 'authorize')
|
14
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
15
|
+
operation.complete!
|
16
|
+
transaction.save!
|
17
|
+
|
18
|
+
response_code = Workarea.config.forter.response_code[gateway_class].call(transaction)
|
19
|
+
assert_equal('10000', response_code)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def gateway_class
|
26
|
+
gateway.class.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def gateway
|
30
|
+
Workarea.config.gateways.credit_card
|
31
|
+
end
|
32
|
+
|
33
|
+
def payment
|
34
|
+
@payment ||=
|
35
|
+
begin
|
36
|
+
profile = create_payment_profile
|
37
|
+
order = create_order
|
38
|
+
create_payment(
|
39
|
+
id: order.id,
|
40
|
+
profile_id: profile.id,
|
41
|
+
address: {
|
42
|
+
first_name: 'Ben',
|
43
|
+
last_name: 'Crouse',
|
44
|
+
street: '22 s. 3rd st.',
|
45
|
+
city: 'Philadelphia',
|
46
|
+
region: 'PA',
|
47
|
+
postal_code: '19106',
|
48
|
+
country: Country['US']
|
49
|
+
}
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def tender
|
55
|
+
@tender ||=
|
56
|
+
begin
|
57
|
+
payment.set_address(first_name: 'Ben', last_name: 'Crouse')
|
58
|
+
|
59
|
+
payment.build_credit_card(
|
60
|
+
number: 4242424242424242,
|
61
|
+
month: 1,
|
62
|
+
year: Time.current.year + 1,
|
63
|
+
cvv: 100
|
64
|
+
)
|
65
|
+
|
66
|
+
payment.credit_card
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|