Я работаю над экспресс-интеграцией PayPal и успешно подключаюсь к PayPal и размещаю платеж, но по возвращении получаю:
ActiveRecord::RecordNotFound in CheckoutController#success
Couldn't find Order without an ID
Действия в моем контроллере:
def place_order
@order = Order.new(params[:order])
@order.customer_ip = request.remote_ip
populate_order
if @order.save
checkout_paypal
else
render :action => 'index'
end
end
def success
@page_title = 'Thank You!'
@order = Order.find(params[:order])
@order.express_payer_id = params[:PayerID]
@order.save
end
private
def checkout_paypal
paypal_response = ::GATEWAY.setup_purchase(
(@order.total * 100).round, # paypal amount is in cents
:ip => request.remote_ip,
:return_url => checkout_success_url(@order),
:cancel_return_url => checkout_error_url(@order)
)
@order.express_token = paypal_response.token
@order.save
redirect_to ::GATEWAY.redirect_url_for(paypal_response.token) and return
end
маршруты:
match '/checkout/place_order', :to => 'checkout#place_order'
match '/checkout/success', :to => 'checkout#success'
match '/checkout/error', :to => 'checkout#error'