Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add shipment_state and payment_state to API v2 Cart/Order response

Damian Legawiec6a67ed0a12af
diff --git a/api/app/serializers/spree/v2/storefront/cart_serializer.rb b/api/app/serializers/spree/v2/storefront/cart_serializer.rb
index 3c33f81ec0..0d1db21a3f 100644
--- a/api/app/serializers/spree/v2/storefront/cart_serializer.rb
+++ b/api/app/serializers/spree/v2/storefront/cart_serializer.rb
@@ -9,7 +9,8 @@ module Spree
:display_included_tax_total, :tax_total, :currency, :state, :token, :email,
:display_item_total, :display_ship_total, :display_adjustment_total, :display_tax_total,
:promo_total, :display_promo_total, :item_count, :special_instructions, :display_total,
- :pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total
+ :pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total,
+ :shipment_state, :payment_state
has_many :line_items
has_many :variants
diff --git a/api/app/serializers/spree/v2/storefront/payment_serializer.rb b/api/app/serializers/spree/v2/storefront/payment_serializer.rb
index 78e4f0bd97..0421530f48 100644
--- a/api/app/serializers/spree/v2/storefront/payment_serializer.rb
+++ b/api/app/serializers/spree/v2/storefront/payment_serializer.rb
@@ -8,7 +8,7 @@ module Spree
has_one :payment_method
attributes :amount, :response_code, :number, :cvv_response_code, :cvv_response_message,
- :payment_method_id, :payment_method_name
+ :payment_method_id, :payment_method_name, :state
end
end
end
diff --git a/api/lib/spree/api/testing_support/v2/current_order.rb b/api/lib/spree/api/testing_support/v2/current_order.rb
index 94a79f6dc9..cda2721ee4 100644
--- a/api/lib/spree/api/testing_support/v2/current_order.rb
+++ b/api/lib/spree/api/testing_support/v2/current_order.rb
@@ -27,6 +27,8 @@ shared_examples 'returns valid cart JSON' do
expect(json_response['data']).to have_type('cart')
expect(json_response['data']).to have_attribute(:number).with_value(order.number)
expect(json_response['data']).to have_attribute(:state).with_value(order.state)
+ expect(json_response['data']).to have_attribute(:payment_state).with_value(order.payment_state)
+ expect(json_response['data']).to have_attribute(:shipment_state).with_value(order.shipment_state)
expect(json_response['data']).to have_attribute(:token).with_value(order.token)
expect(json_response['data']).to have_attribute(:total).with_value(order.total.to_s)
expect(json_response['data']).to have_attribute(:item_total).with_value(order.item_total.to_s)