Class: Spree::Api::PaymentsController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #permitted_line_item_attributes, #set_jsonp_format
included
Instance Method Details
#authorize ⇒ Object
42
43
44
|
# File 'app/controllers/spree/api/payments_controller.rb', line 42
def authorize
perform_payment_action(:authorize)
end
|
#capture ⇒ Object
46
47
48
|
# File 'app/controllers/spree/api/payments_controller.rb', line 46
def capture
perform_payment_action(:capture)
end
|
#create ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'app/controllers/spree/api/payments_controller.rb', line 18
def create
@payment = @order.payments.build(payment_params)
if @payment.save
respond_with(@payment, status: 201, default_template: :show)
else
invalid_resource!(@payment)
end
end
|
#credit ⇒ Object
58
59
60
61
62
63
64
|
# File 'app/controllers/spree/api/payments_controller.rb', line 58
def credit
if params[:amount].to_f > @payment.credit_allowed
render 'credit_over_limit', status: 422
else
perform_payment_action(:credit, params[:amount])
end
end
|
#index ⇒ Object
8
9
10
11
|
# File 'app/controllers/spree/api/payments_controller.rb', line 8
def index
@payments = @order.payments.ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
respond_with(@payments)
end
|
#new ⇒ Object
13
14
15
16
|
# File 'app/controllers/spree/api/payments_controller.rb', line 13
def new
@payment_methods = Spree::PaymentMethod.available
respond_with(@payment_method)
end
|
#purchase ⇒ Object
50
51
52
|
# File 'app/controllers/spree/api/payments_controller.rb', line 50
def purchase
perform_payment_action(:purchase)
end
|
#show ⇒ Object
38
39
40
|
# File 'app/controllers/spree/api/payments_controller.rb', line 38
def show
respond_with(@payment)
end
|
#update ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/spree/api/payments_controller.rb', line 27
def update
authorize! params[:action], @payment
if ! @payment.pending?
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
54
55
56
|
# File 'app/controllers/spree/api/payments_controller.rb', line 54
def void
perform_payment_action(:void_transaction)
end
|