Class: Spree::Api::PaymentsController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#authorize ⇒ Object
32
33
34
|
# File 'app/controllers/spree/api/payments_controller.rb', line 32
def authorize
perform_payment_action(:authorize)
end
|
#capture ⇒ Object
36
37
38
|
# File 'app/controllers/spree/api/payments_controller.rb', line 36
def capture
perform_payment_action(:capture)
end
|
#create ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/controllers/spree/api/payments_controller.rb', line 19
def create
@payment = @order.payments.build(params[:payment])
if @payment.save
respond_with(@payment, :status => 201, :default_template => :show)
else
invalid_resource!(@payment)
end
end
|
#credit ⇒ Object
48
49
50
51
52
53
54
|
# File 'app/controllers/spree/api/payments_controller.rb', line 48
def credit
if params[:amount].to_f > @payment.credit_allowed
render "spree/api/payments/credit_over_limit", :status => 422
else
perform_payment_action(:credit, params[:amount])
end
end
|
#index ⇒ Object
9
10
11
12
|
# File 'app/controllers/spree/api/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/payments_controller.rb', line 14
def new
@payment_methods = Spree::PaymentMethod.where(:environment => Rails.env)
respond_with(@payment_method)
end
|
#purchase ⇒ Object
40
41
42
|
# File 'app/controllers/spree/api/payments_controller.rb', line 40
def purchase
perform_payment_action(:purchase)
end
|
#show ⇒ Object
28
29
30
|
# File 'app/controllers/spree/api/payments_controller.rb', line 28
def show
respond_with(@payment)
end
|
#void ⇒ Object
44
45
46
|
# File 'app/controllers/spree/api/payments_controller.rb', line 44
def void
perform_payment_action(:void_transaction)
end
|