solidus_api 4.7.0 → 4.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b3b5709205727d156db5fe2eab1630cf75936dcb112d1efc18d53b22420e222
4
- data.tar.gz: 73a8d9ac7878bc327954083e3589d8e9a7c43d93574999f171ca6ec993fea6da
3
+ metadata.gz: 92ccd1baa7331139315707fd902eeec5712a41d6563f713611c4c4c32beaff34
4
+ data.tar.gz: 2b93ffdf94c871ec54eaabda3c9c4b46e5108283e1d2aa99686dba426e811cf2
5
5
  SHA512:
6
- metadata.gz: 1fa69f967c9233e7e3f8685bc5f95ce79349d71eae0479ea4273394a3c9d640d593949cc01c59fbce3d1c1c05c096dfaa9062a3145706644f3387e0155fd9e20
7
- data.tar.gz: e8e38fe6122c2414df31f7f27e0252bc2fe3fd32f42bf24bdde674470e7c7fe9f317f9be86beba8a316b4546818cff1c3545c941ce848f5aaf9b004d519979ec
6
+ metadata.gz: d91812f69f054d0536f3bd0bc34a7c028ded3d4172917348d587fbeac25b2a5bb7e2eab28f38d6ae72f82a0a781137c4c53372005c876c42abaf6b115ba9a95f
7
+ data.tar.gz: 2eb2ce76ec4d4a9892f7fa3fd99691f81376cdb0580f8ca39c227ba2f7c394ddb25b14c7e1180cbe931ad0c7f8d5d4d297988b576eabe7f5ca2e70451bbbc920
@@ -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) ? (super + admin_order_attributes) : super
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
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.0
4
+ version: 4.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-04-15 00:00:00.000000000 Z
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.0
60
+ version: 4.7.1
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.0
67
+ version: 4.7.1
69
68
  description: REST API for the Solidus e-commerce framework.
70
69
  email: contact@solidus.io
71
70
  executables: []
@@ -257,7 +256,6 @@ licenses:
257
256
  - BSD-3-Clause
258
257
  metadata:
259
258
  rubygems_mfa_required: 'true'
260
- post_install_message:
261
259
  rdoc_options: []
262
260
  require_paths:
263
261
  - lib
@@ -272,8 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
270
  - !ruby/object:Gem::Version
273
271
  version: 1.8.23
274
272
  requirements: []
275
- rubygems_version: 3.5.22
276
- signing_key:
273
+ rubygems_version: 4.0.10
277
274
  specification_version: 4
278
275
  summary: REST API for the Solidus e-commerce framework.
279
276
  test_files: []