solidus_six_saferpay 0.1.3 → 0.1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +12 -0
- data/Gemfile +33 -0
- data/LICENSE +26 -0
- data/README.md +33 -20
- data/Rakefile +4 -54
- data/app/assets/config/solidus_six_saferpay_manifest.js +1 -0
- data/app/assets/images/solidus_six_saferpay/.keep +0 -0
- data/app/assets/javascripts/spree/backend/solidus_six_saferpay.js +2 -0
- data/app/assets/javascripts/spree/frontend/solidus_six_saferpay.js +2 -0
- data/app/assets/stylesheets/solidus_six_saferpay/loading_animation.scss +0 -27
- data/app/assets/stylesheets/solidus_six_saferpay/payments.scss +4 -1
- data/app/assets/stylesheets/spree/backend/solidus_six_saferpay.css +4 -0
- data/app/assets/stylesheets/spree/frontend/solidus_six_saferpay.css +4 -0
- data/app/controllers/spree/solidus_six_saferpay/checkout_controller.rb +56 -10
- data/app/views/spree/checkout/payment/_saferpay_payment.html.erb +1 -1
- data/app/views/spree/six_saferpay_payments/_six_saferpay_payment.html.erb +2 -2
- data/bin/console +17 -0
- data/bin/rails +18 -0
- data/bin/rake +7 -0
- data/bin/setup +8 -0
- data/config/initializers/assets.rb +3 -0
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/fr.yml +1 -1
- data/config/routes.rb +2 -2
- data/lib/generators/solidus_six_saferpay/install/install_generator.rb +15 -3
- data/lib/solidus_six_saferpay.rb +6 -3
- data/lib/solidus_six_saferpay/configuration.rb +4 -7
- data/lib/solidus_six_saferpay/engine.rb +19 -10
- data/lib/solidus_six_saferpay/gateway.rb +13 -12
- data/lib/solidus_six_saferpay/version.rb +3 -1
- data/solidus_six_saferpay.gemspec +42 -0
- data/spec/controllers/spree/solidus_six_saferpay/checkout_controller_spec.rb +41 -0
- data/spec/controllers/spree/solidus_six_saferpay/payment_page/checkout_controller_spec.rb +205 -0
- data/spec/controllers/spree/solidus_six_saferpay/transaction/checkout_controller_spec.rb +228 -0
- data/spec/factories/payment_methods.rb +23 -0
- data/spec/factories/payments.rb +11 -0
- data/spec/factories/spree/six_saferpay_payments.rb +118 -0
- data/spec/models/spree/six_saferpay_payment_spec.rb +203 -0
- data/spec/rails_helper.rb +73 -0
- data/spec/services/spree/solidus_six_saferpay/assert_payment_page_spec.rb +148 -0
- data/spec/services/spree/solidus_six_saferpay/authorize_payment_spec.rb +39 -0
- data/spec/services/spree/solidus_six_saferpay/authorize_transaction_spec.rb +148 -0
- data/spec/services/spree/solidus_six_saferpay/initialize_payment_page_spec.rb +83 -0
- data/spec/services/spree/solidus_six_saferpay/initialize_payment_spec.rb +40 -0
- data/spec/services/spree/solidus_six_saferpay/initialize_transaction_spec.rb +85 -0
- data/spec/services/spree/solidus_six_saferpay/inquire_payment_page_payment_spec.rb +116 -0
- data/spec/services/spree/solidus_six_saferpay/inquire_payment_spec.rb +39 -0
- data/spec/services/spree/solidus_six_saferpay/inquire_transaction_payment_spec.rb +117 -0
- data/spec/services/spree/solidus_six_saferpay/payment_validator_spec.rb +100 -0
- data/spec/services/spree/solidus_six_saferpay/process_authorized_payment_spec.rb +39 -0
- data/spec/services/spree/solidus_six_saferpay/process_payment_page_payment_spec.rb +225 -0
- data/spec/services/spree/solidus_six_saferpay/process_transaction_payment_spec.rb +219 -0
- data/spec/solidus_six_saferpay/configuration_spec.rb +15 -0
- data/spec/solidus_six_saferpay/error_handler_spec.rb +65 -0
- data/spec/solidus_six_saferpay/gateway_response_spec.rb +70 -0
- data/spec/solidus_six_saferpay/gateway_spec.rb +378 -0
- data/spec/solidus_six_saferpay/payment_page_gateway_spec.rb +390 -0
- data/spec/solidus_six_saferpay/transaction_gateway_spec.rb +387 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/route_access.rb +6 -0
- data/spec/support/uses_payment_page_gateway.rb +29 -0
- data/spec/support/uses_transaction_gateway.rb +28 -0
- metadata +241 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2169c1b1f790ec1dcc28392c40f539850b50763f19b05aa8f081065c58cf45f
|
4
|
+
data.tar.gz: 664168547eb8918651455a7b63c0c7ab97e641fdd9495041ce7a4aefbbbff0b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b39396e4cc40b5329e510c9744564ad0296a756ab4ff6e467bee60bc44b7825ff5359b4aebde2ea479ded6f986b96c02f44ea527ef77d022da8e87dd02d10810
|
7
|
+
data.tar.gz: 582f78f26f3ea9b03e99f9ad28a95551ededba3c38003085a4d0952afffbc381a2317859df484948d98bc0a5e58d28ca510a1a890406b39552cb394047f16469
|
@@ -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
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
data/.rspec
ADDED
data/.rubocop.yml
ADDED
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
|
-
|
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
|
-
|
16
|
+
Bundle your dependencies and run the installation generator:
|
16
17
|
|
17
|
-
```
|
18
|
-
|
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
|
-
##
|
220
|
-
|
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
|
-
#
|
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
|
-
|
3
|
+
require 'solidus_dev_support/rake_tasks'
|
4
|
+
SolidusDevSupport::RakeTasks.install
|
8
5
|
|
9
|
-
|
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'
|
File without changes
|
@@ -1,30 +1,3 @@
|
|
1
1
|
.saferpay-iframe {
|
2
2
|
width: 100%;
|
3
3
|
}
|
4
|
-
|
5
|
-
.loading-animation {
|
6
|
-
text-align: center;
|
7
|
-
background-color: #222222;
|
8
|
-
|
9
|
-
-webkit-animation: sk-scaleout 0.5s infinite ease-in-out;
|
10
|
-
animation: sk-scaleout 0.5s infinite ease-in-out;
|
11
|
-
}
|
12
|
-
|
13
|
-
@-webkit-keyframes sk-scaleout {
|
14
|
-
0% { -webkit-transform: scale(0) }
|
15
|
-
100% {
|
16
|
-
-webkit-transform: scale(0.2);
|
17
|
-
opacity: 0;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
@keyframes sk-scaleout {
|
22
|
-
0% {
|
23
|
-
-webkit-transform: scale(0);
|
24
|
-
transform: scale(0);
|
25
|
-
} 100% {
|
26
|
-
-webkit-transform: scale(0.2);
|
27
|
-
transform: scale(0.2);
|
28
|
-
opacity: 0;
|
29
|
-
}
|
30
|
-
}
|
@@ -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,10 +21,28 @@ 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?
|
23
|
-
raise Spree::Core::GatewayError, t('.
|
45
|
+
raise Spree::Core::GatewayError, t('.saferpay_payment_not_found')
|
24
46
|
end
|
25
47
|
|
26
48
|
# NOTE: PaymentPage payments are authorized directly. Instead, we
|
@@ -38,7 +60,7 @@ module Spree
|
|
38
60
|
|
39
61
|
processed_authorization = process_authorization(saferpay_payment)
|
40
62
|
if processed_authorization.success?
|
41
|
-
|
63
|
+
handle_payment_processing_success
|
42
64
|
else
|
43
65
|
flash[:error] = processed_authorization.user_message
|
44
66
|
end
|
@@ -48,17 +70,30 @@ module Spree
|
|
48
70
|
flash[:error] = payment_inquiry.user_message
|
49
71
|
end
|
50
72
|
|
51
|
-
@redirect_path
|
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
|
90
|
+
payment_inquiry = inquire_payment(saferpay_payment)
|
91
|
+
flash[:error] = payment_inquiry.user_message
|
92
|
+
else
|
93
|
+
flash[:error] = I18n.t(:general_error, scope: [:solidus_six_saferpay, :errors])
|
94
|
+
end
|
59
95
|
|
60
96
|
@redirect_path = order_checkout_path(:payment)
|
61
|
-
flash[:error] = payment_inquiry.user_message
|
62
97
|
render :iframe_breakout_redirect, layout: false
|
63
98
|
end
|
64
99
|
|
@@ -80,9 +115,20 @@ module Spree
|
|
80
115
|
raise NotImplementedError, "Must be implemented in PaymentPageCheckoutController or TransactionCheckoutController"
|
81
116
|
end
|
82
117
|
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
86
132
|
end
|
87
133
|
|
88
134
|
def order_checkout_path(state)
|