workarea-zipco 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc.json +35 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.github/workflows/ci.yml +64 -0
  7. data/.gitignore +23 -0
  8. data/.rubocop.yml +2 -0
  9. data/.stylelintrc.json +8 -0
  10. data/CHANGELOG.md +17 -0
  11. data/Gemfile +17 -0
  12. data/README.md +51 -0
  13. data/Rakefile +59 -0
  14. data/app/assets/images/zipco/.keep +0 -0
  15. data/app/assets/stylesheets/workarea/storefront/zipco/components/_zipco_icon.scss +7 -0
  16. data/app/controllers/storefront/checkout/place_order_controller.decorator +11 -0
  17. data/app/controllers/storefront/zipco_controller.rb +96 -0
  18. data/app/controllers/storefront/zipco_landing_controller.rb +6 -0
  19. data/app/helpers/.keep +0 -0
  20. data/app/mailers/.keep +0 -0
  21. data/app/models/checkout.decorator +33 -0
  22. data/app/models/workarea/order.decorator +52 -0
  23. data/app/models/workarea/order/status/zip_referred.rb +13 -0
  24. data/app/models/workarea/payment.decorator +30 -0
  25. data/app/models/workarea/payment/authorize/zipco.rb +66 -0
  26. data/app/models/workarea/payment/capture/zipco.rb +58 -0
  27. data/app/models/workarea/payment/purchase/zipco.rb +66 -0
  28. data/app/models/workarea/payment/refund/zipco.rb +59 -0
  29. data/app/models/workarea/payment/tender/zipco.rb +13 -0
  30. data/app/models/workarea/search/admin/admin.decorator +7 -0
  31. data/app/services/workarea/zipco/checkout.rb +48 -0
  32. data/app/services/workarea/zipco/order.rb +188 -0
  33. data/app/services/workarea/zipco/setup.rb +37 -0
  34. data/app/view_models/workarea/storefront/checkout/payment_view_model.decorator +17 -0
  35. data/app/view_models/workarea/storefront/order_view_model.decorator +11 -0
  36. data/app/view_models/workarea/storefront/zipco_view_model.rb +18 -0
  37. data/app/views/workarea/admin/orders/tenders/_zipco.html.haml +4 -0
  38. data/app/views/workarea/storefront/checkouts/_zipco_payment.html.haml +10 -0
  39. data/app/views/workarea/storefront/order_mailer/tenders/_zipco.html.haml +4 -0
  40. data/app/views/workarea/storefront/order_mailer/tenders/_zipco.text.erb +1 -0
  41. data/app/views/workarea/storefront/orders/_zipco_order_message.html.haml +2 -0
  42. data/app/views/workarea/storefront/orders/tenders/_zipco.html.haml +6 -0
  43. data/app/views/workarea/storefront/zipco/_zipco_tagline.html.haml +4 -0
  44. data/app/views/workarea/storefront/zipco_landing/show.html.haml +4 -0
  45. data/bin/rails +25 -0
  46. data/config/initializers/appends.rb +24 -0
  47. data/config/initializers/workarea.rb +15 -0
  48. data/config/locales/en.yml +38 -0
  49. data/config/routes.rb +5 -0
  50. data/lib/workarea/zipco.rb +48 -0
  51. data/lib/workarea/zipco/bogus_gateway.rb +160 -0
  52. data/lib/workarea/zipco/engine.rb +10 -0
  53. data/lib/workarea/zipco/gateway.rb +113 -0
  54. data/lib/workarea/zipco/response.rb +29 -0
  55. data/lib/workarea/zipco/version.rb +5 -0
  56. data/test/dummy/.ruby-version +1 -0
  57. data/test/dummy/Rakefile +6 -0
  58. data/test/dummy/app/assets/config/manifest.js +3 -0
  59. data/test/dummy/app/assets/images/.keep +0 -0
  60. data/test/dummy/app/assets/javascripts/application.js +14 -0
  61. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  62. data/test/dummy/app/controllers/application_controller.rb +2 -0
  63. data/test/dummy/app/controllers/concerns/.keep +0 -0
  64. data/test/dummy/app/helpers/application_helper.rb +2 -0
  65. data/test/dummy/app/jobs/application_job.rb +2 -0
  66. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  67. data/test/dummy/app/models/concerns/.keep +0 -0
  68. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  69. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  70. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  71. data/test/dummy/bin/bundle +3 -0
  72. data/test/dummy/bin/rails +4 -0
  73. data/test/dummy/bin/rake +4 -0
  74. data/test/dummy/bin/setup +28 -0
  75. data/test/dummy/bin/update +28 -0
  76. data/test/dummy/bin/yarn +11 -0
  77. data/test/dummy/config.ru +5 -0
  78. data/test/dummy/config/application.rb +34 -0
  79. data/test/dummy/config/boot.rb +5 -0
  80. data/test/dummy/config/environment.rb +5 -0
  81. data/test/dummy/config/environments/development.rb +52 -0
  82. data/test/dummy/config/environments/production.rb +83 -0
  83. data/test/dummy/config/environments/test.rb +45 -0
  84. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  85. data/test/dummy/config/initializers/assets.rb +14 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  88. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  89. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  90. data/test/dummy/config/initializers/inflections.rb +16 -0
  91. data/test/dummy/config/initializers/mime_types.rb +4 -0
  92. data/test/dummy/config/initializers/workarea.rb +5 -0
  93. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  94. data/test/dummy/config/locales/en.yml +33 -0
  95. data/test/dummy/config/puma.rb +34 -0
  96. data/test/dummy/config/routes.rb +5 -0
  97. data/test/dummy/config/spring.rb +6 -0
  98. data/test/dummy/db/seeds.rb +2 -0
  99. data/test/dummy/lib/assets/.keep +0 -0
  100. data/test/dummy/log/.keep +0 -0
  101. data/test/integration/workarea/storefront/zipco_integration_test.rb +250 -0
  102. data/test/models/workarea/order/zipco_queries_test.rb +35 -0
  103. data/test/models/workarea/payment/zipco_payment_integration_test.rb +89 -0
  104. data/test/services/workarea/zipco/checkout_test.rb +43 -0
  105. data/test/services/workarea/zipco/order_test.rb +102 -0
  106. data/test/services/workarea/zipco/setup_test.rb +65 -0
  107. data/test/teaspoon_env.rb +6 -0
  108. data/test/test_helper.rb +10 -0
  109. data/test/view_models/workarea/storefront/zipco_view_model_test.rb +55 -0
  110. data/workarea-zipco.gemspec +19 -0
  111. metadata +167 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 873f7c0a10815319863b842faea8d7e29028ef4a8476b5bdacf4bcf871996333
