Class: Spree::Api::V3::Admin::Orders::RefundsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- ResourceController
- ResourceController
- BaseController
- Spree::Api::V3::Admin::Orders::RefundsController
- Defined in:
- app/controllers/spree/api/v3/admin/orders/refunds_controller.rb
Constant Summary
Constants included from ScopedAuthorization
ScopedAuthorization::READ_ACTIONS
Constants inherited from BaseController
BaseController::RATE_LIMIT_RESPONSE
Constants included from Idempotent
Idempotent::IDEMPOTENCY_HEADER, Idempotent::IDEMPOTENCY_TTL, Idempotent::MAX_KEY_LENGTH, Idempotent::MUTATING_METHODS
Constants included from ErrorHandler
Constants included from JwtAuthentication
JwtAuthentication::JWT_AUDIENCE_ADMIN, JwtAuthentication::JWT_AUDIENCE_STORE, JwtAuthentication::JWT_ISSUER, JwtAuthentication::USER_TYPE_ADMIN, JwtAuthentication::USER_TYPE_CUSTOMER
Instance Method Summary collapse
-
#create ⇒ Object
POST /api/v3/admin/orders/:order_id/refunds.
Methods inherited from ResourceController
#destroy, #index, #show, #update
Methods included from Spree::Api::V3::ApiKeyAuthentication
#authenticate_api_key!, #authenticate_secret_key!
Methods included from JwtAuthentication
#authenticate_user, #require_authentication!
Instance Method Details
#create ⇒ Object
POST /api/v3/admin/orders/:order_id/refunds
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/spree/api/v3/admin/orders/refunds_controller.rb', line 10 def create with_order_lock do payment = @parent.payments.find_by_prefix_id!(params[:payment_id]) reason = Spree::RefundReason.find_by_prefix_id!(params[:refund_reason_id]) if params[:refund_reason_id].present? reason ||= Spree::RefundReason.first @resource = payment.refunds.build( amount: params[:amount], reason: reason, transaction_id: nil ) (@resource, :create) if @resource.save render json: serialize_resource(@resource), status: :created else render_validation_error(@resource.errors) end end end |