workarea-sezzle 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +405 -0
- data/.scss-lint.yml +204 -0
- data/Gemfile +17 -0
- data/LICENSE +7 -0
- data/README.md +95 -0
- data/Rakefile +56 -0
- data/Workarea +0 -0
- data/app/assets/images/workarea/admin/sezzle/.keep +0 -0
- data/app/assets/images/workarea/sezzle_logo_white.svg +1 -0
- data/app/assets/images/workarea/storefront/sezzle/.keep +0 -0
- data/app/assets/javascripts/workarea/admin/sezzle/.keep +0 -0
- data/app/assets/javascripts/workarea/storefront/sezzle/.keep +0 -0
- data/app/assets/stylesheets/workarea/admin/sezzle/.keep +0 -0
- data/app/assets/stylesheets/workarea/admin/sezzle/components/_payment_icon.scss +13 -0
- data/app/assets/stylesheets/workarea/storefront/sezzle/.keep +0 -0
- data/app/assets/stylesheets/workarea/storefront/sezzle/components/_payment_icon.scss +13 -0
- data/app/assets/stylesheets/workarea/storefront/sezzle/components/_sezzle.scss +13 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/workarea/storefront/checkout/place_order_controller.decorator +11 -0
- data/app/controllers/workarea/storefront/sezzle_controller.rb +109 -0
- data/app/helpers/.keep +0 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/workarea/payment/authorize/sezzle.rb +32 -0
- data/app/models/workarea/payment/capture/sezzle.rb +85 -0
- data/app/models/workarea/payment/purchase/sezzle.rb +30 -0
- data/app/models/workarea/payment/refund/sezzle.rb +47 -0
- data/app/models/workarea/payment/tender/sezzle.rb +15 -0
- data/app/models/workarea/paymentl.decorator +32 -0
- data/app/services/workarea/sezzle/order_builder.rb +135 -0
- data/app/view_models/workarea/storefront/checkout/payment_view_model.decorator +11 -0
- data/app/views/.keep +0 -0
- data/app/views/workarea/admin/orders/tenders/_sezzle.html.haml +3 -0
- data/app/views/workarea/storefront/carts/_sezzle_widget.html.haml +5 -0
- data/app/views/workarea/storefront/checkouts/_sezzle_payment.html.haml +8 -0
- data/app/views/workarea/storefront/order_mailer/tenders/_sezzle.html.haml +1 -0
- data/app/views/workarea/storefront/order_mailer/tenders/_sezzle.text.erb +1 -0
- data/app/views/workarea/storefront/orders/tenders/_sezzle.html.haml +4 -0
- data/app/views/workarea/storefront/products/_sezzle_widget.html.haml +10 -0
- data/app/views/workarea/storefront/sezzle/_script.html.haml +22 -0
- data/bin/rails +25 -0
- data/config/initializers/appends.rb +30 -0
- data/config/initializers/configurations.rb +41 -0
- data/config/initializers/workarea.rb +21 -0
- data/config/locales/en.yml +43 -0
- data/config/routes.rb +5 -0
- data/lib/workarea/sezzle.rb +53 -0
- data/lib/workarea/sezzle/authentication.rb +49 -0
- data/lib/workarea/sezzle/bogus_gateway.rb +128 -0
- data/lib/workarea/sezzle/engine.rb +10 -0
- data/lib/workarea/sezzle/gateway.rb +90 -0
- data/lib/workarea/sezzle/response.rb +27 -0
- data/lib/workarea/sezzle/version.rb +5 -0
- data/module +0 -0
- data/test/dummy/.ruby-version +1 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +2 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/javascript/packs/application.js +14 -0
- data/test/dummy/app/jobs/application_job.rb +7 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +25 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +34 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +53 -0
- data/test/dummy/config/environments/production.rb +101 -0
- data/test/dummy/config/environments/test.rb +47 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +12 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/content_security_policy.rb +28 -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 +38 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/integration/workarea/storefront/sezzle_integration_test.rb +205 -0
- data/test/models/workarea/payment/sezzle_payment_integration_test.rb +82 -0
- data/test/services/workarea/sezzle/order_builder_test.rb +116 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +10 -0
- data/workarea-sezzle.gemspec +20 -0
- metadata +163 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
# The test environment is used exclusively to run your application's
|
2
|
+
# test suite. You never need to work with it otherwise. Remember that
|
3
|
+
# your test database is "scratch space" for the test suite and is wiped
|
4
|
+
# and recreated between test runs. Don't rely on the data there!
|
5
|
+
|
6
|
+
Rails.application.configure do
|
7
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
8
|
+
|
9
|
+
config.cache_classes = false
|
10
|
+
|
11
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
12
|
+
# just for the purpose of running a single test. If you are using a tool that
|
13
|
+
# preloads Rails for running tests, you may have to set it to true.
|
14
|
+
config.eager_load = false
|
15
|
+
|
16
|
+
# Configure public file server for tests with Cache-Control for performance.
|
17
|
+
config.public_file_server.enabled = true
|
18
|
+
config.public_file_server.headers = {
|
19
|
+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
|
20
|
+
}
|
21
|
+
|
22
|
+
# Show full error reports and disable caching.
|
23
|
+
config.consider_all_requests_local = true
|
24
|
+
config.action_controller.perform_caching = false
|
25
|
+
config.cache_store = :null_store
|
26
|
+
|
27
|
+
# Raise exceptions instead of rendering exception templates.
|
28
|
+
config.action_dispatch.show_exceptions = false
|
29
|
+
|
30
|
+
# Disable request forgery protection in test environment.
|
31
|
+
config.action_controller.allow_forgery_protection = false
|
32
|
+
|
33
|
+
config.action_mailer.perform_caching = false
|
34
|
+
|
35
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
36
|
+
# The :test delivery method accumulates sent emails in the
|
37
|
+
# ActionMailer::Base.deliveries array.
|
38
|
+
config.action_mailer.delivery_method = :test
|
39
|
+
|
40
|
+
# Print deprecation notices to the stderr.
|
41
|
+
config.active_support.deprecation = :stderr
|
42
|
+
|
43
|
+
# Raises error for missing translations.
|
44
|
+
# config.action_view.raise_on_missing_translations = true
|
45
|
+
|
46
|
+
config.cache_store = :null_store
|
47
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in the app/assets
|
11
|
+
# folder are already added.
|
12
|
+
# 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,28 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Define an application-wide content security policy
|
4
|
+
# For further information see the following documentation
|
5
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
6
|
+
|
7
|
+
# Rails.application.config.content_security_policy do |policy|
|
8
|
+
# policy.default_src :self, :https
|
9
|
+
# policy.font_src :self, :https, :data
|
10
|
+
# policy.img_src :self, :https, :data
|
11
|
+
# policy.object_src :none
|
12
|
+
# policy.script_src :self, :https
|
13
|
+
# policy.style_src :self, :https
|
14
|
+
|
15
|
+
# # Specify URI for violation reports
|
16
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
17
|
+
# end
|
18
|
+
|
19
|
+
# If you are using UJS then enable automatic nonce generation
|
20
|
+
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
|
21
|
+
|
22
|
+
# Set the nonce only to specific directives
|
23
|
+
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
|
24
|
+
|
25
|
+
# Report CSP violations to a specified URI
|
26
|
+
# For further information see the following documentation:
|
27
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
28
|
+
# Rails.application.config.content_security_policy_report_only = true
|
@@ -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 https://guides.rubyonrails.org/i18n.html.
|
31
|
+
|
32
|
+
en:
|
33
|
+
hello: "Hello world"
|
@@ -0,0 +1,38 @@
|
|
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
|
+
max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
|
8
|
+
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
|
9
|
+
threads min_threads_count, max_threads_count
|
10
|
+
|
11
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
12
|
+
#
|
13
|
+
port ENV.fetch('PORT') { 3000 }
|
14
|
+
|
15
|
+
# Specifies the `environment` that Puma will run in.
|
16
|
+
#
|
17
|
+
environment ENV.fetch('RAILS_ENV') { 'development' }
|
18
|
+
|
19
|
+
# Specifies the `pidfile` that Puma will use.
|
20
|
+
pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
|
21
|
+
|
22
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
23
|
+
# Workers are forked web server processes. If using threads and workers together
|
24
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
25
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
26
|
+
# processes).
|
27
|
+
#
|
28
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
29
|
+
|
30
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
31
|
+
# This directive tells Puma to first boot the application and load code
|
32
|
+
# before forking the application. This takes advantage of Copy On Write
|
33
|
+
# process behavior so workers use less memory.
|
34
|
+
#
|
35
|
+
# preload_app!
|
36
|
+
|
37
|
+
# Allow puma to be restarted by `rails restart` command.
|
38
|
+
plugin :tmp_restart
|
File without changes
|
File without changes
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
class SezzleIntengrationTest < Workarea::IntegrationTest
|
6
|
+
setup do
|
7
|
+
create_tax_category(
|
8
|
+
name: 'Sales Tax',
|
9
|
+
code: '001',
|
10
|
+
rates: [{ percentage: 0.07, country: 'US', region: 'PA' }]
|
11
|
+
)
|
12
|
+
|
13
|
+
product = create_product(
|
14
|
+
variants: [{ sku: 'SKU1', regular: 6.to_m, tax_code: '001' }]
|
15
|
+
)
|
16
|
+
|
17
|
+
create_shipping_service(
|
18
|
+
carrier: 'UPS',
|
19
|
+
name: 'Ground',
|
20
|
+
service_code: '03',
|
21
|
+
tax_code: '001',
|
22
|
+
rates: [{ price: 7.to_m }]
|
23
|
+
)
|
24
|
+
|
25
|
+
post storefront.cart_items_path,
|
26
|
+
params: {
|
27
|
+
product_id: product.id,
|
28
|
+
sku: product.skus.first,
|
29
|
+
quantity: 2
|
30
|
+
}
|
31
|
+
|
32
|
+
patch storefront.checkout_addresses_path,
|
33
|
+
params: {
|
34
|
+
email: 'bcrouse@workarea.com',
|
35
|
+
billing_address: {
|
36
|
+
first_name: 'Ben',
|
37
|
+
last_name: 'Crouse',
|
38
|
+
street: '12 N. 3rd St.',
|
39
|
+
city: 'Philadelphia',
|
40
|
+
region: 'PA',
|
41
|
+
postal_code: '19106',
|
42
|
+
country: 'US',
|
43
|
+
phone_number: '2159251800'
|
44
|
+
},
|
45
|
+
shipping_address: {
|
46
|
+
first_name: 'Ben',
|
47
|
+
last_name: 'Crouse',
|
48
|
+
street: '22 S. 3rd St.',
|
49
|
+
city: 'Philadelphia',
|
50
|
+
region: 'PA',
|
51
|
+
postal_code: '19106',
|
52
|
+
country: 'US',
|
53
|
+
phone_number: '2159251800'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
patch storefront.checkout_shipping_path
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_start_clears_credit_card_and_sets_sezzle_payment
|
61
|
+
Workarea.config.sezzle_payment_action = 'AUTH'
|
62
|
+
|
63
|
+
payment = Payment.find(order.id)
|
64
|
+
payment.set_credit_card({
|
65
|
+
month: '01',
|
66
|
+
year: Time.now.year + 1,
|
67
|
+
number: 1,
|
68
|
+
cvv: '123'
|
69
|
+
})
|
70
|
+
|
71
|
+
payment.reload
|
72
|
+
|
73
|
+
get storefront.start_sezzle_path
|
74
|
+
|
75
|
+
payment.reload
|
76
|
+
order.reload
|
77
|
+
|
78
|
+
refute(payment.credit_card.present?)
|
79
|
+
assert(payment.sezzle.present?)
|
80
|
+
assert(payment.sezzle.sezzle_id.present?)
|
81
|
+
assert_equal('AUTH', payment.sezzle.intent)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_cancel_removes_sezzle
|
85
|
+
payment = Payment.find(order.id)
|
86
|
+
|
87
|
+
payment.set_sezzle(
|
88
|
+
sezzle_id: '1234',
|
89
|
+
sezzle_response: '{}'
|
90
|
+
)
|
91
|
+
|
92
|
+
assert(payment.sezzle?)
|
93
|
+
|
94
|
+
get storefront.cancel_sezzle_path(order_id: order.id)
|
95
|
+
payment.reload
|
96
|
+
|
97
|
+
refute(payment.sezzle?)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_placing_order_from_sezzle
|
101
|
+
payment = Payment.find(order.id)
|
102
|
+
|
103
|
+
payment.set_sezzle(
|
104
|
+
sezzle_id: '1234',
|
105
|
+
sezzle_response: '{}',
|
106
|
+
intent: 'AUTH'
|
107
|
+
)
|
108
|
+
|
109
|
+
get storefront.complete_sezzle_path(order_id: order.id)
|
110
|
+
|
111
|
+
payment.reload
|
112
|
+
order.reload
|
113
|
+
|
114
|
+
assert(order.placed?)
|
115
|
+
|
116
|
+
transactions = payment.tenders.first.transactions
|
117
|
+
assert_equal(1, transactions.size)
|
118
|
+
assert(transactions.first.success?)
|
119
|
+
assert_equal('authorize', transactions.first.action)
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_placing_order_with_dual_payment
|
123
|
+
payment = Payment.find(order.id)
|
124
|
+
payment.profile = create_payment_profile(email: order.email)
|
125
|
+
|
126
|
+
payment.profile.update_attributes!(store_credit: 1.00)
|
127
|
+
payment.set_store_credit
|
128
|
+
payment.tenders.first.amount = 1.to_m
|
129
|
+
payment.save!
|
130
|
+
|
131
|
+
payment.set_sezzle(
|
132
|
+
sezzle_id: '1234',
|
133
|
+
sezzle_response: '{}',
|
134
|
+
intent: 'AUTH'
|
135
|
+
)
|
136
|
+
|
137
|
+
get storefront.complete_sezzle_path(order_id: order.id)
|
138
|
+
|
139
|
+
payment.reload
|
140
|
+
order.reload
|
141
|
+
|
142
|
+
assert(order.placed?)
|
143
|
+
transactions = payment.transactions
|
144
|
+
assert_equal(2, transactions.size)
|
145
|
+
|
146
|
+
sezzle_tender = payment.tenders.detect { |t| t.slug == :sezzle }
|
147
|
+
assert(sezzle_tender.transactions.first.success?)
|
148
|
+
assert_equal('authorize', sezzle_tender.transactions.first.action)
|
149
|
+
|
150
|
+
store_credit_tender = payment.tenders.detect { |t| t.slug == :store_credit }
|
151
|
+
assert(store_credit_tender.transactions.first.success?)
|
152
|
+
|
153
|
+
# Workarea v3.0.53, v3.1.40, v3.2.29, v3.3.21 and greater sets store credit to purchase by
|
154
|
+
# default.
|
155
|
+
assert_equal('purchase', store_credit_tender.transactions.first.action)
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_failed_sezzle_capture
|
159
|
+
payment = Payment.find(order.id)
|
160
|
+
|
161
|
+
payment.set_sezzle(token: 'error_token')
|
162
|
+
|
163
|
+
params = { token: 'error_token', status: 'SUCCESS' }
|
164
|
+
|
165
|
+
get storefront.complete_sezzle_path(params)
|
166
|
+
|
167
|
+
payment.reload
|
168
|
+
order.reload
|
169
|
+
|
170
|
+
refute(order.placed?)
|
171
|
+
end
|
172
|
+
|
173
|
+
private
|
174
|
+
|
175
|
+
def order
|
176
|
+
@order ||= Order.first
|
177
|
+
end
|
178
|
+
|
179
|
+
def product
|
180
|
+
@product ||= create_product(
|
181
|
+
variants: [{ sku: 'SKU1', regular: 6.to_m, tax_code: '001' }]
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
def get_order_response(amount)
|
186
|
+
b = {
|
187
|
+
"amount": {
|
188
|
+
"amount": "#{amount}",
|
189
|
+
"currency": 'USD'
|
190
|
+
}
|
191
|
+
}
|
192
|
+
Workarea::Sezzle::Response.new(response(b))
|
193
|
+
end
|
194
|
+
|
195
|
+
def response(body, status = 200)
|
196
|
+
response = Faraday.new do |builder|
|
197
|
+
builder.adapter :test do |stub|
|
198
|
+
stub.get('/v2/bogus') { |env| [ status, {}, body.to_json ] }
|
199
|
+
end
|
200
|
+
end
|
201
|
+
response.get('/v2/bogus')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|