solidus_six_saferpay 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +35 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/stale.yml +17 -0
  5. data/.gitignore +18 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +2 -0
  8. data/.travis.yml +12 -0
  9. data/Gemfile +33 -0
  10. data/LICENSE +26 -0
  11. data/README.md +33 -20
  12. data/Rakefile +4 -54
  13. data/app/assets/config/solidus_six_saferpay_manifest.js +1 -0
  14. data/app/assets/images/solidus_six_saferpay/.keep +0 -0
  15. data/app/assets/javascripts/spree/backend/solidus_six_saferpay.js +2 -0
  16. data/app/assets/javascripts/spree/frontend/solidus_six_saferpay.js +2 -0
  17. data/app/assets/stylesheets/spree/backend/solidus_six_saferpay.css +4 -0
  18. data/app/assets/stylesheets/spree/frontend/solidus_six_saferpay.css +4 -0
  19. data/app/controllers/spree/solidus_six_saferpay/checkout_controller.rb +49 -7
  20. data/bin/console +17 -0
  21. data/bin/rails +18 -0
  22. data/bin/rake +7 -0
  23. data/bin/setup +8 -0
  24. data/config/initializers/assets.rb +3 -0
  25. data/config/routes.rb +2 -2
  26. data/lib/generators/solidus_six_saferpay/install/install_generator.rb +15 -3
  27. data/lib/solidus_six_saferpay.rb +6 -3
  28. data/lib/solidus_six_saferpay/configuration.rb +4 -7
  29. data/lib/solidus_six_saferpay/engine.rb +19 -10
  30. data/lib/solidus_six_saferpay/version.rb +3 -1
  31. data/solidus_six_saferpay.gemspec +42 -0
  32. data/spec/controllers/spree/solidus_six_saferpay/checkout_controller_spec.rb +41 -0
  33. data/spec/controllers/spree/solidus_six_saferpay/payment_page/checkout_controller_spec.rb +205 -0
  34. data/spec/controllers/spree/solidus_six_saferpay/transaction/checkout_controller_spec.rb +228 -0
  35. data/spec/factories/payment_methods.rb +23 -0
  36. data/spec/factories/payments.rb +11 -0
  37. data/spec/factories/spree/six_saferpay_payments.rb +118 -0
  38. data/spec/models/spree/six_saferpay_payment_spec.rb +203 -0
  39. data/spec/rails_helper.rb +73 -0
  40. data/spec/services/spree/solidus_six_saferpay/assert_payment_page_spec.rb +148 -0
  41. data/spec/services/spree/solidus_six_saferpay/authorize_payment_spec.rb +39 -0
  42. data/spec/services/spree/solidus_six_saferpay/authorize_transaction_spec.rb +148 -0
  43. data/spec/services/spree/solidus_six_saferpay/initialize_payment_page_spec.rb +83 -0
  44. data/spec/services/spree/solidus_six_saferpay/initialize_payment_spec.rb +40 -0
  45. data/spec/services/spree/solidus_six_saferpay/initialize_transaction_spec.rb +85 -0
  46. data/spec/services/spree/solidus_six_saferpay/inquire_payment_page_payment_spec.rb +116 -0
  47. data/spec/services/spree/solidus_six_saferpay/inquire_payment_spec.rb +39 -0
  48. data/spec/services/spree/solidus_six_saferpay/inquire_transaction_payment_spec.rb +117 -0
  49. data/spec/services/spree/solidus_six_saferpay/payment_validator_spec.rb +100 -0
  50. data/spec/services/spree/solidus_six_saferpay/process_authorized_payment_spec.rb +39 -0
  51. data/spec/services/spree/solidus_six_saferpay/process_payment_page_payment_spec.rb +225 -0
  52. data/spec/services/spree/solidus_six_saferpay/process_transaction_payment_spec.rb +219 -0
  53. data/spec/solidus_six_saferpay/configuration_spec.rb +15 -0
  54. data/spec/solidus_six_saferpay/error_handler_spec.rb +65 -0
  55. data/spec/solidus_six_saferpay/gateway_response_spec.rb +70 -0
  56. data/spec/solidus_six_saferpay/gateway_spec.rb +378 -0
  57. data/spec/solidus_six_saferpay/payment_page_gateway_spec.rb +390 -0
  58. data/spec/solidus_six_saferpay/transaction_gateway_spec.rb +387 -0
  59. data/spec/spec_helper.rb +21 -0
  60. data/spec/support/route_access.rb +6 -0
  61. data/spec/support/uses_payment_page_gateway.rb +29 -0
  62. data/spec/support/uses_transaction_gateway.rb +28 -0
  63. metadata +241 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7202fabe3b8884bc1ab183e397f2ff18c419acd6c654ae75460b25f4c90fe470
