Merge pull request #4580 from Matt-Yorkley/order_capture

Use asynchronous requests for order capture and ship actions
This commit is contained in:
Luis Ramos
2020-01-13 17:14:40 +00:00
committed by GitHub
11 changed files with 187 additions and 22 deletions

View File

@@ -1,8 +1,8 @@
class Api::Admin::OrderSerializer < ActiveModel::Serializer
attributes :id, :number, :user_id, :full_name, :email, :phone, :completed_at, :display_total,
:edit_path, :state, :payment_state, :shipment_state,
:payments_path, :ship_path, :ready_to_ship, :created_at,
:distributor_name, :special_instructions, :payment_capture_path,
:payments_path, :ready_to_ship, :ready_to_capture, :created_at,
:distributor_name, :special_instructions,
:item_total, :adjustment_total, :payment_total, :total
has_one :distributor, serializer: Api::Admin::IdSerializer
@@ -28,15 +28,9 @@ class Api::Admin::OrderSerializer < ActiveModel::Serializer
spree_routes_helper.admin_order_payments_path(object)
end
def ship_path
spree_routes_helper.fire_admin_order_path(object, e: 'ship')
end
def payment_capture_path
def ready_to_capture
pending_payment = object.pending_payments.first
return '' unless object.payment_required? && pending_payment
spree_routes_helper.fire_admin_order_payment_path(object, pending_payment.id, e: 'capture')
object.payment_required? && pending_payment
end
def ready_to_ship