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.

Update Spree API with new checkout endpoints (#12310)

Łukasz Adamczyk8bf72dc4a23c
diff --git a/api/app/controllers/spree/api/v2/storefront/checkout_controller.rb b/api/app/controllers/spree/api/v2/storefront/checkout_controller.rb
index f50e9e5df2..4e84a83da4 100644
--- a/api/app/controllers/spree/api/v2/storefront/checkout_controller.rb
+++ b/api/app/controllers/spree/api/v2/storefront/checkout_controller.rb
@@ -17,7 +17,9 @@ module Spree
def advance
spree_authorize! :update, spree_current_order, order_token
- result = advance_service.call(order: spree_current_order)
+ check_if_quick_checkout
+
+ result = advance_service.call(order: spree_current_order, state: params[:state], shipping_method_id: params[:shipping_method_id])
render_order(result)
end
@@ -92,6 +94,23 @@ module Spree
render_serialized_payload { serialize_payment_methods(spree_current_order.available_payment_methods) }
end
+ def validate_order_for_payment
+ messages = []
+
+ if spree_current_order.present?
+ validated_order, messages = Spree::Cart::RemoveOutOfStockItems.call(order: spree_current_order).value
+ messages << Spree.t(:cart_state_changed) if !validated_order.payment? && params[:skip_state].blank?
+ end
+
+ if messages.any?
+ render_serialized_payload(422) do
+ serialized_current_order.deep_merge({ meta: { messages: messages } })
+ end
+ else
+ render_serialized_payload { serialized_current_order }
+ end
+ end
+
private
def resource_serializer
@@ -153,6 +172,10 @@ module Spree
include: [:shipping_rates, :stock_location, :line_items]
).serializable_hash
end
+
+ def check_if_quick_checkout
+ spree_current_order.ship_address&.quick_checkout = params[:quick_checkout] if params[:quick_checkout]
+ end
end
end
end
diff --git a/api/app/services/spree/api/error_handler.rb b/api/app/services/spree/api/error_handler.rb
deleted file mode 100644
index ce2449097b..0000000000
--- a/api/app/services/spree/api/error_handler.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-module Spree
- module Api
- class ErrorHandler
- prepend ::Spree::ServiceModule::Base
-
- def call(exception:, opts: {})
- run :format_message
- run :log_error
- run :report_error
- end
-
- protected
-
- def format_message(exception:, opts:)
- message = if exception.respond_to?(:original_message)
- exception.original_message
- else
- exception.message
- end
-
- success(exception: exception, message: message, opts: opts)
- end
-
- def log_error(exception:, message:, opts:)
- Rails.logger.error message
- Rails.logger.error "User ID: #{opts[:user]&.id}" if opts[:user]
- Rails.logger.error exception.backtrace.join("\n")
-
- success(exception: exception, message: message, opts: opts)
- end
-
- def report_error(exception:, message:, opts:)
- # overwrite this method in your application to support different error handlers
- # eg. Sentry, Rollbar, etc
- Sentry.capture_exception(exception) if defined?(Sentry)
-
- success(exception: exception, message: message)
- end
- end
- end
-end
diff --git a/api/config/routes.rb b/api/config/routes.rb
index 1d07fca86c..e3cc9b30ea 100644
--- a/api/config/routes.rb
+++ b/api/config/routes.rb
@@ -31,6 +31,7 @@ Spree::Core::Engine.add_routes do
get :payment_methods
get :shipping_rates
patch :select_shipping_method
+ post :validate_order_for_payment
end
resource :account, controller: :account, only: %i[show create update]
diff --git a/api/lib/spree/api/dependencies.rb b/api/lib/spree/api/dependencies.rb
index 3a359f4b89..a160e757bc 100644
--- a/api/lib/spree/api/dependencies.rb
+++ b/api/lib/spree/api/dependencies.rb
@@ -86,7 +86,7 @@ module Spree
storefront_taxon_finder: -> { Spree::Dependencies.taxon_finder },
storefront_variant_finder: -> { Spree::Dependencies.variant_finder },
- error_handler: 'Spree::Api::ErrorHandler',
+ error_handler: 'Spree::ErrorHandler',
# serializers
platform_admin_user_serializer: 'Spree::Api::V2::Platform::AdminUserSerializer',
diff --git a/api/spec/controllers/spree/api/v2/base_controller_spec.rb b/api/spec/controllers/spree/api/v2/base_controller_spec.rb
index a82e19a8d4..360a9fc626 100644
--- a/api/spec/controllers/spree/api/v2/base_controller_spec.rb
+++ b/api/spec/controllers/spree/api/v2/base_controller_spec.rb
@@ -110,7 +110,7 @@ describe Spree::Api::V2::BaseController, type: :controller do
it do
expect(subject).to receive(:index).and_raise(exception)
expect(subject).to receive(:spree_current_user).at_least(:once).and_return(user)
- expect_next_instance_of(::Spree::Api::ErrorHandler) do |instance|
+ expect_next_instance_of(::Spree::ErrorHandler) do |instance|
expect(instance).to receive(:call).with(
exception: exception,
opts: { user: user }
diff --git a/api/spec/requests/spree/api/v2/errors_spec.rb b/api/spec/requests/spree/api/v2/errors_spec.rb
index ae1fcc2c53..7a4555b48e 100644
--- a/api/spec/requests/spree/api/v2/errors_spec.rb
+++ b/api/spec/requests/spree/api/v2/errors_spec.rb
@@ -30,7 +30,7 @@ describe 'API v2 Errors spec', type: :request do
end
it 'calls error handler' do
- expect_next_instance_of(::Spree::Api::ErrorHandler) do |instance|
+ expect_next_instance_of(::Spree::ErrorHandler) do |instance|
expect(instance).to receive(:call).with(
exception: instance_of(CanCan::AccessDenied),
opts: { user: user }
diff --git a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb
index a21250f844..e6fe99d256 100644
--- a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb
+++ b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb
@@ -111,15 +111,12 @@ describe 'API V2 Storefront Checkout Spec', type: :request do
end
describe 'checkout#advance' do
- let(:execute) { patch '/api/v2/storefront/checkout/advance', headers: headers }
+ subject(:execute) { patch '/api/v2/storefront/checkout/advance', headers: headers }
shared_examples 'perform advance' do
- before do
- order.update_column(:state, 'payment')
- end
-
context 'with payment data' do
before do
+ order.update_column(:state, 'payment')
payment
execute
end
@@ -134,15 +131,74 @@ describe 'API V2 Storefront Checkout Spec', type: :request do
end
context 'without payment data' do
- before { execute }
+ let(:order_state) { 'delivery' }
+
+ before do
+ order.update_column(:state, order_state)
+ execute
+ end
it_behaves_like 'returns 200 HTTP status'
it_behaves_like 'returns valid cart JSON'
- it 'doesnt advance pass payment state' do
+ it 'advances up to the payment state' do
expect(order.reload.state).to eq('payment')
expect(json_response['data']).to have_attribute(:state).with_value('payment')
end
+
+ context 'when targeting the complete state' do
+ subject(:execute) { patch '/api/v2/storefront/checkout/advance', headers: headers, params: { state: 'complete' } }
+
+ before { execute }
+
+ it_behaves_like 'returns 422 HTTP status'
+
+ it 'advances up to the payment state' do
+ expect(order.reload.state).to eq('payment')
+ end
+
+ it 'responds with an error' do
+ expect(json_response['error']).to eq(Spree.t(:no_payment_found))
+ end
+ end
+
+ context 'when on payment state' do
+ let(:order_state) { 'payment' }
+
+ it_behaves_like 'returns 422 HTTP status'
+
+ it 'advances up to the payment state' do
+ expect(order.reload.state).to eq('payment')
+ end
+
+ it 'responds with an error' do
+ expect(json_response['error']).to eq(Spree.t(:no_payment_found))
+ end
+ end
+ end
+
+ context 'on a quick checkout' do
+ subject(:execute) { patch '/api/v2/storefront/checkout/advance', headers: headers, params: { shipping_method_id: shipping_method_2.id } }
+
+ let!(:order) { create(:order_with_line_items, state: 'address', payments: [create(:payment)], user: user, store: store, currency: currency) }
+
+ let!(:shipping_rate_1) { create(:shipping_rate, shipment: shipment, selected: true, shipping_method: shipping_method_1, cost: 0) }
+ let!(:shipping_rate_2) { create(:shipping_rate, shipment: shipment, selected: false, shipping_method: shipping_method_2, cost: 20) }
+
+ let(:shipment) { order.shipments.first }
+ let(:shipping_method_1) { create(:shipping_method, name: 'Standard') }
+ let(:shipping_method_2) { create(:shipping_method, name: 'Express') }
+
+ before do
+ allow(controller).to receive(:check_if_quick_checkout).and_return(true)
+ end
+
+ it 'advances with a new shipping method' do
+ execute
+
+ expect(response.status).to eq(200)
+ expect(order.reload.shipping_method.id).to eq(shipping_method_2.id)
+ end
end
it_behaves_like 'no current order'
@@ -987,4 +1043,110 @@ describe 'API V2 Storefront Checkout Spec', type: :request do
it_behaves_like 'transitions through checkout from start to finish'
end
end
+
+ describe 'checkout#validate_order_for_payment' do
+ let(:order_state) { 'payment' }
+
+ before do
+ order.update!(state: order_state)
+ end
+
+ shared_examples 'validating the order' do
+ before do
+ post '/api/v2/storefront/checkout/validate_order_for_payment', headers: headers
+ end
+
+ it_behaves_like 'returns 200 HTTP status'
+ it_behaves_like 'returns valid cart JSON'
+ end
+
+ shared_examples 'showing 404' do
+ before do
+ order.destroy!
+ post '/api/v2/storefront/checkout/validate_order_for_payment', headers: headers
+ end
+
+ it_behaves_like 'returns 404 HTTP status'
+ end
+
+ context 'when order has line items that were removed' do
+ include_context 'order with a physical line item'
+
+ let!(:product) { order.line_items.first.product }
+
+ before do
+ product.update!(status: 'draft')
+
+ post '/api/v2/storefront/checkout/validate_order_for_payment', headers: headers
+ end
+
+ it_behaves_like 'returns valid cart JSON'
+
+ it 'should return an error' do
+ expect(json_response['meta']['messages']).to eq(["#{product.name} was removed because it was discontinued"])
+ end
+ end
+
+ context 'when order is not on the payment step' do
+ include_context 'order with a physical line item'
+
+ let(:order_state) { 'address' }
+
+ before do
+ post '/api/v2/storefront/checkout/validate_order_for_payment', headers: headers
+ end
+
+ it_behaves_like 'returns valid cart JSON'
+
+ it 'should return an error' do
+ expect(json_response['meta']['messages']).to eq(['Cart changed'])
+ end
+ end
+
+ context 'without existing order' do
+ let!(:headers) { headers_bearer }
+
+ it_behaves_like 'showing 404'
+ end
+
+ context 'with existing user order with line item' do
+ include_context 'order with a physical line item'
+
+ it_behaves_like 'validating the order'
+ end
+
+ context 'with existing guest order' do
+ include_context 'creates guest order with guest token'
+
+ it_behaves_like 'validating the order'
+ end
+
+ context 'with skip state validation' do
+ include_context 'order with a physical line item'
+
+ before do
+ order.update_column(:state, 'address')
+ post '/api/v2/storefront/checkout/validate_order_for_payment', headers: headers, params: { skip_state: true }
+ end
+
+ it 'should return a valid cart' do
+ expect(json_response['data']).to have_id(order.id.to_s)
+ expect(response.status).to eq(200)
+ end
+ end
+
+ context 'without skip state validation' do
+ include_context 'order with a physical line item'
+
+ before do
+ order.update_column(:state, 'address')
+ post '/api/v2/storefront/checkout/validate_order_for_payment', headers: headers
+ end
+
+ it 'should return an error' do
+ expect(response.status).to eq(422)
+ expect(json_response['meta']['messages']).to eq(['Cart changed'])
+ end
+ end
+ end
end
diff --git a/api/spec/serializers/spree/api/v2/platform/address_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/address_serializer_spec.rb
index 8ec2dd50c4..7ecf3569a1 100644
--- a/api/spec/serializers/spree/api/v2/platform/address_serializer_spec.rb
+++ b/api/spec/serializers/spree/api/v2/platform/address_serializer_spec.rb
@@ -26,6 +26,7 @@ describe Spree::Api::V2::Platform::AddressSerializer do
updated_at: address.updated_at,
deleted_at: address.deleted_at,
label: address.label,
+ quick_checkout: false,
public_metadata: {},
private_metadata: {}
},
diff --git a/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rb b/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rb
index 794a8ff56c..381858a0f6 100644
--- a/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rb
+++ b/api/spec/serializers/spree/api/v2/platform/store_serializer_spec.rb
@@ -42,6 +42,8 @@ describe Spree::Api::V2::Platform::StoreSerializer do
address: store.address,
contact_phone: store.contact_phone,
new_order_notifications_email: store.new_order_notifications_email,
+ public_metadata: {},
+ private_metadata: {},
seo_robots: store.seo_robots,
supported_locales: store.supported_locales,
deleted_at: store.deleted_at,
diff --git a/api/spec/services/spree/api/error_handler_spec.rb b/api/spec/services/spree/api/error_handler_spec.rb
deleted file mode 100644
index 7f788cf13b..0000000000
--- a/api/spec/services/spree/api/error_handler_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe Api::ErrorHandler do
- class CustomException < StandardError
- def backtrace
- ['a', 'b']
- end
- end
-
- let(:message) { 'error' }
- let(:exception) { CustomException.new(message) }
- let(:user) { create :user }
-
- subject { described_class.call(exception: exception, opts: { user: user }) }
- let(:result) { subject }
-
- it 'returns result with error' do
- expect(Rails.logger).to receive(:error).with(message)
- expect(Rails.logger).to receive(:error).with("User ID: #{user.id}")
- expect(Rails.logger).to receive(:error).with(exception.backtrace.join("\n"))
-
- expect(result.value).to eq({ exception: exception, message: message })
- end
- end
-end
diff --git a/core/app/services/spree/cart/remove_out_of_stock_items.rb b/core/app/services/spree/cart/remove_out_of_stock_items.rb
new file mode 100644
index 0000000000..68e6fe1f19
--- /dev/null
+++ b/core/app/services/spree/cart/remove_out_of_stock_items.rb
@@ -0,0 +1,56 @@
+module Spree
+ module Cart
+ class RemoveOutOfStockItems
+ prepend ::Spree::ServiceModule::Base
+
+ def call(order:)
+ @messages = []
+ ActiveRecord::Base.transaction do
+ line_items(order).each do |line_item|
+ cart_remove_line_item_service.call(order: order, line_item: line_item) if !valid_status?(line_item) || !stock_available?(line_item)
+ end
+ end
+
+ if @messages.any? # If any line item was removed, reload the order
+ success([order.reload, @messages])
+ else
+ success([order, @messages])
+ end
+ end
+
+ private
+
+ def line_items(order)
+ if order.line_items.empty?
+ []
+ elsif order.line_items.first.association_cached?(:variant) && order.line_items.first.variant.association_cached?(:product)
+ # Don't include associations if it is already included, because it breaks other includes
+ order.line_items
+ else
+ order.line_items.includes(variant: :product)
+ end
+ end
+
+ def valid_status?(line_item)
+ product = line_item.product
+ if !product.active? || product.deleted? || product.discontinued? || line_item.variant.discontinued?
+ @messages << Spree.t('cart_line_item.discontinued', li_name: line_item.name)
+ return false
+ end
+ true
+ end
+
+ def stock_available?(line_item)
+ if line_item.insufficient_stock?
+ @messages << Spree.t('cart_line_item.out_of_stock', li_name: line_item.name)
+ return false
+ end
+ true
+ end
+
+ def cart_remove_line_item_service
+ Spree::Dependencies.cart_remove_line_item_service.constantize
+ end
+ end
+ end
+end
diff --git a/core/app/services/spree/checkout/advance.rb b/core/app/services/spree/checkout/advance.rb
index a495f3e072..82ab8a892d 100644
--- a/core/app/services/spree/checkout/advance.rb
+++ b/core/app/services/spree/checkout/advance.rb
@@ -3,15 +3,55 @@ module Spree
class Advance
prepend Spree::ServiceModule::Base
- def call(order:)
- Spree::Dependencies.checkout_next_service.constantize.call(order: order) until cannot_make_transition?(order)
+ def call(order:, state: nil, shipping_method_id: nil)
+ return failure(order) if state.present? && !order.has_checkout_step?(state)
+ return success(order) if state.present? && order.passed_checkout_step?(state)
+
+ old_state = order.state
+ order_updater_ran = false
+
+ # We need to check how many times we transitioned between checkout steps and return the error if no transition has been made
+ # We'll always return an error when passing the `state` arg and not reaching the targeted state
+ transitions_count = 0
+
+ until cannot_make_transition?(order, state)
+ next_result = Spree::Dependencies.checkout_next_service.constantize.call(order: order)
+ return failure(order, order.errors) if next_result.failure? && (transitions_count.zero? || state.present?)
+
+ transitions_count +=1
+
+ # Quick Checkout with Google Pay not always sends events for shipping method selection
+ # we have to check this after payment
+
+ if order.delivery? &&
+ shipping_method_id.present? &&
+ order.shipments.count == 1 &&
+ order.shipping_method.id != shipping_method_id
+
+ result = Spree::Checkout::SelectShippingMethod.call(order: order, params: { shipping_method_id: shipping_method_id })
+
+ # We're running the order update inside Spree::Checkout::SelectShippingMethod
+ order_updater_ran = result.success?
+ end
+ end
+
+ if order.state != old_state && !order_updater_ran
+ order.updater.update_shipment_state
+ order.updater.update_payment_state
+ order.save! if order.changed?
+ end
+
success(order)
end
private
- def cannot_make_transition?(order)
- order.confirm? || order.complete? || order.errors.present?
+ def cannot_make_transition?(order, state = nil)
+ order.state == state || order.confirm? || order.complete? || order.errors.present?
+ end
+
+ def report_advance_error(error, order)
+ # You can report checkout advance error here
end
end
end
diff --git a/core/app/services/spree/checkout/select_shipping_method.rb b/core/app/services/spree/checkout/select_shipping_method.rb
index ce3fa41b73..303abd927f 100644
--- a/core/app/services/spree/checkout/select_shipping_method.rb
+++ b/core/app/services/spree/checkout/select_shipping_method.rb
@@ -26,6 +26,8 @@ module Spree
end
end
+ order.update_with_updater!
+
success(order)
end
diff --git a/core/app/services/spree/error_handler.rb b/core/app/services/spree/error_handler.rb
new file mode 100644
index 0000000000..9ce7bec88e
--- /dev/null
+++ b/core/app/services/spree/error_handler.rb
@@ -0,0 +1,47 @@
+module Spree
+ class ErrorHandler
+ prepend ::Spree::ServiceModule::Base
+
+ def call(exception:, opts: {})
+ run :format_message
+ run :log_error
+ run :report_error
+ end
+
+ protected
+
+ def format_message(exception:, opts:)
+ message = if exception.respond_to?(:original_message)
+ exception.original_message
+ else
+ exception.message
+ end
+
+ success(exception: exception, message: message, opts: opts)
+ end
+
+ def log_error(exception:, message:, opts:)
+ Rails.logger.error message
+ Rails.logger.error "User ID: #{opts[:user]&.id}" if opts[:user]
+ Rails.logger.error exception.backtrace.join("\n")
+
+ success(exception: exception, message: message, opts: opts)
+ end
+
+ def report_error(exception:, message:, opts:)
+ # overwrite this method in your application to support different error handlers
+ # eg. Sentry, Rollbar, etc
+ if defined?(Sentry)
+ if opts[:sentry_context].present?
+ Sentry.configure_scope do |scope|
+ scope.set_context(:extra, opts[:report_context])
+ end
+ end
+
+ Sentry.capture_exception(exception)
+ end
+
+ success(exception: exception, message: message)
+ end
+ end
+end
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 2ef887ae22..8b4be82897 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -649,6 +649,9 @@ en:
card_type: Brand
card_type_is: Card type is
cart: Cart
+ cart_line_item:
+ discontinued: '%{li_name} was removed because it was discontinued'
+ out_of_stock: '%{li_name} was removed because it was sold out'
cart_page:
add_promo_code: ADD PROMO CODE
change_quantity: Change quantity
@@ -662,6 +665,7 @@ en:
cart_subtotal:
one: 'Subtotal (1 item)'
other: 'Subtotal (%{count} items)'
+ cart_state_changed: Cart changed
categories: Categories
category: Category
category_nav_bar:
diff --git a/core/db/migrate/20250110171203_add_quick_checkout_to_spree_addresses.rb b/core/db/migrate/20250110171203_add_quick_checkout_to_spree_addresses.rb
new file mode 100644
index 0000000000..33af159b9d
--- /dev/null
+++ b/core/db/migrate/20250110171203_add_quick_checkout_to_spree_addresses.rb
@@ -0,0 +1,6 @@
+class AddQuickCheckoutToSpreeAddresses < ActiveRecord::Migration[6.1]
+ def change
+ add_column :spree_addresses, :quick_checkout, :boolean, default: false, if_not_exists: true
+ add_index :spree_addresses, :quick_checkout, if_not_exists: true
+ end
+end
diff --git a/core/lib/spree/testing_support/common_rake.rb b/core/lib/spree/testing_support/common_rake.rb
index 879ebf6f09..72177ca940 100644
--- a/core/lib/spree/testing_support/common_rake.rb
+++ b/core/lib/spree/testing_support/common_rake.rb
@@ -41,7 +41,7 @@ namespace :common do
system('bin/rails db:environment:set RAILS_ENV=test > /dev/null 2>&1')
system('bundle exec rake db:drop db:create > /dev/null 2>&1')
Spree::DummyModelGenerator.start
- system('bundle exec rake db:migrate > /dev/null 2>&1')
+ system('bundle exec rake db:migrate')
begin
require "generators/#{ENV['LIB_NAME']}/install/install_generator"
diff --git a/core/spec/models/spree/base_spec.rb b/core/spec/models/spree/base_spec.rb
index 86ee6abe7d..2c1d12a817 100644
--- a/core/spec/models/spree/base_spec.rb
+++ b/core/spec/models/spree/base_spec.rb
@@ -57,11 +57,11 @@ describe Spree::Base do
expect(Spree::LegacyUser.json_api_columns).to include('email')
end
- it { expect(Spree::Address.json_api_columns).to contain_exactly('address1', 'address2', 'alternative_phone', 'city', 'company', 'created_at', 'deleted_at', 'firstname', 'label', 'lastname', 'phone', 'state_name', 'updated_at', 'zipcode', 'public_metadata', 'private_metadata') }
+ it { expect(Spree::Address.json_api_columns).to contain_exactly('address1', 'address2', 'alternative_phone', 'city', 'company', 'created_at', 'deleted_at', 'firstname', 'label', 'lastname', 'phone', 'state_name', 'updated_at', 'zipcode', 'public_metadata', 'private_metadata', 'quick_checkout') }
it { expect(Spree::Address.json_api_columns).not_to include('country_id') }
end
describe '.json_api_permitted_attributes' do
- it { expect(Spree::Address.json_api_permitted_attributes).to contain_exactly('firstname', 'lastname', 'address1', 'address2', 'city', 'zipcode', 'phone', 'state_name', 'alternative_phone', 'company', 'state_id', 'country_id', 'created_at', 'updated_at', 'user_id', 'deleted_at', 'label', 'public_metadata', 'private_metadata') }
+ it { expect(Spree::Address.json_api_permitted_attributes).to contain_exactly('firstname', 'lastname', 'address1', 'address2', 'city', 'zipcode', 'phone', 'state_name', 'alternative_phone', 'company', 'state_id', 'country_id', 'created_at', 'updated_at', 'user_id', 'deleted_at', 'label', 'public_metadata', 'private_metadata', 'quick_checkout') }
end
end
diff --git a/core/spec/services/spree/cart/remove_out_of_stock_items_spec.rb b/core/spec/services/spree/cart/remove_out_of_stock_items_spec.rb
new file mode 100644
index 0000000000..a5f9c057c2
--- /dev/null
+++ b/core/spec/services/spree/cart/remove_out_of_stock_items_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Cart::RemoveOutOfStockItems do
+ subject { described_class }
+
+ let(:store) { Spree::Store.default }
+ let(:user) { create(:user) }
+ let(:order) { create(:order_with_totals, store: store, user: user) }
+ let(:execute) { subject.call(order: order) }
+
+ it 'evaluate service to success' do
+ expect(execute).to be_success
+ end
+
+ it 'removes line item and render discontinued flash message' do
+ product = order.products.first
+ product.update_columns(status: 'archive')
+ expect(execute.value.last.to_sentence).to eq(Spree.t('cart_line_item.discontinued', li_name: product.name))
+ end
+
+ it 'removes line item and render out of stock flash message' do
+ product = order.products.first
+ product.stock_items.update_all(count_on_hand: 0, backorderable: false)
+ expect(execute.value.last.to_sentence).to eq(Spree.t('cart_line_item.out_of_stock', li_name: product.name))
+ end
+
+ it 'renders discontinued flash message when line item is deleted' do
+ product = order.products.first
+ product.delete
+ expect(execute.value.last.to_sentence).to eq(Spree.t('cart_line_item.discontinued', li_name: product.name))
+ end
+
+ it 'renders discontinued flash message when line item is discontinued' do
+ product = order.products.first
+ product.update_columns(status: 'discontinued')
+ expect(execute.value.last.to_sentence).to eq(Spree.t('cart_line_item.discontinued', li_name: product.name))
+ end
+
+ it 'renders discontinued flash message when a variant is discontinued' do
+ variant = order.variants.first
+ variant.discontinue!
+ expect(execute.value.last.to_sentence).to eq(Spree.t('cart_line_item.discontinued', li_name: variant.product.name))
+ end
+end
diff --git a/core/spec/services/spree/checkout/advance_spec.rb b/core/spec/services/spree/checkout/advance_spec.rb
new file mode 100644
index 0000000000..95622a3a59
--- /dev/null
+++ b/core/spec/services/spree/checkout/advance_spec.rb
@@ -0,0 +1,169 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Checkout::Advance do
+ let(:service) { described_class.new }
+ let(:order) { create(:order_ready_to_ship, state: :address) }
+ let(:shipping_method) { create(:shipping_method) }
+
+ describe '#call' do
+ context 'with no specific target state' do
+ before do
+ order.payments.last.update(amount: 19.99)
+ order.update(payment_total: 19.99, completed_at: nil)
+ order.reload
+ Spree::StockItem.where(variant: order.variants).update_all(count_on_hand: 10, backorderable: false)
+ end
+
+ it 'advances the order until it cannot proceed further' do
+ ensure_states_updated_only_once
+
+ result = service.call(order: order)
+
+ expect(result).to be_success
+ expect(order.reload.state).to eq('confirm')
+ end
+
+ it 'updates order states after advancement' do
+ ensure_states_updated_only_once
+
+ service.call(order: order)
+
+ expect(order.shipment_state).to eq('pending')
+ expect(order.payment_state).to eq('paid')
+ end
+
+ context 'when no transition has been made' do
+ before do
+ order.payments.destroy_all
+ order.update_column(:state, 'payment')
+ end
+
+ it 'responds with an error' do
+ result = service.call(order: order)
+
+ expect(result).to be_failure
+ expect(result.error.value.full_messages).to contain_exactly(Spree.t(:no_payment_found))
+ end
+ end
+ end
+
+ context 'with specific target state' do
+ it 'returns failure for invalid state' do
+ result = service.call(order: order, state: 'invalid_state')
+
+ expect(result).to be_failure
+ end
+
+ it 'returns success if order already passed target state' do
+ order.update_column(:state, 'payment')
+
+ result = service.call(order: order, state: 'address')
+
+ expect(result).to be_success
+ expect(order.state).to eq('payment')
+ end
+
+ it 'advances the order to target state' do
+ ensure_states_updated_only_once
+
+ result = service.call(order: order, state: 'delivery')
+
+ expect(result).to be_success
+ expect(order.state).to eq('delivery')
+ end
+
+ context 'when unable to reach the targeted state' do
+ before do
+ order.payments.destroy_all
+ end
+
+ it 'responds with an error' do
+ result = service.call(order: order, state: 'complete')
+
+ expect(result).to be_failure
+ expect(result.error.value.full_messages).to contain_exactly(Spree.t(:no_payment_found))
+ end
+ end
+ end
+
+ context 'with shipping method selection' do
+ let(:new_shipping_method) { create(:shipping_method) }
+ let(:order) { create(:order_ready_to_ship, state: :address) }
+
+ it 'updates shipping method during advancement' do
+ expect_next_instance_of(Spree::Checkout::SelectShippingMethod) do |instance|
+ expect(instance).
+ to receive(:call).
+ with(order: order, params: { shipping_method_id: new_shipping_method.id }).
+ and_call_original
+ end
+ ensure_states_updated_only_once
+
+ result = service.call(order: order, shipping_method_id: new_shipping_method.id, state: 'delivery')
+
+ expect(result).to be_success
+ expect(order.shipping_method).to eq(new_shipping_method)
+ expect(order.reload.state).to eq('delivery')
+ end
+
+ context 'on shipping method failure' do
+ before do
+ allow_next_instance_of(Spree::Checkout::SelectShippingMethod) do |instance|
+ allow(instance).to receive(:call).
+ and_return(
+ double(
+ :failure,
+ success?: false, failure?: true,
+ value: order, error: 'Shipping method error'
+ )
+ )
+ end
+ end
+
+ it 'keeps the old shipping method' do
+ result = service.call(order: order, shipping_method_id: new_shipping_method.id, state: 'delivery')
+
+ expect(result).to be_success
+ expect(order.reload.shipping_method).to eq(order.shipments.first.shipping_method)
+ expect(order.state).to eq('delivery')
+ end
+ end
+ end
+
+ context 'when next service fails' do
+ before do
+ allow_next_instance_of(Spree::Dependencies.checkout_next_service.constantize) do |instance|
+ allow(instance).to receive(:call).and_return(Spree::ServiceModule::Result.new(false, order))
+ end
+ end
+
+ it 'returns failure result' do
+ old_order_state = order.state
+ result = service.call(order: order)
+
+ expect(result).to be_failure
+ expect(order.reload.state).to eq(old_order_state)
+ end
+ end
+
+ context 'when order is complete' do
+ let(:order) { create(:order_ready_to_ship) }
+
+ it 'stops advancement' do
+ expect(Spree::Dependencies.checkout_next_service.constantize).not_to receive(:new)
+
+ result = service.call(order: order)
+
+ expect(result).to be_success
+ expect(order.state).to eq('complete')
+ end
+ end
+ end
+
+ def ensure_states_updated_only_once
+ updater_spy = Spree::OrderUpdater.new(order)
+ allow(order).to receive(:updater).and_return(updater_spy)
+ expect(updater_spy).to receive(:update_shipment_state).once.and_call_original
+ expect(updater_spy).to receive(:update_payment_state).once.and_call_original
+ end
+end
diff --git a/core/spec/services/spree/error_handler_spec.rb b/core/spec/services/spree/error_handler_spec.rb
new file mode 100644
index 0000000000..bc8d995dfe
--- /dev/null
+++ b/core/spec/services/spree/error_handler_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+RSpec.describe Spree::ErrorHandler do
+ class CustomException < StandardError
+ def backtrace
+ ['a', 'b']
+ end
+ end
+
+ let(:message) { 'error' }
+ let(:exception) { CustomException.new(message) }
+ let(:user) { create :user }
+
+ subject { described_class.call(exception: exception, opts: { user: user }) }
+ let(:result) { subject }
+
+ it 'returns result with error' do
+ expect(Rails.logger).to receive(:error).with(message)
+ expect(Rails.logger).to receive(:error).with("User ID: #{user.id}")
+ expect(Rails.logger).to receive(:error).with(exception.backtrace.join("\n"))
+
+ expect(result.value).to eq({ exception: exception, message: message })
+ end
+end
diff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rb
index 419d34bddc..81cafcf768 100644
--- a/core/spec/spec_helper.rb
+++ b/core/spec/spec_helper.rb
@@ -48,6 +48,7 @@ require 'spree/testing_support/preferences'
require 'spree/testing_support/url_helpers'
require 'spree/testing_support/kernel'
require 'spree/testing_support/rspec_retry_config'
+require 'spree/testing_support/next_instance_of'
RSpec.configure do |config|
config.color = true
diff --git a/docs/api-reference/storefront.yaml b/docs/api-reference/storefront.yaml
index f95984805a..49011825b0 100644
--- a/docs/api-reference/storefront.yaml
+++ b/docs/api-reference/storefront.yaml
@@ -973,6 +973,33 @@ paths:
summary: Selects shipping method for shipment(s)
tags:
- Checkout / Shipments
+ /api/v2/storefront/checkout/validate_order_for_payment:
+ post:
+ description: |-
+ Validate an order before placing it. It will respond with an error when:
+ - cart was changed
+ - any order item is out of stock
+ - any order item is discontinued
+ operationId: validate-order-payment
+ responses:
+ '200':
+ $ref: '#/components/responses/Cart'
+ '422':
+ $ref: '#/components/responses/CartWithErrors'
+ security:
+ - orderToken: []
+ - bearerAuth: []
+ parameters:
+ - in: query
+ name: skip_state
+ description: Set to `true` if the check for cart changes should be skipped
+ schema:
+ type: boolean
+ - $ref: '#/components/parameters/CartIncludeParam'
+ - $ref: '#/components/parameters/SparseFieldsCart'
+ summary: Validate order payment
+ tags:
+ - Checkout
/api/v2/storefront/checkout/create_payment:
post:
description: |-
@@ -1165,6 +1192,12 @@ paths:
type: string
example: '1,2,3,4,5,6,7,8,9,10,11'
description: 'Filter Products based on taxons (IDs of categories, brands, etc)'
+ - in: query
+ name: 'filter[vendor_ids]'
+ schema:
+ type: string
+ example: 'bb492c7d-c174-4e6b-ba0b-fe98d5c17307,51c35adb-7ab3-4880-8887-35bdc4f6c29f'
+ description: 'Fetch products from specified Vendors (Sellers) only'
- in: query
name: 'filter[name]'
schema:
@@ -1353,6 +1386,12 @@ paths:
type: boolean
example: false
description: Fetch only root Taxons (Taxonomies)
+ - in: query
+ name: 'filter[vendor_id]'
+ schema:
+ type: string
+ example: '1'
+ description: Fetch only Taxons that have products of a selected Vendor
- $ref: '#/components/parameters/PageParam'
- $ref: '#/components/parameters/PerPageParam'
- $ref: '#/components/parameters/TaxonIncludeParam'
@@ -1500,6 +1539,131 @@ paths:
in: path
required: true
description: The ID of the `menu` you wish to retrieve.
+ /api/v2/storefront/stripe/payment_intents:
+ post:
+ summary: Create a Stripe Payment Intent
+ description: Create a Stripe Payment Intent using provided payment method. It creates a Stripe customer if not exists.
+ tags:
+ - Stripe
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ payment_intent:
+ type: object
+ properties:
+ amount:
+ type: number
+ description: The payment amount
+ stripe_payment_method_id:
+ type: string
+ description: Stripe Payment Method ID
+ off_session:
+ type: boolean
+ description: If the payment is off-session (eq. payment method from setup intent)
+ required:
+ - payment_intent
+ operationId: create-stripe-payment-intent
+ responses:
+ '200':
+ $ref: '#/components/responses/StripePaymentIntent'
+ '422':
+ $ref: '#/components/responses/422UnprocessableEntity'
+ security:
+ - orderToken: []
+ get:
+ summary: Return a Stripe Payment Intent
+ description: 'Returns the Payment Intent information'
+ tags:
+ - Stripe
+ operationId: show-stripe-payment-intent
+ responses:
+ '200':
+ $ref: '#/components/responses/StripePaymentIntent'
+ '403':
+ $ref: '#/components/responses/403Forbidden'
+ '404':
+ $ref: '#/components/responses/404NotFound'
+ security:
+ - orderToken: []
+ patch:
+ summary: Create a Stripe Payment Intent
+ description: Create a Stripe Payment Intent using provided payment method. It creates a Stripe customer if not exists.
+ tags:
+ - Stripe
+ operationId: update-stripe-payment-intent
+ security:
+ - orderToken: []
+ requestBody:
+ content:
+ application/vnd.api+json:
+ schema:
+ type: object
+ properties:
+ payment_intent:
+ type: object
+ properties:
+ amount:
+ type: number
+ description: A new payment amount
+ stripe_payment_method_id:
+ type: string
+ description: A new Stripe Payment Method ID
+ off_session:
+ type: boolean
+ description: If the payment is off-session (eq. payment method from setup intent)
+ required:
+ - payment_intent
+ responses:
+ '200':
+ $ref: '#/components/responses/StripePaymentIntent'
+ '403':
+ $ref: '#/components/responses/403Forbidden'
+ '404':
+ $ref: '#/components/responses/404NotFound'
+ /api/v2/storefront/stripe/setup_intents:
+ post:
+ summary: Create a Stripe Setup Intent
+ description: "First, this endpoint creates a customer in Stripe (if it doesn't already exist), then it creates an Ephemeral Key for the customer, and finally, it creates a Setup Intent for the customer."
+ tags:
+ - Stripe
+ operationId: create-stripe-setup-intent
+ responses:
+ '200':
+ $ref: '#/components/responses/StripeSetupIntent'
+ '422':
+ $ref: '#/components/responses/422UnprocessableEntity'
+ /api/v2/storefront/vendors:
+ get:
+ description: 'Returns a list of Vendors.'
+ summary: List all Vendors available on this Store / Marketplace.
+ tags:
+ - Vendors
+ operationId: vendors-list
+ parameters:
+ - $ref: '#/components/parameters/PageParam'
+ - $ref: '#/components/parameters/PerPageParam'
+ - $ref: '#/components/parameters/SparseFieldsVendor'
+ responses:
+ '200':
+ $ref: '#/components/responses/VendorList'
+ '/api/v2/storefront/vendors/{vendor_slug}':
+ get:
+ description: Returns the details of a specified Vendor.
+ summary: Retrieve a Vendor
+ tags:
+ - Vendors
+ operationId: show-vendor
+ parameters:
+ - $ref: '#/components/parameters/VendorSlug'
+ - $ref: '#/components/parameters/SparseFieldsVendor'
+ responses:
+ '200':
+ $ref: '#/components/responses/Vendor'
+ '404':
+ $ref: '#/components/responses/404NotFound'
/api/v2/storefront/wishlists:
get:
description: 'Returns all wishlists available to the current user, in the current store.'
@@ -4117,6 +4281,58 @@ components:
data:
$ref: '#/components/schemas/Relation'
description: Digital links are accessible in the order includes line_items.digital_links
+ Vendor:
+ title: Vendor
+ description: 'Vendors are Sellers in the marketplace.'
+ type: object
+ x-internal: true
+ properties:
+ id:
+ type: string
+ example: '980a80d5-f51b-4065-b3a0-622fc5cb6bf6'
+ type:
+ type: string
+ default: vendor
+ attributes:
+ type: object
+ properties:
+ name:
+ type: string
+ example: 'Shoes For Everyone'
+ email:
+ type: string
+ example: '[email protected]'
+ slug:
+ type: string
+ example: 'shoes-for-everyone'
+ about_us:
+ type: string
+ example: '<p>We are the #1 shoe store for you.</p>\n<p>Located in 20 countries.</p>'
+ description: Information about the Vendor stored as HTML
+ logo_url:
+ type: string
+ example: 'https://somewebsite.com/our-logo'
+ description: URL of the Logo
+ cover_photo_url:
+ type: string
+ example: 'https://somewebsite.com/our-cover-photo'
+ description: URL of the Cover Photo
+ relationships:
+ type: object
+ properties:
+ products:
+ type: object
+ description: List of active and available products from this vendor
+ properties:
+ data:
+ type: array
+ items:
+ $ref: '#/components/schemas/Relation'
+ required:
+ - id
+ - type
+ - attributes
+ - relationships
parameters:
Token:
name: token
@@ -4233,11 +4449,11 @@ components:
Specify what related resources (relationships) you would like to receive in the response body. Eg.
```
- default_variant,variants,option_types,product_properties,taxons,images,primary_variant
+ default_variant,variants,option_types,product_properties,taxons,images,primary_variant,vendor
```
[More information](https://jsonapi.org/format/#fetching-includes)
- example: 'default_variant,variants,option_types,product_properties,taxons,images,primary_variant'
+ example: 'default_variant,variants,option_types,product_properties,taxons,images,primary_variant,vendor'
StoreIncludeParam:
name: include
in: query
@@ -4435,6 +4651,13 @@ components:
description: 'Specify the fields you would like returned in the response body. [More information](https://jsonapi.org/format/#fetching-sparse-fieldsets).'
schema:
type: string
+ SparseFieldsVendor:
+ name: 'fields[vendor]'
+ in: query
+ description: 'Specify the fields you would like returned in the response body. [More information](https://jsonapi.org/format/#fetching-sparse-fieldsets).'
+ schema:
+ type: string
+ example: 'name,slug,about_us,facebook'
SparseFieldsWishlist:
in: query
name: 'fields[wishlist]'
@@ -4442,6 +4665,14 @@ components:
description: 'Specify the fields you would like returned in the response body. [More information](https://jsonapi.org/format/#fetching-sparse-fieldsets).'
schema:
type: string
+ VendorSlug:
+ name: vendor_slug
+ in: path
+ required: true
+ description: Look for Vendor by ID or their slug
+ schema:
+ type: string
+ example: acme-co
responses:
404NotFound:
description: 404 Not Found - Resource not found.
@@ -4988,6 +5219,30 @@ components:
data:
id: '1'
type: stock_location
+ CartWithErrors:
+ description: 422 Unprocessable entity - Returns the `cart` object with errors.
+ content:
+ application/vnd.api+json:
+ schema:
+ type: object
+ properties:
+ data:
+ $ref: '#/components/schemas/Cart'
+ included:
+ type: array
+ items:
+ $ref: '#/components/schemas/CartIncludes'
+ meta:
+ type: object
+ properties:
+ messages:
+ type: array
+ items:
+ type: string
+ example: Cart changed
+ required:
+ - data
+ - meta
CartList:
description: 200 Success - Returns an array of `cart` objects.
content:
@@ -5379,7 +5634,7 @@ components:
total_count: 1
total_pages: 1
links:
- self: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items,variants,variants.images,billing_address,shipping_address,user,payments,shipments,promotions'
+ self: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items,variants,variants.images,billing_address,shipping_address,user,payments,shipments,promotions,vendors'
next: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
prev: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
last: 'http://localhost:3000/api/v2/storefront/account/orders?include=line_items%2Cvariants%2Cvariants.images%2Cbilling_address%2Cshipping_address%2Cuser%2Cpayments%2Cshipments%2Cpromotions&page=1'
@@ -6625,6 +6880,89 @@ components:
prev: 'http://localhost:3000/api/v2/storefront/account/credit_cards?page=1'
last: 'http://localhost:3000/api/v2/storefront/account/credit_cards?page=0'
first: 'http://localhost:3000/api/v2/storefront/account/credit_cards?page=1'
+ StripeSetupIntent:
+ description: 200 Success - Returns the `customer_id` of the authenticated user, created ephemeral key's secret and client secret of the created setup intent.
+ content:
+ application/vnd.api+json:
+ schema:
+ type: object
+ properties:
+ customer_id:
+ type: string
+ description: |
+ Stripe's customer ID of the authenticated user (or new one if unauthenticated).
+ ephemeral_key_secret:
+ type: string
+ description: |
+ Secret of the created ephemeral key.
+ setup_intent_client_secret:
+ type: string
+ description: |
+ Client secret of the created setup intent
+ required:
+ - customer_id
+ - ephemeral_key_secret
+ - setup_intent_client_secret
+ examples:
+ Stripe Setup Intent:
+ value:
+ customer_id: 'cus_Q9uqUz6gVQFku2'
+ ephemeral_key_secret: 'ek_test_YWNjdF8xTGtSb1lJaFIwZ0llZ0llyG1LbFhsVU9XWHY1SlNyMXRKVzNJb0hyQ2JZam1HY28_007lGgvGaA'
+ setup_intent_client_secret: 'seti_1PJb0hIhR0gIegIeZYQQuxpH_secret_Q9uqLuTAvIJQSK1SFS6OaxJMRpe9s7R'
+ StripePaymentIntent:
+ description: 200 Success - Returns the Stripe Payment Intent with the Stripe ID, client key, ephemeral_key, customer_id, amount and Stripe Payment Method ID.
+ content:
+ application/vnd.api+json:
+ schema:
+ type: object
+ properties:
+ data:
+ type: object
+ properties:
+ id:
+ type: string
+ example: 980a80d5-f51b-4065-b3a0-622fc5cb6bf6
+ type:
+ type: string
+ default: payment_intent
+ attributes:
+ type: object
+ properties:
+ stripe_id:
+ type: string
+ description: The Stripe internal ID of the Payment Intent
+ client_secret:
+ type: string
+ description: |
+ The client secret can be used to complete a payment from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.
+ ephemeral_key_secret:
+ type: string
+ description: |
+ Secret of the created ephemeral key.
+ customer_id:
+ type: string
+ description: |
+ Stripe's customer ID of the authenticated user (or new one if unauthenticated).
+ amount:
+ type: number
+ description: The payment amount
+ stripe_payment_method_id:
+ type: string
+ description: |
+ This is the same stripe_payment_method_id that was sent in the parameters. It can be used to confirm Stripe intent that was not confirmed before
+ examples:
+ Stripe Payment Intent:
+ value:
+ data:
+ id: '980a80d5-f51b-4065-b3a0-622fc5cb6bf6'
+ type: payment_intent
+ attributes:
+ stripe_id: 'pi_3QhUuj2ESifGlJez0ADSS4tu'
+ client_secret: 'pi_3KQRG2DcAgmy0ota09WCW6nf_secret_8XTxRbOyg7oEkvvIOvnP75dRw'
+ ephemeral_key_secret: 'ek_test_YWNjdF8xTGtSb1lJaFIwZ0llZ0llyG1LbFhsVU9XWHY1SlNyMXRKVzNJb0hyQ2JZam1HY28_007lGgvGaA'
+ customer_id: 'cus_Q9uqUz6gVQFku2'
+ amount: '44.0'
+ stripe_payment_method_id: 'pm_1Qedd42ESifGlJez0IOx5AZ3'
Product:
description: 200 Success - Returns the `product` object.
content:
@@ -16823,6 +17161,71 @@ components:
name: Check
description: Pay by check.
preferences: {}
+ Vendor:
+ description: 200 Success - Returns the `vendor` object.
+ content:
+ application/vnd.api+json:
+ schema:
+ type: object
+ properties:
+ data:
+ $ref: '#/components/schemas/Vendor'
+ required:
+ - data
+ examples:
+ Single Vendor:
+ value:
+ data:
+ id: 'e1171601-a4ce-47d2-a795-c96fbdf20029'
+ type: vendor
+ attributes:
+ name: 'Best Shoes'
+ slug: 'best-shoes'
+ about_us: "<p>We are your #1 shoe store.</p>\n<p>Follow us on social media.</p>"
+ logo_url: 'https://assets.com/images/logo_name'
+ cover_photo_url: 'https://assets.com/images/wide_tree_wzxgak'
+ VendorList:
+ description: 200 Success - Returns an array of `vendor` objects.
+ content:
+ application/vnd.api+json:
+ schema:
+ type: object
+ properties:
+ data:
+ type: array
+ items:
+ $ref: '#/components/schemas/Vendor'
+ meta:
+ $ref: '#/components/schemas/ListMeta'
+ links:
+ $ref: '#/components/schemas/ListLinks'
+ required:
+ - data
+ - meta
+ - links
+ examples:
+ List of Vendors:
+ value:
+ data:
+ - id: 'eb261155-1ddc-47e5-8178-8c3da6e607a8'
+ type: vendor
+ attributes:
+ name: 'Best Shoes'
+ slug: 'best-shoes'
+ about_us: "<p>We are your #1 shoe store.</p>\n<p>Follow us on social media.</p>"
+ logo_url: 'https://assets.com/images/logo_name'
+ cover_photo_url: 'https://assets.com/images/wide_tree_wzxgak'
+ - id: '4f46f04f-fa2c-42d0-b69c-ce2b2997f5fd'
+ type: vendor
+ attributes:
+ name: 'Best Shirts'
+ slug: 'best-shirts'
+ about_us: "<p>We are your #1 shirts store.</p>\n<p>Follow us on social media.</p>"
+ logo_url: 'https://assets.com/images/logo_name34553'
+ cover_photo_url: 'https://assets.com/images/coverfn5ig'
tags:
- name: Account
- name: Account / Address
@@ -16837,6 +17240,7 @@ tags:
- name: Checkout / Shipments
- name: Checkout / Payments
- name: Checkout / Store Credit
+ - name: Stripe
- name: CMS Pages
- name: Countries
- name: Digital Downloads
@@ -16846,5 +17250,6 @@ tags:
- name: Variants
- name: Stores
- name: Taxons
+ - name: Vendors
- name: Wishlists
- name: Wishlists / Wished Items