4
- data.tar.gz: 1e49380bf2304bd3694b307ee6231a73c212f3af216bf24bf44a4dd31f369f8a
3
+ metadata.gz: 96b400cf874bdda08cfb33f3030d266f58444ec30e8e002ece965b5cb3ae83e3
4
+ data.tar.gz: c1b05c8a67b4399814684d412c0fed4f60903a62d102bbda5d2929ba5ac81a4d
5
5
  SHA512:
6
- metadata.gz: 6467caba523bb6a51aed70eeacf38f2b45e2bc9b0b9a2c5d43d23e4777ae89cca00bbce71312ce108cb2ce981d8bcf4cc1efebcef8a1abececa3c8170ff87550
7
- data.tar.gz: 2b2ee111227b9b7df5de845d3ad471916ac73557379e5d77a7ccf43fac6d6ef4523f4b9d4d69f5c9f5aac8dd32093d37c0c3065cdab035a4c86d4bea98ab8147
6
+ metadata.gz: dc50f1d3e2be9d70f340b78a9f12f9fbd2cd7b531862fa56c0fbe1c9717cf44e067d1b74f31899532988bea30280ad7e25688348534e02c4712e4634cada9b0b
7
+ data.tar.gz: 545277b46dbb2bb516e04c90903b3b8878b031a0a741f29361bd1af71c9d9395e055035d512c4c2f1207c58a5416dc831b0ee3f0ccb459cf6a7b12c1317d72f4
@@ -0,0 +1,35 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Always take the latest version of the orb, this allows us to
5
+ # run specs against Solidus supported versions only without the need
6
+ # to change this configuration every time a Solidus version is released
7
+ # or goes EOL.
8
+ solidusio_extensions: solidusio/extensions@volatile
9
+
10
+ jobs:
11
+ run-specs-with-postgres:
12
+ executor: solidusio_extensions/postgres
13
+ steps:
14
+ - solidusio_extensions/run-tests
15
+ run-specs-with-mysql:
16
+ executor: solidusio_extensions/mysql
17
+ steps:
18
+ - solidusio_extensions/run-tests
19
+
20
+ workflows:
21
+ "Run specs on supported Solidus versions":
22
+ jobs:
23
+ - run-specs-with-postgres
24
+ - run-specs-with-mysql
25
+ "Weekly run specs against master":
26
+ triggers:
27
+ - schedule:
28
+ cron: "0 0 * * 4" # every Thursday
29
+ filters:
30
+ branches:
31
+ only:
32
+ - master
33
+ jobs:
34
+ - run-specs-with-postgres
35
+ - run-specs-with-mysql
data/.gem_release.yml ADDED
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_six_saferpay/version.rb'
4
+ message: Bump SolidusSixSaferpay to %{version}
5
+ tag: true
data/.github/stale.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
16
+ spec/examples.txt
17
+
18
+ sandbox
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ require:
2
+ - solidus_dev_support/rubocop
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.5.1
4
+ before_install:
5
+ - gem install bundler -v 2.0.1
6
+ script:
7
+ - bin/rake extension:test_app
8
+ - bin/rake extension:specs
9
+ notifications:
10
+ slack:
11
+ secure: Vpuu/JENlZAiH67DU5bFmyKlKNmhiAZ0wSd6mjFyzcFAXaEbFIt9xkMigoEwLfQh/ZMUvKQcv3oQ6s9j5FkYImRZ0gfs1me7z/H8NTXMF5eOu7aS/gRHMGq8x2nvDBqNhSVtffqLfF3aydjZPJvGz8cvAQtqw4b+qOSIuxs2BOpcMMgEZEXW7Py6AthY2p1jxByyiqGB7NcvKsQedVtgdrnK4j+jcwK6Q9/DTOMivhWLEWAvn6VJ5zMomM5FdOFfH86uhHASGYB72ufpmKUwmFASSNHBM3CNQhZ0O/LS+a1dOlaW1BhU5q6KS/q6vgEYHyjdqcD7HhKFdlaVm6W/N1lbX+MFFcFT++l6CN8Aa3xmYpy/zWO5wwBRZw0zhYT/7P4BRoCll1D7RetnGcIV6KJyC0ydn2u/pi1kKBOgzuwbgQ+pH/lPH9+HuZzlhynRBdz2v45ctXf6AFQZmfJvFEBNwb38Q08zzGcCru0+Lu4uhFFLEwi2oMCWtpUsk0PfUJf/cUfp0hluh8wZsQWe+VQOS1NjmL8/yxjijFGzmS8WmMTb+fw7bRXFir0ecdntbP9aAhJxBN4PaMfYEFzBjCbc1e2gmwXk0VBV/0IH9hxxzIorUSmGydrWLDWiap0yDC2bm+gndodxKawT4+O45qB9jI5aYXG6JlHzrTn8QU4=
12
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # Needed to help Bundler figure out how to resolve dependencies,
10
+ # otherwise it takes forever to resolve them.
11
+ # See https://github.com/bundler/bundler/issues/6677
12
+ gem 'rails', '>0.a'
13
+
14
+ # Provides basic authentication functionality for testing parts of your engine
15
+ gem 'solidus_auth_devise'
16
+
17
+ case ENV['DB']
18
+ when 'mysql'
19
+ gem 'mysql2'
20
+ when 'postgresql'
21
+ gem 'pg'
22
+ else
23
+ gem 'sqlite3'
24
+ end
25
+
26
+ gemspec
27
+
28
+ # Use a local Gemfile to include development dependencies that might not be
29
+ # relevant for the project or for other contributors, e.g. pry-byebug.
30
+ #
31
+ # We use `send` instead of calling `eval_gemfile` to work around an issue with
32
+ # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
33
+ send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2020 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -1,33 +1,23 @@
1
1
  # SolidusSixSaferpay
