solidus_api 4.7.0 → 4.7.2
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.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/checkouts_controller.rb +11 -1
- data/app/controllers/spree/api/orders_controller.rb +31 -1
- data/app/controllers/spree/api/payments_controller.rb +11 -0
- data/app/controllers/spree/api/users_controller.rb +9 -3
- data/app/views/spree/api/orders/invalid_state.json.jbuilder +3 -0
- data/config/locales/en.yml +1 -0
- data/lib/spree/api_configuration.rb +4 -0
- metadata +6 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a09ac9341a0721a7b5cd1ee955557b6659e0baa689adcd3abfc0b73b6e96cfc0
|
|
4
|
+
data.tar.gz: 473737cd41360507d3d6eacffcbf64d6dffb65d05c8d3d6b85b934ebcc2a1137
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed264bfc8321d2072db352b6820fbbcee2c72918f500279e940fe7f11ff329442baf4c657eb7ddf67870fd44eeb7966044cf55033f032d29ecb1516d14d5dd6d
|
|
7
|
+
data.tar.gz: 6f220657fb6b51d027586734957b61ae6e8b22f68acfc9637a7c983ce56f5b6e0684e4ad5e6b893b62472430c8f99dac15930b0826dd7869f1c4baf29a7929b0
|
|
@@ -105,10 +105,20 @@ module Spree
|
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
def update_order_state
|
|
108
|
-
|
|
108
|
+
return unless params[:state]
|
|
109
|
+
|
|
110
|
+
unless Spree::Api::Config.allow_arbitrary_state_in_checkout || valid_checkout_step?(params[:state])
|
|
111
|
+
return respond_with(@order, default_template: "spree/api/orders/invalid_state", status: 422)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
@order.state = params[:state]
|
|
109
115
|
state_callback(:before)
|
|
110
116
|
end
|
|
111
117
|
|
|
118
|
+
def valid_checkout_step?(step)
|
|
119
|
+
@order.passed_checkout_step?(step) || @order.state == step
|
|
120
|
+
end
|
|
121
|
+
|
|
112
122
|
def state_callback(before_or_after = :before)
|
|
113
123
|
method_name = :"#{before_or_after}_#{@order.state}"
|
|
114
124
|
send(method_name) if respond_to?(method_name, true)
|
|
@@ -11,6 +11,12 @@ module Spree
|
|
|
11
11
|
|
|
12
12
|
class_attribute :admin_payment_attributes
|
|
13
13
|
self.admin_payment_attributes = [:payment_method, :amount, :state, source: {}]
|
|
14
|
+
msg = "`Spree::Api::OrdersController.admin_payment_attributes` is deprecated."
|
|
15
|
+
deprecate(
|
|
16
|
+
admin_payment_attributes: msg,
|
|
17
|
+
"admin_payment_attributes=": msg,
|
|
18
|
+
deprecator: Spree.deprecator
|
|
19
|
+
)
|
|
14
20
|
|
|
15
21
|
before_action :find_order, except: [:create, :mine, :current, :index]
|
|
16
22
|
around_action :lock_order, except: [:create, :mine, :current, :index, :show]
|
|
@@ -149,7 +155,25 @@ module Spree
|
|
|
149
155
|
end
|
|
150
156
|
|
|
151
157
|
def permitted_order_attributes
|
|
152
|
-
can?(:admin, Spree::Order)
|
|
158
|
+
if can?(:admin, Spree::Order)
|
|
159
|
+
super + admin_order_attributes
|
|
160
|
+
else
|
|
161
|
+
# We need to remove the `:amount` attribute from payments_attributes
|
|
162
|
+
# for non-admin users. Unfortunately, order_attributes uses the
|
|
163
|
+
# checkout_payment_attributes instead of the payment_attributes, which
|
|
164
|
+
# needs to be able to set the amount.
|
|
165
|
+
#
|
|
166
|
+
# We're doing a deep_dup here to avoid modifying the original
|
|
167
|
+
# permitted attributes, which could have unintended side effects.
|
|
168
|
+
order_attributes = super.deep_dup
|
|
169
|
+
|
|
170
|
+
payments_attributes = order_attributes.find do |attribute|
|
|
171
|
+
attribute.is_a?(Hash) && attribute.has_key?(:payments_attributes)
|
|
172
|
+
end
|
|
173
|
+
payments_attributes[:payments_attributes] -= [:amount]
|
|
174
|
+
|
|
175
|
+
order_attributes
|
|
176
|
+
end
|
|
153
177
|
end
|
|
154
178
|
|
|
155
179
|
def permitted_shipment_attributes
|
|
@@ -161,6 +185,12 @@ module Spree
|
|
|
161
185
|
end
|
|
162
186
|
|
|
163
187
|
def permitted_payment_attributes
|
|
188
|
+
Spree.deprecator.warn(
|
|
189
|
+
"`Spree::Api::OrdersController#permitted_payment_attributes` is deprecated. " \
|
|
190
|
+
"This method was never actually used in this controller because " \
|
|
191
|
+
"permitted_order_attributes uses the permitted_checkout_payment_attributes " \
|
|
192
|
+
"method to determine the permitted attributes for payments."
|
|
193
|
+
)
|
|
164
194
|
if can?(:admin, Spree::Payment)
|
|
165
195
|
super + admin_payment_attributes
|
|
166
196
|
else
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module Spree
|
|
4
4
|
module Api
|
|
5
5
|
class PaymentsController < Spree::Api::BaseController
|
|
6
|
+
class_attribute :admin_payment_attributes
|
|
7
|
+
self.admin_payment_attributes = [:amount]
|
|
8
|
+
|
|
6
9
|
before_action :find_order
|
|
7
10
|
around_action :lock_order, only: [:create, :update, :authorize, :capture, :purchase, :void]
|
|
8
11
|
before_action :find_payment, only: [:update, :show, :authorize, :purchase, :capture, :void]
|
|
@@ -78,6 +81,14 @@ module Spree
|
|
|
78
81
|
def payment_params
|
|
79
82
|
params.require(:payment).permit(permitted_payment_attributes)
|
|
80
83
|
end
|
|
84
|
+
|
|
85
|
+
def permitted_payment_attributes
|
|
86
|
+
if can?(:admin, Spree::Payment)
|
|
87
|
+
super + admin_payment_attributes
|
|
88
|
+
else
|
|
89
|
+
super
|
|
90
|
+
end
|
|
91
|
+
end
|
|
81
92
|
end
|
|
82
93
|
end
|
|
83
94
|
end
|
|
@@ -80,10 +80,16 @@ class Spree::Api::UsersController < Spree::Api::BaseController
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def permitted_user_attributes
|
|
83
|
+
attributes = super
|
|
84
|
+
|
|
83
85
|
if action_name == "create" || can?(:update_email, @user)
|
|
84
|
-
|
|
85
|
-
else
|
|
86
|
-
super
|
|
86
|
+
attributes |= [:email]
|
|
87
87
|
end
|
|
88
|
+
|
|
89
|
+
unless action_name == "create" || @user == current_api_user || can?(:update_password, @user)
|
|
90
|
+
attributes -= [:password, :password_confirmation]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
attributes
|
|
88
94
|
end
|
|
89
95
|
end
|
data/config/locales/en.yml
CHANGED
|
@@ -12,6 +12,7 @@ en:
|
|
|
12
12
|
order:
|
|
13
13
|
expected_total_mismatch: Expected total does not match actual total.
|
|
14
14
|
invalid_shipping_method: Invalid shipping method specified.
|
|
15
|
+
invalid_state: Invalid state specified.
|
|
15
16
|
quantity_is_not_available: Quantity is not available for items in your order
|
|
16
17
|
payment:
|
|
17
18
|
credit_over_limit: This payment can only be credited up to %{limit}. Please specify an amount less than or equal to this number.
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
4
|
class ApiConfiguration < Preferences::Configuration
|
|
5
|
+
# @!attribute [rw] allow_arbitrary_state_in_api
|
|
6
|
+
# @return [Boolean] When true, the API will allow arbitrary state transitions on orders (default: +false+)
|
|
7
|
+
preference :allow_arbitrary_state_in_checkout, :boolean, default: false
|
|
8
|
+
|
|
5
9
|
preference :requires_authentication, :boolean, default: true
|
|
6
10
|
|
|
7
11
|
preference :product_attributes, :array, default: [
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solidus_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.7.
|
|
4
|
+
version: 4.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Solidus Team
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: jbuilder
|
|
@@ -58,14 +57,14 @@ dependencies:
|
|
|
58
57
|
requirements:
|
|
59
58
|
- - '='
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 4.7.
|
|
60
|
+
version: 4.7.2
|
|
62
61
|
type: :runtime
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
65
|
- - '='
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 4.7.
|
|
67
|
+
version: 4.7.2
|
|
69
68
|
description: REST API for the Solidus e-commerce framework.
|
|
70
69
|
email: contact@solidus.io
|
|
71
70
|
executables: []
|
|
@@ -153,6 +152,7 @@ files:
|
|
|
153
152
|
- app/views/spree/api/orders/expected_total_mismatch.json.jbuilder
|
|
154
153
|
- app/views/spree/api/orders/index.json.jbuilder
|
|
155
154
|
- app/views/spree/api/orders/invalid_shipping_method.json.jbuilder
|
|
155
|
+
- app/views/spree/api/orders/invalid_state.json.jbuilder
|
|
156
156
|
- app/views/spree/api/orders/mine.json.jbuilder
|
|
157
157
|
- app/views/spree/api/orders/show.json.jbuilder
|
|
158
158
|
- app/views/spree/api/payments/credit_over_limit.json.jbuilder
|
|
@@ -257,7 +257,6 @@ licenses:
|
|
|
257
257
|
- BSD-3-Clause
|
|
258
258
|
metadata:
|
|
259
259
|
rubygems_mfa_required: 'true'
|
|
260
|
-
post_install_message:
|
|
261
260
|
rdoc_options: []
|
|
262
261
|
require_paths:
|
|
263
262
|
- lib
|
|
@@ -272,8 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
272
271
|
- !ruby/object:Gem::Version
|
|
273
272
|
version: 1.8.23
|
|
274
273
|
requirements: []
|
|
275
|
-
rubygems_version:
|
|
276
|
-
signing_key:
|
|
274
|
+
rubygems_version: 4.0.10
|
|
277
275
|
specification_version: 4
|
|
278
276
|
summary: REST API for the Solidus e-commerce framework.
|
|
279
277
|
test_files: []
|