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
|
# File 'app/controllers/trado_paypal_module/paypal_controller.rb', line 5
def confirm
set_order
set_cart_totals
set_grouped_countries
set_browser_data
@order.attributes = params[:order]
if @order.save
@order.calculate(current_cart, Store.tax_rate)
generate_payment_url
if @redirect_url.nil?
flash_message :error, 'An error ocurred with your order. Please try again.'
Rails.logger.error "PayPal: Unable to generate redirect URL."
redirect_to checkout_carts_url
else
redirect_to @redirect_url
end
else
flash_message :error, 'An error ocurred with your order. Please try again.'
render theme_presenter.page_template_path('carts/checkout'), layout: theme_presenter.layout_template_path
end
rescue ActiveMerchant::ConnectionError
flash_message :error, 'An error ocurred with your order. Please try again.'
Rails.logger.error "PayPal: API is temporarily unavailable."
redirect_to checkout_carts_url
end
|