2
+
2
3
  The `solidus_six_saferpay` engine adds checkout options for the Saferpay Payment Page ([Integration Guide](https://saferpay.github.io/sndbx/Integration_PP.html), [JSON API documentation](http://saferpay.github.io/jsonapi/#ChapterPaymentPage)) and the Saferpay Transaction ([Integration Guide](https://saferpay.github.io/sndbx/Integration_trx.html), [JSON API documentation](https://saferpay.github.io/sndbx/Integration_trx.html)).
3
4
 
4
5
  ## Status
5
6
  Travis CI status: [![Build Status](https://travis-ci.org/fadendaten/solidus_six_saferpay.svg?branch=master)](https://travis-ci.org/fadendaten/solidus_six_saferpay)
6
7
 
7
-
8
8
  ## Installation
9
- Add this line to your application's Gemfile:
9
+
10
+ Add solidus_six_saferpay to your Gemfile:
10
11
 
11
12
  ```ruby
12
13
  gem 'solidus_six_saferpay'
13
14
  ```
14
15
 
15
- And then execute:
16
+ Bundle your dependencies and run the installation generator:
16
17
 
17
- ```bash
18
- $ bundle
19
- ```
20
-
21
- Or install it yourself as:
22
-
23
- ```bash
24
- $ gem install solidus_six_saferpay
25
- ```
26
-
27
- After installing the gem, copy the migrations to your host application and migrate:
28
-
29
- ```bash
30
- $ bundle exec rails g solidus_six_saferpay:install
18
+ ```shell
19
+ bundle
20
+ bundle exec rails g solidus_six_saferpay:install
31
21
  ```
32
22
 
33
23
  Add the following javascript to your `application.js` manifest file below the `//= require spree` line:
@@ -60,7 +50,6 @@ Spree::Core::Engine.routes.default_url_options { 'http://localhost:3000' }
60
50
  Spree::Core::Engine.routes.default_url_options { 'https://url-to-your-solidus-shop.tld' }
61
51
  ```
62
52
 
63
-
64
53
  ## Configuration and Usage
65
54
  After adding the `solidus_six_saferpay` gem to your Solidus Rails app, you can create new payment methods `Saferpay Payment Page` and `Saferpay Transaction` in the admin backend under "Settings" > "Payment". When adding a new Saferpay payment method, you can configure the payment method with the information you have received from SIX when creating a new test account.
66
55
 
@@ -212,9 +201,33 @@ When the user confirms the purchase in the checkout process, the saferpay paymen
212
201
  #### Checkout: Payment Cancel
213
202
  When a user cancels a payment, the `CheckoutController` receives a `fail` request and handles this request in the `#fail` action. The result is that the user is shown an error message stating that the payment was aborted.
214
203
 
204
+
205
+ ## Testing
206
+
207
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
208
+
209
+ ```shell
210
+ bundle
211
+ bin/rake
212
+ ```
213
+
214
+ When testing your application's integration with this extension you may use its factories.
215
+ Simply add this require statement to your spec_helper:
216
+
217
+ ```ruby
218
+ require 'solidus_six_saferpay/factories'
219
+ ```
220
+
215
221
  ## Contributing
216
222
  This gem is available for everyone to use, however chances are that its implementation is still tailored towards our custom solidus-based shop.
217
223
  If you see improvements to be made, feel free to fork the gem and submit pull requests. All incoming pull requests will be discussed, but it's possible that we will reject pull requests that break functionality for our use case.
218
224
 
219
- ## License
220
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
225
+ ## Releasing
226
+
227
+ Your new extension version can be released using `gem-release` like this:
228
+
229
+ ```shell
230
+ bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release
231
+ ```
232
+
233
+ Copyright (c) 2020 fadendaten GmbH, released under the New BSD License
data/Rakefile CHANGED
@@ -1,56 +1,6 @@
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
1
+ # frozen_string_literal: true
6
2
 
7
- # require 'rdoc/task'
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
8
5
 
9
- # RDoc::Task.new(:rdoc) do |rdoc|
10
- # rdoc.rdoc_dir = 'rdoc'
11
- # rdoc.title = 'SolidusSixSaferpay'
12
- # rdoc.options << '--line-numbers'
13
- # rdoc.rdoc_files.include('README.md')
14
- # rdoc.rdoc_files.include('lib/**/*.rb')
15
- # end
16
-
17
- # APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
- # load 'rails/tasks/engine.rake'
19
-
20
- # load 'rails/tasks/statistics.rake'
21
-
22
- # require 'bundler/gem_tasks'
23
-
24
- # require 'rspec/core/rake_task'
25
- # RSpec::Core::RakeTask.new(:spec)
26
-
27
- # task default: :spec
28
-
29
- require 'bundler'
30
-
31
- Bundler::GemHelper.install_tasks
32
-
33
- begin
34
- require 'spree/testing_support/extension_rake'
35
- require 'rspec/core/rake_task'
36
-
37
- RSpec::Core::RakeTask.new(:spec)
38
-
39
- # task default: %i(first_run spec)
40
- task default: %i(first_run spec)
41
- rescue LoadError
42
- # no rspec available
43
- end
44
-
45
- task :first_run do
46
- if Dir['spec/dummy'].empty?
47
- Rake::Task[:test_app].invoke
48
- Dir.chdir('../../')
49
- end
50
- end
51
-
52
- desc 'Generates a dummy app for testing'
53
- task :test_app do
54
- ENV['LIB_NAME'] = 'solidus_six_saferpay'
55
- Rake::Task['extension:test_app'].invoke
56
- end
6
+ task default: 'extension:specs'
@@ -1,2 +1,3 @@
1
+ //= link_tree ../images
1
2
  //= link_directory ../javascripts/solidus_six_saferpay .js
2
3
  //= link_directory ../stylesheets/solidus_six_saferpay .css
File without changes
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -2,9 +2,13 @@ module Spree
2
2
  module SolidusSixSaferpay
3
3
  class CheckoutController < StoreController
4
4
 
5
- before_action :load_order
6
-
7
5
  def init
6
+ # loading the order is not shared between actions because the success
7
+ # action must break out of the iframe
8
+ @order = current_order
9
+ redirect_to(spree.cart_path) && return unless @order
10
+
11
+
8
12
  payment_method = Spree::PaymentMethod.find(params[:payment_method_id])
9
13
  initialized_payment = initialize_payment(@order, payment_method)
10
14
 
@@ -17,6 +21,24 @@ module Spree
17
21
  end
18
22
 
19
23
  def success
24
+ # loading the order is not shared between actions because the success
25
+ # action must break out of the iframe
26
+ @order = current_order
27
+ if @order.nil?
28
+ @redirect_path = spree.cart_path
29
+ render :iframe_breakout_redirect, layout: false
30
+ return
31
+ end
32
+
33
+ # ensure that completed orders don't try to reprocess the
34
+ # authorization. This could happen if a user presses the back button
35
+ # after completing an order.
36
+ if @order.completed?
37
+ @redirect_path = spree.cart_path
38
+ render :iframe_breakout_redirect, layout: false
39
+ return
40
+ end
41
+
20
42
  saferpay_payment = Spree::SixSaferpayPayment.where(order_id: @order.id).order(:created_at).last
21
43
 
22
44
  if saferpay_payment.nil?
@@ -38,7 +60,7 @@ module Spree
38
60
 
39
61
  processed_authorization = process_authorization(saferpay_payment)
40
62
  if processed_authorization.success?
41
- @order.next! if @order.payment?
63
+ handle_payment_processing_success
42
64
  else
43
65
  flash[:error] = processed_authorization.user_message
44
66
  end
@@ -48,11 +70,20 @@ module Spree
48
70
  flash[:error] = payment_inquiry.user_message
49
71
  end
50
72
 
51
- @redirect_path = order_checkout_path(@order.state)
73
+ @redirect_path ||= order_checkout_path(@order.state)
52
74
  render :iframe_breakout_redirect, layout: false
53
75
  end
54
76
 
55
77
  def fail
78
+ # loading the order is not shared between actions because the success
79
+ # action must break out of the iframe
80
+ @order = current_order
81
+ if @order.nil?
82
+ @redirect_path = spree.cart_path
83
+ render :iframe_breakout_redirect, layout: false
84
+ return
85
+ end
86
+
56
87
  saferpay_payment = Spree::SixSaferpayPayment.where(order_id: @order.id).order(:created_at).last
57
88
 
58
89
  if saferpay_payment
@@ -84,9 +115,20 @@ module Spree
84
115
  raise NotImplementedError, "Must be implemented in PaymentPageCheckoutController or TransactionCheckoutController"
85
116
  end
86
117
 
87
- def load_order
88
- @order = current_order
89
- redirect_to(spree.cart_path) && return unless @order
118
+ # Allows overriding of success behaviour in host application by setting
119
+ # SolidusSixSaferpay.config.payment_processing_success_handler
120
+ #
121
+ # By default, it will ensure that the order state is no longer "payment"
122
+ #
123
+ # Example
124
+ # config.payment_processing_success_handler = Proc.new { |order| puts "Order #{order} has been successfully paid!" }
125
+ #
126
+ def handle_payment_processing_success
127
+ if success_handler = ::SolidusSixSaferpay.config.payment_processing_success_handler.presence
128
+ success_handler.call(self, @order)
129
+ else
130
+ @order.next! if @order.payment?
131
+ end
90
132
  end
91
133
 
92
134
  def order_checkout_path(state)