4
+ data.tar.gz: 50ff89769ab6ffe57cdf66cabcc1a8ccc5bb5620dd76d61c32a6ce0110f6d22c
5
+ SHA512:
6
+ metadata.gz: 3f8003f3b5c6d7ff3438951cfcd5bb4144f6c757bdeee481e6ad900e1a753837eacca5e92901e0e9e88b03b22b68d27c6d74ef1c7d8152a944f633b4ab0bc930
7
+ data.tar.gz: bb341589f6d49f2d01fe2b7aa2a7de38139cc9f31b2fe3d6d357de249d3c20806f36501d9ac09ff9dbd267352a65ebb6a210f381637c313eb0cc267405b38c78
@@ -0,0 +1,35 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "semi": ["error", "always"],
5
+ "eqeqeq": ["error", "always"]
6
+ },
7
+ "globals": {
8
+ "window": true,
9
+ "document": true,
10
+ "WORKAREA": true,
11
+ "$": true,
12
+ "jQuery": true,
13
+ "_": true,
14
+ "feature": true,
15
+ "JST": true,
16
+ "Turbolinks": true,
17
+ "I18n": true,
18
+ "Chart": true,
19
+ "Dropzone": true,
20
+ "strftime": true,
21
+ "Waypoint": true,
22
+ "wysihtml": true,
23
+ "LocalTime": true,
24
+ "describe": true,
25
+ "after": true,
26
+ "afterEach": true,
27
+ "before": true,
28
+ "beforeEach": true,
29
+ "it": true,
30
+ "expect": true,
31
+ "sinon": true,
32
+ "fixture": true,
33
+ "chai": true
34
+ }
35
+ }
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve Workarea
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ ⚠️**Before you create**⚠️
11
+ Please verify the issue you're experiencing is not part of your Workarea project customizations. The best way to do this is with a [vanilla Workarea installation](https://developer.workarea.com/articles/create-a-new-host-application.html). This will help us spend time on fixes/improvements for the whole community. Thank you!
12
+
13
+ **Describe the bug**
14
+ A clear and concise description of what the bug is.
15
+
16
+ **To Reproduce**
17
+ Steps to reproduce the behavior:
18
+ 1. Go to '...'
19
+ 2. Click on '....'
20
+ 3. Scroll down to '....'
21
+ 4. See error
22
+
23
+ **Expected behavior**
24
+ A clear and concise description of what you expected to happen.
25
+
26
+ **Workarea Setup (please complete the following information):**
27
+ - Workarea Version: [e.g. v3.4.6]
28
+ - Plugins [e.g. workarea-blog, workarea-sitemaps]
29
+
30
+ **Attachments**
31
+ If applicable, add any attachments to help explain your problem, things like:
32
+ - screenshots
33
+ - Gemfile.lock
34
+ - test cases
35
+
36
+ **Additional context**
37
+ Add any other context about the problem here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Documentation request
3
+ about: Suggest documentation
4
+ title: ''
5
+ labels: documentation
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your documentation related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm confused by [...]
12
+
13
+ **Describe the article you'd like**
14
+ A clear and concise description of what would be in the documentation article.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for Workarea
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,64 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ paths-ignore:
5
+ - '.github/**'
6
+ - '**.md'
7
+
8
+ jobs:
9
+ static_analysis:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+ - uses: workarea-commerce/ci/bundler-audit@v1
14
+ - uses: workarea-commerce/ci/rubocop@v1
15
+ - uses: workarea-commerce/ci/eslint@v1
16
+ with:
17
+ args: '**/*.js'
18
+ - uses: workarea-commerce/ci/stylelint@v1
19
+ with:
20
+ args: '**/*.scss'
21
+
22
+ admin_tests:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v1
26
+ - uses: actions/setup-ruby@v1
27
+ with:
28
+ ruby-version: 2.6.x
29
+ - uses: workarea-commerce/ci/test@v1
30
+ with:
31
+ command: bin/rails app:workarea:test:admin
32
+
33
+ core_tests:
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - uses: actions/checkout@v1
37
+ - uses: actions/setup-ruby@v1
38
+ with:
39
+ ruby-version: 2.6.x
40
+ - uses: workarea-commerce/ci/test@v1
41
+ with:
42
+ command: bin/rails app:workarea:test:core
43
+
44
+ storefront_tests:
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - uses: actions/checkout@v1
48
+ - uses: actions/setup-ruby@v1
49
+ with:
50
+ ruby-version: 2.6.x
51
+ - uses: workarea-commerce/ci/test@v1
52
+ with:
53
+ command: bin/rails app:workarea:test:storefront
54
+
55
+ plugins_tests:
56
+ runs-on: ubuntu-latest
57
+ steps:
58
+ - uses: actions/checkout@v1
59
+ - uses: actions/setup-ruby@v1
60
+ with:
61
+ ruby-version: 2.6.x
62
+ - uses: workarea-commerce/ci/test@v1
63
+ with:
64
+ command: bin/rails app:workarea:test:plugins
@@ -0,0 +1,23 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/log/*.log
5
+ test/dummy/node_modules/
6
+ test/dummy/yarn-error.log
7
+ test/dummy/tmp/
8
+ .DS_Store
9
+ .byebug_history
10
+ .bundle/
11
+ .sass-cache/
12
+ Gemfile.lock
13
+ pkg/
14
+ test/dummy/tmp/
15
+ test/dummy/public/
16
+ log/*.log
17
+ test/dummy/log/*.log
18
+ test/dummy/db/*.sqlite3
19
+ test/dummy/db/*.sqlite3-journal
20
+ node_modules
21
+ package.json
22
+ yarn.lock
23
+ .rubocop-http*
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "stylelint-config-recommended-scss",
3
+ "rules": {
4
+ "block-no-empty": null,
5
+ "no-descending-specificity": null,
6
+ "property-no-unknown": [true, { "ignoreProperties": ["mso-hide"] }]
7
+ }
8
+ }
@@ -0,0 +1,17 @@
1
+ Workarea Zipco 1.0.0 (2020-03-19)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Deduct advanced payment tenders from zipco tendered amount
5
+
6
+ ZIPCO-2
7
+ Jeff Yucis
8
+
9
+ * Zip Payments Integration
10
+
11
+ Integrates with the zip payments api for checkout. Allows
12
+ for approved and referred order flow. Includes
13
+ tagline and landing pages for Zip Payments information.
14
+ Jeff Yucis
15
+
16
+
17
+
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in zipco.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ gem 'workarea', github: 'workarea-commerce/workarea', branch: 'v3.5-stable'
10
+
11
+ # Declare any dependencies that are still in development here instead of in
12
+ # your gemspec. These might include edge Rails or gems from your path or
13
+ # Git. Remember to move these dependencies to your gemspec before releasing
14
+ # your gem to rubygems.org.
15
+
16
+ # To use a debugger
17
+ gem 'pry', group: [:development, :test]
@@ -0,0 +1,51 @@
1
+ Workarea Zipco
2
+ ================================================================================
3
+
4
+ Zipco plugin for the Workarea platform.
5
+
6
+ Getting Started
7
+ --------------------------------------------------------------------------------
8
+
9
+ This gem contains a rails engine that must be mounted onto a host Rails application.
10
+
11
+ To access Workarea gems and source code, you must be an employee or a licensed retailer or partner.
12
+
13
+ Workarea gems are hosted privately at https://gems.weblinc.com/.
14
+ You must have individual or team credentials to install gems from this server. Add your gems server credentials to Bundler:
15
+
16
+ bundle config gems.weblinc.com my_username:my_password
17
+
18
+ Or set the appropriate environment variable in a shell startup file:
19
+
20
+ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
21
+
22
+ Then add the gem to your application's Gemfile specifying the source:
23
+
24
+ # ...
25
+ gem 'workarea-zipco', source: 'https://gems.weblinc.com'
26
+ # ...
27
+
28
+ Or use a source block:
29
+
30
+ # ...
31
+ source 'https://gems.weblinc.com' do
32
+ gem 'workarea-zipco'
33
+ end
34
+ # ...
35
+
36
+ Update your application's bundle.
37
+
38
+ cd path/to/application
39
+ bundle
40
+
41
+ Workarea Platform Documentation
42
+ --------------------------------------------------------------------------------
43
+
44
+ See [http://developer.workarea.com](http://developer.workarea.com) for Workarea platform documentation.
45
+
46
+ Copyright & Licensing
47
+ --------------------------------------------------------------------------------
48
+
49
+ Copyright Workarea 2019. All rights reserved.
50
+
51
+ For licensing, contact sales@workarea.com.
@@ -0,0 +1,59 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'Zipco'
11
+ rdoc.options << '--line-numbers'
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+ load 'rails/tasks/statistics.rake'
19
+ load 'workarea/changelog.rake'
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
31
+ require 'workarea/zipco/version'
32
+
33
+ desc "Release version #{Workarea::Zipco::VERSION} of the gem"
34
+ task :release do
35
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
36
+
37
+ Rake::Task['workarea:changelog'].execute
38
+ system 'git add CHANGELOG.md'
39
+ system 'git commit -m "Update CHANGELOG"'
40
+
41
+ system "git tag -a v#{Workarea::Zipco::VERSION} -m 'Tagging #{Workarea::Zipco::VERSION}'"
42
+ system 'git push origin HEAD --follow-tags'
43
+
44
+ system "gem build workarea-zipco.gemspec"
45
+ system "gem push workarea-zipco-#{Workarea::Zipco::VERSION}.gem"
46
+ system "gem push workarea-zipco-#{Workarea::Zipco::VERSION}.gem --host #{host}"
47
+ system "rm workarea-zipco-#{Workarea::Zipco::VERSION}.gem"
48
+ end
49
+
50
+ desc 'Run the JavaScript tests'
51
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
52
+ task teaspoon: 'app:teaspoon'
53
+
54
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
55
+ task :teaspoon_server do
56
+ Dir.chdir("test/dummy")
57
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
58
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
59
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ /*------------------------------------*\
2
+ #ZIPCO-ICON
3
+ \*------------------------------------*/
4
+
5
+ .zipco-icon {
6
+ height: 50px;
7
+ }
@@ -0,0 +1,11 @@
1
+ module Workarea
2
+ decorate Storefront::Checkout::PlaceOrderController, with: 'zipco' do
3
+ def place_order
4
+ if params[:payment] == 'zipco' && !current_checkout.payment.zipco?
5
+ redirect_to start_zipco_path and return
6
+ else
7
+ super
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,96 @@
1
+ module Workarea
2
+ class Storefront::ZipcoController < Storefront::ApplicationController
3
+ before_action :validate_checkout, only: :start
4
+
5
+ def start
6
+ zipco = Zipco::Setup.new(current_checkout)
7
+
8
+ if zipco.create_order_response.success?
9
+ zipco.set_checkout_data
10
+ redirect_to zipco.redirect_uri
11
+ else
12
+ flash[:error] = t('workarea.storefront.zipco.payment_error')
13
+ redirect_to(checkout_payment_path) && return
14
+ end
15
+ end
16
+
17
+ def complete
18
+ self.current_order = Order.where(zipco_order_id: params[:checkoutId]).first
19
+ if !can_checkout?(params[:result])
20
+ handle_negative_result
21
+ redirect_to unfinished_checkout_destination
22
+ return
23
+ end
24
+
25
+ # only check the inventory if immediate approval, approved referred orders
26
+ # have already captured the inventory.
27
+ check_inventory || return unless params[:result] == "approved" && current_order.zipco_referred?
28
+
29
+ place_order_result = Zipco::Checkout.new(current_checkout, current_user, params).complete
30
+
31
+ if place_order_result
32
+ complete_place_order
33
+ else
34
+ incomplete_place_order
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def can_checkout?(response_code)
41
+ ["approved", "referred"].include?(response_code)
42
+ end
43
+
44
+ def complete_place_order
45
+ Storefront::OrderMailer.confirmation(current_order.id).deliver_later unless current_order.zipco_referred?
46
+
47
+ self.completed_order = current_order
48
+ clear_current_order
49
+
50
+ flash[:success] = t('workarea.storefront.flash_messages.order_placed')
51
+ redirect_to finished_checkout_destination
52
+ end
53
+
54
+ def incomplete_place_order
55
+ flash[:error] = t('workarea.storefront.zipco.payment_error')
56
+
57
+ current_checkout.payment.clear_zipco!
58
+ redirect_to checkout_payment_path
59
+ end
60
+
61
+ def finished_checkout_destination
62
+ if current_admin.present? && current_admin.orders_access?
63
+ admin.order_path(completed_order)
64
+ else
65
+ checkout_confirmation_path
66
+ end
67
+ end
68
+
69
+ def unfinished_checkout_destination
70
+ if self.current_order.zipco_referred? && params[:result] == "declined"
71
+ cart_path
72
+ else
73
+ checkout_payment_path
74
+ end
75
+ end
76
+
77
+ def handle_negative_result
78
+ if params[:result] == "cancelled"
79
+ flash[:success] = t('workarea.storefront.zipco.cancelled_message')
80
+ elsif params[:result] == "declined"
81
+ flash[:success] = t('workarea.storefront.zipco.declined_message')
82
+ else
83
+ flash[:error] = t('workarea.storefront.zipco.payment_error')
84
+ end
85
+
86
+ # if order was declined from an referred state than cancel the order,
87
+ # otherwise simply clear out the zipco information.
88
+ if params[:result] == "declined" && self.current_order.zipco_referred?
89
+ CancelOrder.new(current_order, refund: false).perform
90
+ else
91
+ current_checkout.payment.clear_zipco!
92
+ current_order.clear_zipco!
93
+ end
94
+ end
95
+ end
96
+ end