5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/nimbleshop_authorizedotnet/payments_controller.rb', line 5
def create
order = Order.find_by_id! session[:order_id]
address_attrs = order.final_billing_address.to_credit_card_attributes
creditcard_attrs = creditcard_params.merge address_attrs
creditcard = Creditcard.new creditcard_attrs
payment_method = NimbleshopAuthorizedotnet::Authorizedotnet.first
processor = NimbleshopAuthorizedotnet::Processor.new(order: order, payment_method: payment_method)
default_action = Shop.current.default_creditcard_action
if processor.send(default_action, creditcard: creditcard)
url = main_theme.order_path order
@output = "window.location='#{url}'"
else
error = processor.errors.first
Rails.logger.info "Error: #{error}"
@output = "alert('#{error}')"
end
respond_to do |format|
format.js do
render js: @output
end
end
end
|