Class: Spree::Api::V1::PaymentsController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#content_type, #permitted_line_item_attributes
included
Instance Method Details
#authorize ⇒ Object
44
45
46
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 44
def authorize
perform_payment_action(:authorize)
end
|
#capture ⇒ Object
48
49
50
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 48
def capture
perform_payment_action(:capture)
end
|
#create ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 19
def create
@order.validate_payments_attributes([payment_params])
@payment = @order.payments.build(payment_params)
if @payment.save
respond_with(@payment, status: 201, default_template: :show)
else
invalid_resource!(@payment)
end
end
|
#index ⇒ Object
9
10
11
12
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 9
def index
@payments = @order.payments.ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
respond_with(@payments)
end
|
#new ⇒ Object
14
15
16
17
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 14
def new
@payment_methods = Spree::PaymentMethod.available
respond_with(@payment_methods)
end
|
#purchase ⇒ Object
52
53
54
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 52
def purchase
perform_payment_action(:purchase)
end
|
#show ⇒ Object
40
41
42
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 40
def show
respond_with(@payment)
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 29
def update
authorize! params[:action], @payment
if !@payment.editable?
render 'update_forbidden', status: 403
elsif @payment.update_attributes(payment_params)
respond_with(@payment, default_template: :show)
else
invalid_resource!(@payment)
end
end
|
#void ⇒ Object
56
57
58
|
# File 'app/controllers/spree/api/v1/payments_controller.rb', line 56
def void
perform_payment_action(:void_transaction)
end
|