solidus_six_saferpay 0.1.8 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +3 -0
- data/app/assets/javascripts/solidus_six_saferpay/saferpay_payment.js +4 -1
- data/app/controllers/spree/solidus_six_saferpay/checkout_controller.rb +65 -41
- data/app/controllers/spree/solidus_six_saferpay/transaction/checkout_controller.rb +1 -1
- data/app/models/spree/payment_method/saferpay_payment_method.rb +1 -1
- data/app/models/spree/payment_method/saferpay_payment_page.rb +2 -2
- data/app/models/spree/payment_method/saferpay_transaction.rb +2 -2
- data/app/services/spree/solidus_six_saferpay/cancel_authorized_payment.rb +33 -0
- data/app/services/spree/solidus_six_saferpay/initialize_payment.rb +0 -1
- data/app/services/spree/solidus_six_saferpay/initialize_transaction.rb +0 -1
- data/app/services/spree/solidus_six_saferpay/inquire_payment.rb +27 -1
- data/app/services/spree/solidus_six_saferpay/order_not_found_handler.rb +28 -0
- data/app/services/spree/solidus_six_saferpay/payment_not_found_handler.rb +28 -0
- data/app/services/spree/solidus_six_saferpay/payment_processing_success_handler.rb +26 -0
- data/app/views/spree/checkout/payment/_saferpay_payment.html.erb +2 -2
- data/app/views/spree/solidus_six_saferpay/checkout/{iframe_breakout_redirect.html.erb → iframe_breakout_redirect.erb} +1 -1
- data/config/locales/de.yml +3 -0
- data/config/locales/en.yml +3 -0
- data/config/locales/fr.yml +3 -0
- data/config/routes.rb +6 -6
- data/lib/solidus_six_saferpay/configuration.rb +0 -2
- data/lib/solidus_six_saferpay/gateway.rb +11 -11
- data/lib/solidus_six_saferpay/payment_page_gateway.rb +8 -9
- data/lib/solidus_six_saferpay/transaction_gateway.rb +8 -9
- data/lib/solidus_six_saferpay/version.rb +1 -1
- data/solidus_six_saferpay.gemspec +2 -1
- data/spec/controllers/spree/solidus_six_saferpay/payment_page/checkout_controller_spec.rb +8 -197
- data/spec/controllers/spree/solidus_six_saferpay/transaction/checkout_controller_spec.rb +8 -220
- data/spec/services/spree/solidus_six_saferpay/assert_payment_page_spec.rb +2 -128
- data/spec/services/spree/solidus_six_saferpay/authorize_transaction_spec.rb +3 -127
- data/spec/services/spree/solidus_six_saferpay/cancel_authorized_payment_spec.rb +58 -0
- data/spec/services/spree/solidus_six_saferpay/initialize_payment_page_spec.rb +0 -2
- data/spec/services/spree/solidus_six_saferpay/initialize_transaction_spec.rb +0 -1
- data/spec/services/spree/solidus_six_saferpay/inquire_payment_page_payment_spec.rb +2 -98
- data/spec/services/spree/solidus_six_saferpay/inquire_transaction_payment_spec.rb +2 -98
- data/spec/services/spree/solidus_six_saferpay/order_not_found_handler_spec.rb +30 -0
- data/spec/services/spree/solidus_six_saferpay/payment_not_found_handler_spec.rb +30 -0
- data/spec/services/spree/solidus_six_saferpay/payment_processing_success_handler_spec.rb +34 -0
- data/spec/services/spree/solidus_six_saferpay/process_payment_page_payment_spec.rb +1 -206
- data/spec/services/spree/solidus_six_saferpay/process_transaction_payment_spec.rb +1 -200
- data/spec/solidus_six_saferpay/configuration_spec.rb +0 -3
- data/spec/solidus_six_saferpay/gateway_spec.rb +1 -14
- data/spec/solidus_six_saferpay/payment_page_gateway_spec.rb +16 -14
- data/spec/solidus_six_saferpay/transaction_gateway_spec.rb +17 -14
- data/spec/support/shared_examples/authorize_payment.rb +132 -0
- data/spec/support/shared_examples/checkout_controller.rb +294 -0
- data/spec/support/shared_examples/inquire_payment.rb +118 -0
- data/spec/support/shared_examples/process_authorized_payment.rb +202 -0
- metadata +41 -10
- data/app/services/spree/solidus_six_saferpay/inquire_transaction.rb +0 -7
- data/spec/controllers/spree/solidus_six_saferpay/checkout_controller_spec.rb +0 -41
data/config/locales/de.yml
CHANGED
@@ -5,7 +5,9 @@ de:
|
|
5
5
|
checkout: &checkout
|
6
6
|
init:
|
7
7
|
checkout_not_initialized: Zahlung konnte nicht gestartet werden.
|
8
|
+
order_was_modified_after_confirmation: Bestellung wurde nach der Bestätigung verändert. Bitte starten Sie den Zahlungsvorgang erneut.
|
8
9
|
success:
|
10
|
+
error_while_processing_payment: Beim Verarbeiten der Bezahlung ist ein Fehler aufgetreten. Bitte starten Sie den Zahlungsvorgang erneut.
|
9
11
|
saferpay_payment_not_found: Six Saferpay Zahlung kann nicht gefunden werden.
|
10
12
|
fail:
|
11
13
|
payment_failed: Die Zahlung konnte nicht abgeschlossen werden.
|
@@ -19,6 +21,7 @@ de:
|
|
19
21
|
errors:
|
20
22
|
general_error: Bezahlungsfehler
|
21
23
|
liability_shift_not_granted: Haftungsumkehr wurde abgelehnt
|
24
|
+
saferpay_payment_not_found: Saferpay Payment konnte nicht gefunden werden
|
22
25
|
six_saferpay:
|
23
26
|
error_names:
|
24
27
|
ACTION_NOT_SUPPORTED: Die angeforderte Aktion wird im Kontext der Aktion nicht unterstützt un kann mit den Anforderungsdaten nicht ausgeführt werden.
|
data/config/locales/en.yml
CHANGED
@@ -5,7 +5,9 @@ en:
|
|
5
5
|
checkout: &checkout
|
6
6
|
init:
|
7
7
|
checkout_not_initialized: Payment could not be initialized.
|
8
|
+
order_was_modified_after_confirmation: Order was modified after confirmation. Please restart the checkout process.
|
8
9
|
success:
|
10
|
+
error_while_processing_payment: An error occurred while processing the payment. Please restart the checkout process.
|
9
11
|
saferpay_payment_not_found: Six Saferpay payment can not be found.
|
10
12
|
fail:
|
11
13
|
payment_failed: The payment could not be completed.
|
@@ -19,6 +21,7 @@ en:
|
|
19
21
|
errors:
|
20
22
|
general_error: Payment Error
|
21
23
|
liability_shift_not_granted: Liability Shift was rejected
|
24
|
+
saferpay_payment_not_found: Saferpay Payment could not be found
|
22
25
|
six_saferpay:
|
23
26
|
error_names:
|
24
27
|
ACTION_NOT_SUPPORTED: The requested action is not supported in the given context or the action can't be executed with the request data.
|
data/config/locales/fr.yml
CHANGED
@@ -5,7 +5,9 @@ fr:
|
|
5
5
|
checkout: &checkout
|
6
6
|
init:
|
7
7
|
checkout_not_initialized: Le paiement n'a pas pu être initialisé.
|
8
|
+
order_was_modified_after_confirmation: La commande a été modifiée après confirmation. Veuillez redémarrer le processus de paiement.
|
8
9
|
success:
|
10
|
+
error_while_processing_payment: Une erreur s'est produite lors du traitement du paiement. Veuillez redémarrer le processus de paiement.
|
9
11
|
saferpay_payment_not_found: Paiement Six Saferpay est introuvable.
|
10
12
|
fail:
|
11
13
|
payment_failed: Le paiement n'a pas pu être complété.
|
@@ -18,6 +20,7 @@ fr:
|
|
18
20
|
solidus_six_saferpay:
|
19
21
|
errors:
|
20
22
|
liability_shift_not_granted: Le transfert de responsabilité a été rejeté
|
23
|
+
saferpay_payment_not_found: Saferpay Payment est introuvable
|
21
24
|
six_saferpay:
|
22
25
|
error_names:
|
23
26
|
ACTION_NOT_SUPPORTED: l'action demandé n'es pas prise en charge dans le contexte de l'action et ne peut pas être exécutée avec les données de la demande.
|
data/config/routes.rb
CHANGED
@@ -3,15 +3,15 @@
|
|
3
3
|
Spree::Core::Engine.routes.draw do
|
4
4
|
namespace :solidus_six_saferpay do
|
5
5
|
namespace :payment_page do
|
6
|
-
get :init,
|
7
|
-
get :success,
|
8
|
-
get :fail,
|
6
|
+
get 'init/:order_number', to: 'checkout#init', as: :init, defaults: { format: :json }
|
7
|
+
get 'success/:order_number', to: 'checkout#success', as: :success
|
8
|
+
get 'fail/:order_number', to: 'checkout#fail', as: :fail
|
9
9
|
end
|
10
10
|
|
11
11
|
namespace :transaction do
|
12
|
-
get :init,
|
13
|
-
get :success,
|
14
|
-
get :fail,
|
12
|
+
get 'init/:order_number', to: 'checkout#init', as: :init, defaults: { format: :json }
|
13
|
+
get 'success/:order_number', to: 'checkout#success', as: :success
|
14
|
+
get 'fail/:order_number', to: 'checkout#fail', as: :fail
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -5,9 +5,6 @@ module SolidusSixSaferpay
|
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
SixSaferpay.configure do |config|
|
8
|
-
config.success_url = options.fetch(:success_url)
|
9
|
-
config.fail_url = options.fetch(:fail_url)
|
10
|
-
|
11
8
|
# Allow config via ENV for static values
|
12
9
|
config.customer_id = options.fetch(:customer_id) { ENV.fetch('SIX_SAFERPAY_CUSTOMER_ID') }
|
13
10
|
config.terminal_id = options.fetch(:terminal_id) { ENV.fetch('SIX_SAFERPAY_TERMINAL_ID') }
|
@@ -43,7 +40,7 @@ module SolidusSixSaferpay
|
|
43
40
|
capture(amount, saferpay_payment.transaction_id, options)
|
44
41
|
end
|
45
42
|
|
46
|
-
def capture(
|
43
|
+
def capture(_amount, transaction_id, options={})
|
47
44
|
transaction_reference = SixSaferpay::TransactionReference.new(transaction_id: transaction_id)
|
48
45
|
payment_capture = SixSaferpay::SixTransaction::Capture.new(transaction_reference: transaction_reference)
|
49
46
|
|
@@ -82,15 +79,14 @@ module SolidusSixSaferpay
|
|
82
79
|
end
|
83
80
|
|
84
81
|
# aliased to #refund for compatibility with solidus internals
|
85
|
-
def credit(
|
86
|
-
refund(
|
82
|
+
def credit(amount_cents, transaction_id, options = {})
|
83
|
+
refund(amount_cents, transaction_id, options)
|
87
84
|
end
|
88
85
|
|
89
|
-
def refund(
|
86
|
+
def refund(amount_cents, transaction_id, options = {})
|
90
87
|
payment = Spree::Payment.find_by!(response_code: transaction_id)
|
91
|
-
refund_amount = Spree::Money.new(amount, currency: payment.currency)
|
92
88
|
|
93
|
-
saferpay_amount = SixSaferpay::Amount.new(value:
|
89
|
+
saferpay_amount = SixSaferpay::Amount.new(value: amount_cents, currency_code: payment.currency)
|
94
90
|
saferpay_refund = SixSaferpay::Refund.new(amount: saferpay_amount, order_id: payment.order.number)
|
95
91
|
capture_reference = SixSaferpay::CaptureReference.new(capture_id: payment.transaction_id)
|
96
92
|
|
@@ -99,7 +95,7 @@ module SolidusSixSaferpay
|
|
99
95
|
if refund_response = SixSaferpay::Client.post(payment_refund)
|
100
96
|
|
101
97
|
# actually capture the refund
|
102
|
-
capture(
|
98
|
+
capture(amount_cents, refund_response.transaction.id, options)
|
103
99
|
end
|
104
100
|
|
105
101
|
rescue SixSaferpay::Error => e
|
@@ -156,7 +152,7 @@ module SolidusSixSaferpay
|
|
156
152
|
)
|
157
153
|
payer = SixSaferpay::Payer.new(language_code: I18n.locale, billing_address: billing_address, delivery_address: delivery_address)
|
158
154
|
|
159
|
-
params = { payment: payment, payer: payer }
|
155
|
+
params = { payment: payment, payer: payer, return_urls: return_urls(order) }
|
160
156
|
|
161
157
|
six_payment_methods = payment_method.enabled_payment_methods
|
162
158
|
params.merge!(payment_methods: six_payment_methods) unless six_payment_methods.blank?
|
@@ -164,6 +160,10 @@ module SolidusSixSaferpay
|
|
164
160
|
params
|
165
161
|
end
|
166
162
|
|
163
|
+
def return_urls(order)
|
164
|
+
raise NotImplementedError, "Must be implemented in PaymentPageGateway or TransactionGateway"
|
165
|
+
end
|
166
|
+
|
167
167
|
def response(success, message, api_response, options = {})
|
168
168
|
GatewayResponse.new(success, message, api_response, options)
|
169
169
|
end
|
@@ -1,15 +1,6 @@
|
|
1
1
|
module SolidusSixSaferpay
|
2
2
|
class PaymentPageGateway < Gateway
|
3
3
|
|
4
|
-
def initialize(options = {})
|
5
|
-
super(
|
6
|
-
options.merge(
|
7
|
-
success_url: url_helpers.solidus_six_saferpay_payment_page_success_url,
|
8
|
-
fail_url: url_helpers.solidus_six_saferpay_payment_page_fail_url
|
9
|
-
)
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
4
|
def inquire(saferpay_payment, options = {})
|
14
5
|
inquire_response = perform_assert_request(saferpay_payment, options)
|
15
6
|
|
@@ -47,6 +38,14 @@ module SolidusSixSaferpay
|
|
47
38
|
SixSaferpay::SixPaymentPage::Initialize.new(interface_initialize_params(order, payment_method))
|
48
39
|
end
|
49
40
|
|
41
|
+
def return_urls(order)
|
42
|
+
SixSaferpay::ReturnUrls.new(
|
43
|
+
success: url_helpers.solidus_six_saferpay_payment_page_success_url(order.number),
|
44
|
+
fd_fail: url_helpers.solidus_six_saferpay_payment_page_fail_url(order.number),
|
45
|
+
fd_abort: url_helpers.solidus_six_saferpay_payment_page_fail_url(order.number)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
50
49
|
def perform_assert_request(saferpay_payment, options = {})
|
51
50
|
payment_page_assert = SixSaferpay::SixPaymentPage::Assert.new(token: saferpay_payment.token)
|
52
51
|
SixSaferpay::Client.post(payment_page_assert)
|
@@ -1,15 +1,6 @@
|
|
1
1
|
module SolidusSixSaferpay
|
2
2
|
class TransactionGateway < Gateway
|
3
3
|
|
4
|
-
def initialize(options = {})
|
5
|
-
super(
|
6
|
-
options.merge(
|
7
|
-
success_url: url_helpers.solidus_six_saferpay_transaction_success_url,
|
8
|
-
fail_url: url_helpers.solidus_six_saferpay_transaction_fail_url
|
9
|
-
)
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
4
|
def inquire(saferpay_payment, options = {})
|
14
5
|
transaction_inquire = SixSaferpay::SixTransaction::Inquire.new(transaction_reference: saferpay_payment.transaction_id)
|
15
6
|
inquire_response = SixSaferpay::Client.post(transaction_inquire)
|
@@ -43,5 +34,13 @@ module SolidusSixSaferpay
|
|
43
34
|
def interface_initialize_object(order, payment_method)
|
44
35
|
SixSaferpay::SixTransaction::Initialize.new(interface_initialize_params(order, payment_method))
|
45
36
|
end
|
37
|
+
|
38
|
+
def return_urls(order)
|
39
|
+
SixSaferpay::ReturnUrls.new(
|
40
|
+
success: url_helpers.solidus_six_saferpay_transaction_success_url(order.number),
|
41
|
+
fd_fail: url_helpers.solidus_six_saferpay_transaction_fail_url(order.number),
|
42
|
+
fd_abort: url_helpers.solidus_six_saferpay_transaction_fail_url(order.number)
|
43
|
+
)
|
44
|
+
end
|
46
45
|
end
|
47
46
|
end
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
|
32
32
|
spec.add_dependency 'solidus_support', '~> 0.4.0'
|
33
|
-
spec.add_dependency "six_saferpay", "~> 2.
|
33
|
+
spec.add_dependency "six_saferpay", "~> 2.8.1"
|
34
34
|
spec.add_dependency "rails-i18n", "~> 5.1"
|
35
35
|
|
36
36
|
spec.add_development_dependency 'solidus_dev_support'
|
@@ -39,4 +39,5 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency "rails-controller-testing", "~> 1.0", ">= 1.0.4"
|
40
40
|
spec.add_development_dependency "pry", "~> 0.12"
|
41
41
|
spec.add_development_dependency "pry-rails", "~> 0.3"
|
42
|
+
spec.add_development_dependency "bundler-audit"
|
42
43
|
end
|
@@ -1,205 +1,16 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Spree
|
4
|
+
module SolidusSixSaferpay
|
5
|
+
RSpec.describe PaymentPage::CheckoutController do
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
let(:initialize_payment_service_class) { InitializePaymentPage }
|
8
|
+
let(:authorize_payment_service_class) { AssertPaymentPage }
|
9
|
+
let(:process_authorization_service_class) { ProcessPaymentPagePayment }
|
10
|
+
let(:inquire_payment_service_class) { InquirePaymentPagePayment }
|
9
11
|
|
10
|
-
|
12
|
+
it_behaves_like "checkout_controller"
|
11
13
|
|
12
|
-
before do
|
13
|
-
allow(controller).to receive_messages try_spree_current_user: user
|
14
|
-
allow(controller).to receive_messages current_order: order
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'GET init' do
|
18
|
-
let(:success) { false }
|
19
|
-
let(:redirect_url) { '/saferpay/redirect/url' }
|
20
|
-
let(:initialized_payment) { instance_double("Spree::SolidusSixSaferpay::InitializePaymentPage", success?: success, redirect_url: redirect_url) }
|
21
|
-
|
22
|
-
it 'tries to the saferpay payment' do
|
23
|
-
expect(Spree::SolidusSixSaferpay::InitializePaymentPage).to receive(:call).with(order, payment_method).and_return(initialized_payment)
|
24
|
-
|
25
|
-
get :init, params: { payment_method_id: payment_method.id }
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
context 'when payment initialize succeeds' do
|
30
|
-
let(:success) { true }
|
31
|
-
|
32
|
-
before do
|
33
|
-
allow(Spree::SolidusSixSaferpay::InitializePaymentPage).to receive(:call).with(order, payment_method).and_return(initialized_payment)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'returns the redirect_url' do
|
37
|
-
get :init, params: { payment_method_id: payment_method.id }
|
38
|
-
|
39
|
-
body = JSON.parse(response.body)
|
40
|
-
expect(body["redirect_url"]).to eq(redirect_url)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when payment initialize fails' do
|
45
|
-
let(:success) { false }
|
46
|
-
|
47
|
-
before do
|
48
|
-
allow(Spree::SolidusSixSaferpay::InitializePaymentPage).to receive(:call).with(order, payment_method).and_return(initialized_payment)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'returns an error' do
|
52
|
-
get :init, params: { payment_method_id: payment_method.id }
|
53
|
-
|
54
|
-
expect(response.body).to match(/errors/)
|
55
|
-
expect(response.status).to eq(422)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'GET success' do
|
62
|
-
context 'when the order is not found' do
|
63
|
-
let(:order) { nil }
|
64
|
-
|
65
|
-
it 'redirects to the cart page via iframe breakout' do
|
66
|
-
get :success
|
67
|
-
expect(assigns(:redirect_path)).to eq(routes.cart_path)
|
68
|
-
expect(response).to render_template :iframe_breakout_redirect
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'when the order is already completed' do
|
73
|
-
let(:order) { create(:order_ready_to_ship) }
|
74
|
-
|
75
|
-
it 'redirects to the cart page via iframe breakout' do
|
76
|
-
get :success
|
77
|
-
expect(assigns(:redirect_path)).to eq(routes.cart_path)
|
78
|
-
expect(response).to render_template :iframe_breakout_redirect
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when payment could not be created' do
|
83
|
-
let!(:payment) { nil }
|
84
|
-
|
85
|
-
it 'raises an error because no payment exists' do
|
86
|
-
expect{ get(:success) }.to raise_error(Spree::Core::GatewayError)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'when payment create was successful' do
|
91
|
-
let!(:payment) { create(:six_saferpay_payment, order: order) }
|
92
|
-
let(:assert_success) { false }
|
93
|
-
let(:payment_assert) { instance_double("Spree::SolidusSixSaferpay::AssertPaymentPage", success?: assert_success) }
|
94
|
-
let(:payment_inquiry) { instance_double("Spree::SolidusSixSaferpay::InquirePaymentPagePayment", user_message: "payment inquiry message") }
|
95
|
-
|
96
|
-
it 'asserts the payment' do
|
97
|
-
expect(Spree::SolidusSixSaferpay::AssertPaymentPage).to receive(:call).with(payment).and_return(payment_assert)
|
98
|
-
expect(Spree::SolidusSixSaferpay::InquirePaymentPagePayment).to receive(:call).with(payment).and_return(payment_inquiry)
|
99
|
-
|
100
|
-
get :success
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'when the payment assert is successful' do
|
104
|
-
let(:assert_success) { true }
|
105
|
-
let(:process_success) { false }
|
106
|
-
let(:processed_payment) { instance_double("Spree::SolidusSixSaferpay::ProcessPaymentPagePayment", success?: process_success, user_message: "payment processing message") }
|
107
|
-
|
108
|
-
before do
|
109
|
-
allow(Spree::SolidusSixSaferpay::AssertPaymentPage).to receive(:call).with(payment).and_return(payment_assert)
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'processes the asserted payment' do
|
113
|
-
expect(Spree::SolidusSixSaferpay::ProcessPaymentPagePayment).to receive(:call).with(payment).and_return(processed_payment)
|
114
|
-
|
115
|
-
get :success
|
116
|
-
end
|
117
|
-
|
118
|
-
context 'when the processing is successful' do
|
119
|
-
let(:process_success) { true }
|
120
|
-
|
121
|
-
before do
|
122
|
-
allow(Spree::SolidusSixSaferpay::ProcessPaymentPagePayment).to receive(:call).with(payment).and_return(processed_payment)
|
123
|
-
end
|
124
|
-
|
125
|
-
|
126
|
-
context 'when order is in payment state' do
|
127
|
-
let(:order) { create(:order, state: :payment) }
|
128
|
-
|
129
|
-
it 'moves order to next state' do
|
130
|
-
expect(order).to receive(:next!)
|
131
|
-
|
132
|
-
get :success
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
context 'when order is already in complete state' do
|
137
|
-
let(:order) { create(:order, state: :complete) }
|
138
|
-
|
139
|
-
it 'does not modify the order state' do
|
140
|
-
expect(order).not_to receive(:next!)
|
141
|
-
|
142
|
-
get :success
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'when the processing fails' do
|
148
|
-
let(:process_success) { false }
|
149
|
-
|
150
|
-
before do
|
151
|
-
allow(Spree::SolidusSixSaferpay::ProcessPaymentPagePayment).to receive(:call).with(payment).and_return(processed_payment)
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'displays an error message' do
|
155
|
-
get :success
|
156
|
-
|
157
|
-
expect(flash[:error]).to eq("payment processing message")
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'when the payment assert fails' do
|
164
|
-
let(:assert_success) { false }
|
165
|
-
|
166
|
-
before do
|
167
|
-
allow(Spree::SolidusSixSaferpay::AssertPaymentPage).to receive(:call).with(payment).and_return(payment_assert)
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'inquires the payment' do
|
171
|
-
expect(Spree::SolidusSixSaferpay::InquirePaymentPagePayment).to receive(:call).with(payment).and_return(payment_inquiry)
|
172
|
-
|
173
|
-
get :success
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'displays an error message' do
|
177
|
-
expect(Spree::SolidusSixSaferpay::InquirePaymentPagePayment).to receive(:call).with(payment).and_return(payment_inquiry)
|
178
|
-
get :success
|
179
|
-
|
180
|
-
expect(flash[:error]).to eq("payment inquiry message")
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe 'GET fail' do
|
187
|
-
let!(:payment) { create(:six_saferpay_payment, order: order) }
|
188
|
-
let(:payment_inquiry) { instance_double("Spree::SolidusSixSaferpay::InquirePaymentPagePayment", user_message: "payment inquiry message") }
|
189
|
-
|
190
|
-
it 'inquires the payment' do
|
191
|
-
expect(Spree::SolidusSixSaferpay::InquirePaymentPagePayment).to receive(:call).with(payment).and_return(payment_inquiry)
|
192
|
-
|
193
|
-
get :fail
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'displays an error message' do
|
197
|
-
expect(Spree::SolidusSixSaferpay::InquirePaymentPagePayment).to receive(:call).with(payment).and_return(payment_inquiry)
|
198
|
-
|
199
|
-
get :fail
|
200
|
-
|
201
|
-
expect(flash[:error]).to eq("payment inquiry message")
|
202
14
|
end
|
203
|
-
|
204
15
|
end
|
205
16
|
end
|